24
24
function main ( bucketName , cacheName ) {
25
25
// [START storage_control_get_anywhere_cache]
26
26
/**
27
- * TODO(developer): Uncomment these variables before running the sample.
27
+ * Retrieves details of a specific Anywhere Cache instance.
28
+ *
29
+ * This function is useful for checking the current state, configuration (like TTL),
30
+ * and other metadata of an existing cache.
31
+ *
32
+ * @param {string } bucketName The name of the bucket where the cache resides.
33
+ * Example: 'your-gcp-bucket-name'
34
+ * @param {string } cacheName The unique identifier of the cache instance.
35
+ * Example: 'my-anywhere-cache-id'
28
36
*/
29
37
30
- // The name of your GCS bucket
31
- // const bucketName = 'bucketName';
32
-
33
- // The name of the cache to get
34
- // const cacheName = 'cacheName';
35
-
36
38
// Imports the Control library
37
39
const { StorageControlClient} = require ( '@google-cloud/storage-control' ) . v2 ;
38
40
@@ -54,6 +56,15 @@ function main(bucketName, cacheName) {
54
56
// Run request
55
57
const [ response ] = await controlClient . getAnywhereCache ( request ) ;
56
58
console . log ( `Got anywhere cache: ${ response . name } .` ) ;
59
+ console . log ( `Anywhere Cache details for '${ cacheName } ':` ) ;
60
+ console . log ( ` ID: ${ response . id } ` ) ;
61
+ console . log ( ` Zone: ${ response . zone } ` ) ;
62
+ console . log ( ` State: ${ response . state } ` ) ;
63
+ console . log ( ` TTL: ${ response . ttl . seconds } s` ) ;
64
+ console . log ( ` Admission Policy: ${ response . admissionPolicy } ` ) ;
65
+ console . log (
66
+ ` Create Time: ${ new Date ( response . createTime . seconds * 1000 ) . toISOString ( ) } `
67
+ ) ;
57
68
}
58
69
59
70
callGetAnywhereCache ( ) ;
0 commit comments