@@ -67,6 +67,7 @@ public static CloudKMS createAuthorizedClient() throws IOException {
6767 .build ();
6868 }
6969
70+ // [START kms_create_keyring]
7071 /**
7172 * Creates a new key ring with the given id.
7273 */
@@ -86,7 +87,9 @@ public static KeyRing createKeyRing(String projectId, String ringId) throws IOEx
8687 System .out .println (keyring );
8788 return keyring ;
8889 }
90+ // [END kms_create_keyring]
8991
92+ // [START kms_create_cryptokey]
9093 /**
9194 * Creates a new crypto key with the given id.
9295 */
@@ -114,7 +117,9 @@ public static CryptoKey createCryptoKey(String projectId, String ringId, String
114117 System .out .println (createdKey );
115118 return createdKey ;
116119 }
120+ // [END kms_create_cryptokey]
117121
122+ // [START kms_create_cryptokey_version]
118123 /**
119124 * Creates a new crypto key version for the given id.
120125 */
@@ -138,7 +143,9 @@ public static void createCryptoKeyVersion(
138143
139144 System .out .println (newVersion );
140145 }
146+ // [END kms_create_cryptokey_version]
141147
148+ // [START kms_disable_cryptokey_version]
142149 /**
143150 * Disables the given version of the crypto key.
144151 */
@@ -166,7 +173,9 @@ public static CryptoKeyVersion disableCryptoKeyVersion(
166173 System .out .println (response );
167174 return response ;
168175 }
176+ // [END kms_disable_cryptokey_version]
169177
178+ // [START kms_destroy_cryptokey_version]
170179 /**
171180 * Marks the given version of a crypto key to be destroyed at a scheduled future point.
172181 */
@@ -192,7 +201,9 @@ public static CryptoKeyVersion destroyCryptoKeyVersion(
192201 System .out .println (destroyed );
193202 return destroyed ;
194203 }
204+ // [END kms_destroy_cryptokey_version]
195205
206+ // [START kms_get_cryptokey_policy]
196207 /**
197208 * Retrieves the IAM policy for the given crypto key.
198209 */
@@ -215,7 +226,9 @@ public static Policy getCryptoKeyPolicy(String projectId, String ringId, String
215226 System .out .println (iamPolicy .getBindings ());
216227 return iamPolicy ;
217228 }
229+ // [END kms_get_cryptokey_policy]
218230
231+ // [START kms_get_keyring_policy]
219232 /**
220233 * Retrieves the IAM policy for the given crypto key.
221234 */
@@ -237,7 +250,9 @@ public static Policy getKeyRingPolicy(String projectId, String ringId) throws IO
237250 System .out .println (iamPolicy .getBindings ());
238251 return iamPolicy ;
239252 }
253+ // [END kms_get_keyring_policy]
240254
255+ // [START kms_add_member_to_cryptokey_policy]
241256 /**
242257 * Adds the given member to the given key, with the given role.
243258 *
@@ -296,7 +311,9 @@ public static Policy addMemberToCryptoKeyPolicy(
296311 System .out .println ("Response: " + newIamPolicy );
297312 return newIamPolicy ;
298313 }
314+ // [END kms_add_member_to_cryptokey_policy]
299315
316+ // [START kms_add_member_to_keyring_policy]
300317 /**
301318 * Adds the given member to the given keyring, with the given role.
302319 *
@@ -354,7 +371,9 @@ public static Policy addMemberToKeyRingPolicy(
354371 System .out .println ("Response: " + newIamPolicy );
355372 return newIamPolicy ;
356373 }
374+ // [END kms_add_member_to_keyring_policy]
357375
376+ // [START kms_remove_member_from_cryptokey_policy]
358377 /**
359378 * Removes the given member from the given policy.
360379 */
@@ -395,7 +414,9 @@ public static Policy removeMemberFromCryptoKeyPolicy(
395414 System .out .println ("Response: " + newIamPolicy );
396415 return newIamPolicy ;
397416 }
417+ // [END kms_remove_member_from_cryptokey_policy]
398418
419+ // [START kms_remove_member_from_keyring_policy]
399420 /**
400421 * Removes the given member from the given policy.
401422 */
@@ -431,7 +452,9 @@ public static Policy removeMemberFromKeyRingPolicy(
431452 System .out .println ("Response: " + newIamPolicy );
432453 return newIamPolicy ;
433454 }
455+ // [END kms_remove_member_from_keyring_policy]
434456
457+ // [START kms_quickstart]
435458 /**
436459 * Prints all the keyrings in the given project.
437460 */
@@ -461,6 +484,7 @@ public static void listKeyRings(String projectId) throws IOException {
461484 System .out .println ("No keyrings defined." );
462485 }
463486 }
487+ // [END kms_quickstart]
464488
465489 /**
466490 * Prints all the keys in the given key ring.
0 commit comments