Storage Control Pause Anywhere Cache

Storage Control Pause Anywhere Cache

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

C++

For more information, see the Cloud Storage C++ API reference documentation .

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .

  namespace 
  
 storagecontrol 
  
 = 
  
 google 
 :: 
 cloud 
 :: 
 storagecontrol_v2 
 ; 
 []( 
 storagecontrol 
 :: 
 StorageControlClient 
  
 client 
 , 
  
 std 
 :: 
 string 
  
 const 
&  
 cache_name 
 ) 
  
 { 
  
 auto 
  
 anywhere_cache 
  
 = 
  
 client 
 . 
 PauseAnywhereCache 
 ( 
 cache_name 
 ); 
  
 if 
  
 ( 
 ! 
 anywhere_cache 
 ) 
  
 throw 
  
 std 
 :: 
 move 
 ( 
 anywhere_cache 
 ). 
 status 
 (); 
  
 std 
 :: 
 cout 
 << 
 "Paused anywhere cache: " 
 << 
 anywhere_cache 
 - 
> name 
 () 
 << 
 " 
 \n 
 " 
 ; 
 } 
 

Java

For more information, see the Cloud Storage Java API reference documentation .

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .

  import 
  
 com.google.storage.control.v2. AnywhereCache 
 
 ; 
 import 
  
 com.google.storage.control.v2. PauseAnywhereCacheRequest 
 
 ; 
 import 
  
 com.google.storage.control.v2. StorageControlClient 
 
 ; 
 import 
  
 java.io.IOException 
 ; 
 public 
  
 final 
  
 class 
 AnywhereCachePause 
  
 { 
  
 public 
  
 static 
  
 void 
  
 anywhereCachePause 
 ( 
 String 
  
 cacheName 
 ) 
  
 throws 
  
 IOException 
  
 { 
  
 try 
  
 ( 
  StorageControlClient 
 
  
 storageControl 
  
 = 
  
  StorageControlClient 
 
 . 
 create 
 ()) 
  
 { 
  
  PauseAnywhereCacheRequest 
 
  
 request 
  
 = 
  
  PauseAnywhereCacheRequest 
 
 . 
 newBuilder 
 (). 
 setName 
 ( 
 cacheName 
 ). 
 build 
 (); 
  
  AnywhereCache 
 
  
 anywhereCache 
  
 = 
  
 storageControl 
 . 
 pauseAnywhereCache 
 ( 
 request 
 ); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Paused anywhere cache: %s%n" 
 , 
  
 anywhereCache 
 . 
  getName 
 
 ()); 
  
 } 
  
 } 
 } 
 

PHP

For more information, see the Cloud Storage PHP API reference documentation .

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .

  use Google\Cloud\Storage\Control\V2\Client\StorageControlClient; 
 use Google\Cloud\Storage\Control\V2\PauseAnywhereCacheRequest; 
 /** 
 * Pauses an Anywhere Cache instance. 
 * 
 * @param string $bucketName The name of your Cloud Storage bucket. 
 *        (e.g. 'my-bucket') 
 * @param string $anywhereCacheId Uniquely identifies the cache. 
 *        (e.g. 'us-east1-b') 
 */ 
 function pause_anywhere_cache(string $bucketName, string $anywhereCacheId): void 
 { 
 $storageControlClient = new StorageControlClient(); 
 // Set project to "_" to signify global bucket 
 $formattedName = $storageControlClient->anywhereCacheName('_', $bucketName, $anywhereCacheId); 
 $request = new PauseAnywhereCacheRequest([ 
 'name' => $formattedName, 
 ]); 
 $response = $storageControlClient->pauseAnywhereCache($request); 
 printf('Paused anywhere cache: %s', $response->getName()); 
 } 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: