From 2375491de1b79d6393b04c373f5b8cc6ffb714c5 Mon Sep 17 00:00:00 2001 From: Phil Coakley Date: Thu, 16 Mar 2017 17:49:24 -0400 Subject: [PATCH] Updates Cloud-KMS sample code to use V1 libraries. (#566) * Updates KMS sample code to use V1 libraries. * Updates KMS sample code to use V1 libraries. --- kms/pom.xml | 2 +- kms/src/main/java/com/example/CryptFile.java | 14 +++++----- kms/src/main/java/com/example/Quickstart.java | 10 +++---- .../java/com/example/SnippetCommands.java | 8 +++--- kms/src/main/java/com/example/Snippets.java | 28 +++++++++---------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/kms/pom.xml b/kms/pom.xml index 219c0814d78..31491542629 100644 --- a/kms/pom.xml +++ b/kms/pom.xml @@ -16,7 +16,7 @@ com.google.apis google-api-services-cloudkms - v1beta1-rev412-1.22.0 + v1-rev1-1.22.0 com.google.guava diff --git a/kms/src/main/java/com/example/CryptFile.java b/kms/src/main/java/com/example/CryptFile.java index f0c59d844ae..b01ec244914 100644 --- a/kms/src/main/java/com/example/CryptFile.java +++ b/kms/src/main/java/com/example/CryptFile.java @@ -19,12 +19,12 @@ import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; -import com.google.api.services.cloudkms.v1beta1.CloudKMS; -import com.google.api.services.cloudkms.v1beta1.CloudKMSScopes; -import com.google.api.services.cloudkms.v1beta1.model.DecryptRequest; -import com.google.api.services.cloudkms.v1beta1.model.DecryptResponse; -import com.google.api.services.cloudkms.v1beta1.model.EncryptRequest; -import com.google.api.services.cloudkms.v1beta1.model.EncryptResponse; +import com.google.api.services.cloudkms.v1.CloudKMS; +import com.google.api.services.cloudkms.v1.CloudKMSScopes; +import com.google.api.services.cloudkms.v1.model.DecryptRequest; +import com.google.api.services.cloudkms.v1.model.DecryptResponse; +import com.google.api.services.cloudkms.v1.model.EncryptRequest; +import com.google.api.services.cloudkms.v1.model.EncryptResponse; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -63,7 +63,7 @@ public static CloudKMS createAuthorizedClient() throws IOException { * Encrypts the given bytes, using the primary version of the specified crypto key. * * The primary version can be updated via the updatePrimaryVersion + * href="https://g.co/cloud/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/updatePrimaryVersion">updatePrimaryVersion * method. */ public static byte[] encrypt(String projectId, String ringId, String keyId, byte[] plaintext) diff --git a/kms/src/main/java/com/example/Quickstart.java b/kms/src/main/java/com/example/Quickstart.java index 3148eb7345c..c84e7adcb21 100644 --- a/kms/src/main/java/com/example/Quickstart.java +++ b/kms/src/main/java/com/example/Quickstart.java @@ -20,10 +20,10 @@ import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; -import com.google.api.services.cloudkms.v1beta1.CloudKMS; -import com.google.api.services.cloudkms.v1beta1.CloudKMSScopes; -import com.google.api.services.cloudkms.v1beta1.model.KeyRing; -import com.google.api.services.cloudkms.v1beta1.model.ListKeyRingsResponse; +import com.google.api.services.cloudkms.v1.CloudKMS; +import com.google.api.services.cloudkms.v1.CloudKMSScopes; +import com.google.api.services.cloudkms.v1.model.KeyRing; +import com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse; import java.io.IOException; @@ -84,4 +84,4 @@ public static void main(String... args) throws Exception { } } } -// [END kms_quickstart] \ No newline at end of file +// [END kms_quickstart] diff --git a/kms/src/main/java/com/example/SnippetCommands.java b/kms/src/main/java/com/example/SnippetCommands.java index 4ae9fe506b9..2d6e6d28df0 100644 --- a/kms/src/main/java/com/example/SnippetCommands.java +++ b/kms/src/main/java/com/example/SnippetCommands.java @@ -119,7 +119,7 @@ public void run() throws IOException { public static class AddMemberToKeyRingPolicyCommand extends KeyRingArgs implements Command { @Argument(metaVar = "member", required = true, index = 1, usage = "The member to add.\n" - + "See https://g.co/cloud/kms/docs/reference/rest/v1beta1/Policy#binding " + + "See https://g.co/cloud/kms/docs/reference/rest/v1/Policy#binding " + "for valid values.") String member; @Argument(metaVar = "role", required = true, index = 2, @@ -135,7 +135,7 @@ public void run() throws IOException { public static class AddMemberToCryptoKeyPolicyCommand extends KeyArgs implements Command { @Argument(metaVar = "member", required = true, index = 2, usage = "The member to add.\n" - + "See https://g.co/cloud/kms/docs/reference/rest/v1beta1/Policy#binding " + + "See https://g.co/cloud/kms/docs/reference/rest/v1/Policy#binding " + "for valid values.") String member; @Argument(metaVar = "role", required = true, index = 3, @@ -151,7 +151,7 @@ public void run() throws IOException { public static class RemoveMemberFromKeyRingPolicyCommand extends KeyRingArgs implements Command { @Argument(metaVar = "member", required = true, index = 1, usage = "The member to add.\n" - + "See https://g.co/cloud/kms/docs/reference/rest/v1beta1/Policy#binding " + + "See https://g.co/cloud/kms/docs/reference/rest/v1/Policy#binding " + "for valid values.") String member; @Argument(metaVar = "role", required = true, index = 2, @@ -167,7 +167,7 @@ public void run() throws IOException { public static class RemoveMemberFromCryptoKeyPolicyCommand extends KeyArgs implements Command { @Argument(metaVar = "member", required = true, index = 2, usage = "The member to add.\n" - + "See https://g.co/cloud/kms/docs/reference/rest/v1beta1/Policy#binding " + + "See https://g.co/cloud/kms/docs/reference/rest/v1/Policy#binding " + "for valid values.") String member; @Argument(metaVar = "role", required = true, index = 3, diff --git a/kms/src/main/java/com/example/Snippets.java b/kms/src/main/java/com/example/Snippets.java index 65e3bdc2c7e..41b4c6fa73e 100644 --- a/kms/src/main/java/com/example/Snippets.java +++ b/kms/src/main/java/com/example/Snippets.java @@ -19,18 +19,18 @@ import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; -import com.google.api.services.cloudkms.v1beta1.CloudKMS; -import com.google.api.services.cloudkms.v1beta1.CloudKMSScopes; -import com.google.api.services.cloudkms.v1beta1.model.Binding; -import com.google.api.services.cloudkms.v1beta1.model.CryptoKey; -import com.google.api.services.cloudkms.v1beta1.model.CryptoKeyVersion; -import com.google.api.services.cloudkms.v1beta1.model.DestroyCryptoKeyVersionRequest; -import com.google.api.services.cloudkms.v1beta1.model.KeyRing; -import com.google.api.services.cloudkms.v1beta1.model.ListCryptoKeyVersionsResponse; -import com.google.api.services.cloudkms.v1beta1.model.ListCryptoKeysResponse; -import com.google.api.services.cloudkms.v1beta1.model.ListKeyRingsResponse; -import com.google.api.services.cloudkms.v1beta1.model.Policy; -import com.google.api.services.cloudkms.v1beta1.model.SetIamPolicyRequest; +import com.google.api.services.cloudkms.v1.CloudKMS; +import com.google.api.services.cloudkms.v1.CloudKMSScopes; +import com.google.api.services.cloudkms.v1.model.Binding; +import com.google.api.services.cloudkms.v1.model.CryptoKey; +import com.google.api.services.cloudkms.v1.model.CryptoKeyVersion; +import com.google.api.services.cloudkms.v1.model.DestroyCryptoKeyVersionRequest; +import com.google.api.services.cloudkms.v1.model.KeyRing; +import com.google.api.services.cloudkms.v1.model.ListCryptoKeyVersionsResponse; +import com.google.api.services.cloudkms.v1.model.ListCryptoKeysResponse; +import com.google.api.services.cloudkms.v1.model.ListKeyRingsResponse; +import com.google.api.services.cloudkms.v1.model.Policy; +import com.google.api.services.cloudkms.v1.model.SetIamPolicyRequest; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -264,7 +264,7 @@ public static Policy getKeyRingPolicy(String projectId, String ringId) throws IO * user:$userEmail * serviceAccount:$serviceAccountEmail * - * See https://g.co/cloud/kms/docs/reference/rest/v1beta1/Policy#binding + * See https://g.co/cloud/kms/docs/reference/rest/v1/Policy#binding * for more details. * * @param role Must be in one of the following formats: @@ -324,7 +324,7 @@ public static Policy addMemberToCryptoKeyPolicy( * user:$userEmail * serviceAccount:$serviceAccountEmail * - * See https://g.co/cloud/kms/docs/reference/rest/v1beta1/Policy#binding + * See https://g.co/cloud/kms/docs/reference/rest/v1/Policy#binding * for more details. * * @param role Must be in one of the following formats: