Skip to content

Commit

Permalink
Updates Cloud-KMS sample code to use V1 libraries. (#566)
Browse files Browse the repository at this point in the history
* Updates KMS sample code to use V1 libraries.

* Updates KMS sample code to use V1 libraries.
  • Loading branch information
philcoakley authored and lesv committed Mar 16, 2017
1 parent c27959d commit 2375491
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion kms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudkms</artifactId>
<version>v1beta1-rev412-1.22.0</version>
<version>v1-rev1-1.22.0</version>
<exclusions>
<exclusion> <!-- exclude an old version of Guava -->
<groupId>com.google.guava</groupId>
Expand Down
14 changes: 7 additions & 7 deletions kms/src/main/java/com/example/CryptFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <a
* href="https://g.co/cloud/kms/docs/reference/rest/v1beta1/projects.locations.keyRings.cryptoKeys/updatePrimaryVersion">updatePrimaryVersion</a>
* href="https://g.co/cloud/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/updatePrimaryVersion">updatePrimaryVersion</a>
* method.
*/
public static byte[] encrypt(String projectId, String ringId, String keyId, byte[] plaintext)
Expand Down
10 changes: 5 additions & 5 deletions kms/src/main/java/com/example/Quickstart.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -84,4 +84,4 @@ public static void main(String... args) throws Exception {
}
}
}
// [END kms_quickstart]
// [END kms_quickstart]
8 changes: 4 additions & 4 deletions kms/src/main/java/com/example/SnippetCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions kms/src/main/java/com/example/Snippets.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2375491

Please sign in to comment.