From 518f5c848d33a67367c28640a2efe0c5a11d4e96 Mon Sep 17 00:00:00 2001 From: dpebot Date: Tue, 2 Oct 2018 04:10:44 -0700 Subject: [PATCH] Re-generate library using /synth.py --- .circleci/config.yml | 2 - .circleci/npm-install-retry.js | 2 +- .kokoro/common.cfg | 11 + .kokoro/presubmit/node8/samples-test.cfg | 7 + .kokoro/presubmit/node8/system-test.cfg | 7 + .kokoro/samples-test.sh | 7 + .kokoro/system-test.sh | 2 + .kokoro/test.bat | 2 + .kokoro/test.sh | 3 +- codecov.yaml | 4 + .../doc/google/cloud/kms/v1/doc_resources.js | 14 +- src/v1/doc/google/cloud/kms/v1/doc_service.js | 56 +-- src/v1/doc/google/iam/v1/doc_iam_policy.js | 8 +- src/v1/doc/google/iam/v1/doc_policy.js | 8 +- src/v1/doc/google/protobuf/doc_duration.js | 2 +- src/v1/doc/google/protobuf/doc_field_mask.js | 2 +- src/v1/doc/google/protobuf/doc_timestamp.js | 2 +- src/v1/key_management_service_client.js | 406 +++++++++++++----- .../key_management_service_client_config.json | 15 + test/gapic-v1.js | 224 ++++++++++ 20 files changed, 626 insertions(+), 158 deletions(-) create mode 100644 .kokoro/presubmit/node8/samples-test.cfg create mode 100644 .kokoro/presubmit/node8/system-test.cfg create mode 100644 codecov.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index 8af6a4d0..da54155f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,8 +68,6 @@ jobs: environment: NPM_CONFIG_PREFIX: /home/node/.npm-global - run: npm test - - run: node_modules/.bin/codecov - node8: docker: - image: 'node:8' diff --git a/.circleci/npm-install-retry.js b/.circleci/npm-install-retry.js index ae3220d7..3240aa2c 100755 --- a/.circleci/npm-install-retry.js +++ b/.circleci/npm-install-retry.js @@ -6,7 +6,7 @@ let spawn = require('child_process').spawn; //USE: ./index.js [... NPM ARGS] // -let timeout = process.argv[2] || 60000; +let timeout = process.argv[2] || process.env.NPM_INSTALL_TIMEOUT || 60000; let attempts = process.argv[3] || 3; let args = process.argv.slice(4); if (args.length === 0) { diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 0f11d8b5..5c08adc3 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -13,6 +13,17 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. build_file: "nodejs-kms/.kokoro/trampoline.sh" +# Bring in codecov.io master token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "dpebot_codecov_token" + backend_type: FASTCONFIGPUSH + } + } +} + # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" diff --git a/.kokoro/presubmit/node8/samples-test.cfg b/.kokoro/presubmit/node8/samples-test.cfg new file mode 100644 index 00000000..6ff11302 --- /dev/null +++ b/.kokoro/presubmit/node8/samples-test.cfg @@ -0,0 +1,7 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-kms/.kokoro/samples-test.sh" +} diff --git a/.kokoro/presubmit/node8/system-test.cfg b/.kokoro/presubmit/node8/system-test.cfg new file mode 100644 index 00000000..936eb86a --- /dev/null +++ b/.kokoro/presubmit/node8/system-test.cfg @@ -0,0 +1,7 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-kms/.kokoro/system-test.sh" +} diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 76edbbbb..5a81ec01 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -24,6 +24,13 @@ export GCLOUD_PROJECT=long-door-651 cd $(dirname $0)/.. +# Run a pre-test hook, if a pre-samples-test.sh is in the project +if [ -f .kokoro/pre-samples-test.sh ]; then + set +x + . .kokoro/pre-samples-test.sh + set -x +fi + npm install # Install and link samples diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index a954b794..fd8f0b63 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -26,7 +26,9 @@ cd $(dirname $0)/.. # Run a pre-test hook, if a pre-system-test.sh is in the project if [ -f .kokoro/pre-system-test.sh ]; then + set +x . .kokoro/pre-system-test.sh + set -x fi npm install diff --git a/.kokoro/test.bat b/.kokoro/test.bat index a8534ba8..d6047366 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -17,6 +17,8 @@ cd /d %~dp0 cd .. +call npm install -g npm@5 || goto :error + call npm install || goto :error call npm run test || goto :error diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 51f29589..eb25b89b 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -22,4 +22,5 @@ cd $(dirname $0)/.. npm install npm test -node_modules/.bin/codecov + +bash $KOKORO_GFILE_DIR/codecov.sh diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 00000000..5724ea94 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,4 @@ +--- +codecov: + ci: + - source.cloud.google.com diff --git a/src/v1/doc/google/cloud/kms/v1/doc_resources.js b/src/v1/doc/google/cloud/kms/v1/doc_resources.js index a42ab187..823c02d2 100644 --- a/src/v1/doc/google/cloud/kms/v1/doc_resources.js +++ b/src/v1/doc/google/cloud/kms/v1/doc_resources.js @@ -31,7 +31,7 @@ * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.KeyRing definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/resources.proto} */ -var KeyRing = { +const KeyRing = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -115,7 +115,7 @@ var KeyRing = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.CryptoKey definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/resources.proto} */ -var CryptoKey = { +const CryptoKey = { // This is for documentation. Actual contents will be loaded by gRPC. /** @@ -182,7 +182,7 @@ var CryptoKey = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.CryptoKeyVersionTemplate definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/resources.proto} */ -var CryptoKeyVersionTemplate = { +const CryptoKeyVersionTemplate = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -202,7 +202,7 @@ var CryptoKeyVersionTemplate = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.KeyOperationAttestation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/resources.proto} */ -var KeyOperationAttestation = { +const KeyOperationAttestation = { // This is for documentation. Actual contents will be loaded by gRPC. /** @@ -292,7 +292,7 @@ var KeyOperationAttestation = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.CryptoKeyVersion definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/resources.proto} */ -var CryptoKeyVersion = { +const CryptoKeyVersion = { // This is for documentation. Actual contents will be loaded by gRPC. /** @@ -491,7 +491,7 @@ var CryptoKeyVersion = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.PublicKey definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/resources.proto} */ -var PublicKey = { +const PublicKey = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -501,7 +501,7 @@ var PublicKey = { * @enum {number} * @memberof google.cloud.kms.v1 */ -var ProtectionLevel = { +const ProtectionLevel = { /** * Not specified. diff --git a/src/v1/doc/google/cloud/kms/v1/doc_service.js b/src/v1/doc/google/cloud/kms/v1/doc_service.js index 2b0da854..0553c6db 100644 --- a/src/v1/doc/google/cloud/kms/v1/doc_service.js +++ b/src/v1/doc/google/cloud/kms/v1/doc_service.js @@ -36,7 +36,7 @@ * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.ListKeyRingsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var ListKeyRingsRequest = { +const ListKeyRingsRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -66,7 +66,7 @@ var ListKeyRingsRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.ListCryptoKeysRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var ListCryptoKeysRequest = { +const ListCryptoKeysRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -97,7 +97,7 @@ var ListCryptoKeysRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.ListCryptoKeyVersionsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var ListCryptoKeyVersionsRequest = { +const ListCryptoKeyVersionsRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -120,7 +120,7 @@ var ListCryptoKeyVersionsRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.ListKeyRingsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var ListKeyRingsResponse = { +const ListKeyRingsResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -143,7 +143,7 @@ var ListKeyRingsResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.ListCryptoKeysResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var ListCryptoKeysResponse = { +const ListCryptoKeysResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -168,7 +168,7 @@ var ListCryptoKeysResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.ListCryptoKeyVersionsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var ListCryptoKeyVersionsResponse = { +const ListCryptoKeyVersionsResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -182,7 +182,7 @@ var ListCryptoKeyVersionsResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.GetKeyRingRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var GetKeyRingRequest = { +const GetKeyRingRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -196,7 +196,7 @@ var GetKeyRingRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.GetCryptoKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var GetCryptoKeyRequest = { +const GetCryptoKeyRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -210,7 +210,7 @@ var GetCryptoKeyRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.GetCryptoKeyVersionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var GetCryptoKeyVersionRequest = { +const GetCryptoKeyVersionRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -225,7 +225,7 @@ var GetCryptoKeyVersionRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.GetPublicKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var GetPublicKeyRequest = { +const GetPublicKeyRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -249,7 +249,7 @@ var GetPublicKeyRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.CreateKeyRingRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var CreateKeyRingRequest = { +const CreateKeyRingRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -273,7 +273,7 @@ var CreateKeyRingRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.CreateCryptoKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var CreateCryptoKeyRequest = { +const CreateCryptoKeyRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -293,7 +293,7 @@ var CreateCryptoKeyRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.CreateCryptoKeyVersionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var CreateCryptoKeyVersionRequest = { +const CreateCryptoKeyVersionRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -314,7 +314,7 @@ var CreateCryptoKeyVersionRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.UpdateCryptoKeyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var UpdateCryptoKeyRequest = { +const UpdateCryptoKeyRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -335,7 +335,7 @@ var UpdateCryptoKeyRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.UpdateCryptoKeyVersionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var UpdateCryptoKeyVersionRequest = { +const UpdateCryptoKeyVersionRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -374,7 +374,7 @@ var UpdateCryptoKeyVersionRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.EncryptRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var EncryptRequest = { +const EncryptRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -397,7 +397,7 @@ var EncryptRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.DecryptRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var DecryptRequest = { +const DecryptRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -418,7 +418,7 @@ var DecryptRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.AsymmetricSignRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var AsymmetricSignRequest = { +const AsymmetricSignRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -437,7 +437,7 @@ var AsymmetricSignRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.AsymmetricDecryptRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var AsymmetricDecryptRequest = { +const AsymmetricDecryptRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -451,7 +451,7 @@ var AsymmetricDecryptRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.DecryptResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var DecryptResponse = { +const DecryptResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -468,7 +468,7 @@ var DecryptResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.EncryptResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var EncryptResponse = { +const EncryptResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -482,7 +482,7 @@ var EncryptResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.AsymmetricSignResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var AsymmetricSignResponse = { +const AsymmetricSignResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -496,7 +496,7 @@ var AsymmetricSignResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.AsymmetricDecryptResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var AsymmetricDecryptResponse = { +const AsymmetricDecryptResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -513,7 +513,7 @@ var AsymmetricDecryptResponse = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var UpdateCryptoKeyPrimaryVersionRequest = { +const UpdateCryptoKeyPrimaryVersionRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -527,7 +527,7 @@ var UpdateCryptoKeyPrimaryVersionRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.DestroyCryptoKeyVersionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var DestroyCryptoKeyVersionRequest = { +const DestroyCryptoKeyVersionRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -541,7 +541,7 @@ var DestroyCryptoKeyVersionRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.RestoreCryptoKeyVersionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var RestoreCryptoKeyVersionRequest = { +const RestoreCryptoKeyVersionRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -561,7 +561,7 @@ var RestoreCryptoKeyVersionRequest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.Digest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var Digest = { +const Digest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -577,6 +577,6 @@ var Digest = { * @memberof google.cloud.kms.v1 * @see [google.cloud.kms.v1.LocationMetadata definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto} */ -var LocationMetadata = { +const LocationMetadata = { // This is for documentation. Actual contents will be loaded by gRPC. }; \ No newline at end of file diff --git a/src/v1/doc/google/iam/v1/doc_iam_policy.js b/src/v1/doc/google/iam/v1/doc_iam_policy.js index 52a719ae..e952d5d1 100644 --- a/src/v1/doc/google/iam/v1/doc_iam_policy.js +++ b/src/v1/doc/google/iam/v1/doc_iam_policy.js @@ -35,7 +35,7 @@ * @memberof google.iam.v1 * @see [google.iam.v1.SetIamPolicyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/iam_policy.proto} */ -var SetIamPolicyRequest = { +const SetIamPolicyRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -51,7 +51,7 @@ var SetIamPolicyRequest = { * @memberof google.iam.v1 * @see [google.iam.v1.GetIamPolicyRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/iam_policy.proto} */ -var GetIamPolicyRequest = { +const GetIamPolicyRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -73,7 +73,7 @@ var GetIamPolicyRequest = { * @memberof google.iam.v1 * @see [google.iam.v1.TestIamPermissionsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/iam_policy.proto} */ -var TestIamPermissionsRequest = { +const TestIamPermissionsRequest = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -88,6 +88,6 @@ var TestIamPermissionsRequest = { * @memberof google.iam.v1 * @see [google.iam.v1.TestIamPermissionsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/iam_policy.proto} */ -var TestIamPermissionsResponse = { +const TestIamPermissionsResponse = { // This is for documentation. Actual contents will be loaded by gRPC. }; \ No newline at end of file diff --git a/src/v1/doc/google/iam/v1/doc_policy.js b/src/v1/doc/google/iam/v1/doc_policy.js index 0163cf59..59fca188 100644 --- a/src/v1/doc/google/iam/v1/doc_policy.js +++ b/src/v1/doc/google/iam/v1/doc_policy.js @@ -74,7 +74,7 @@ * @memberof google.iam.v1 * @see [google.iam.v1.Policy definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/policy.proto} */ -var Policy = { +const Policy = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -113,7 +113,7 @@ var Policy = { * @memberof google.iam.v1 * @see [google.iam.v1.Binding definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/policy.proto} */ -var Binding = { +const Binding = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -129,7 +129,7 @@ var Binding = { * @memberof google.iam.v1 * @see [google.iam.v1.PolicyDelta definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/policy.proto} */ -var PolicyDelta = { +const PolicyDelta = { // This is for documentation. Actual contents will be loaded by gRPC. }; @@ -157,6 +157,6 @@ var PolicyDelta = { * @memberof google.iam.v1 * @see [google.iam.v1.BindingDelta definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/iam/v1/policy.proto} */ -var BindingDelta = { +const BindingDelta = { // This is for documentation. Actual contents will be loaded by gRPC. }; \ No newline at end of file diff --git a/src/v1/doc/google/protobuf/doc_duration.js b/src/v1/doc/google/protobuf/doc_duration.js index 3ea5c376..c03ce2fb 100644 --- a/src/v1/doc/google/protobuf/doc_duration.js +++ b/src/v1/doc/google/protobuf/doc_duration.js @@ -92,6 +92,6 @@ * @memberof google.protobuf * @see [google.protobuf.Duration definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/duration.proto} */ -var Duration = { +const Duration = { // This is for documentation. Actual contents will be loaded by gRPC. }; \ No newline at end of file diff --git a/src/v1/doc/google/protobuf/doc_field_mask.js b/src/v1/doc/google/protobuf/doc_field_mask.js index d700752b..0cb35328 100644 --- a/src/v1/doc/google/protobuf/doc_field_mask.js +++ b/src/v1/doc/google/protobuf/doc_field_mask.js @@ -231,6 +231,6 @@ * @memberof google.protobuf * @see [google.protobuf.FieldMask definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/field_mask.proto} */ -var FieldMask = { +const FieldMask = { // This is for documentation. Actual contents will be loaded by gRPC. }; \ No newline at end of file diff --git a/src/v1/doc/google/protobuf/doc_timestamp.js b/src/v1/doc/google/protobuf/doc_timestamp.js index 51d8f40f..1ebe2e6e 100644 --- a/src/v1/doc/google/protobuf/doc_timestamp.js +++ b/src/v1/doc/google/protobuf/doc_timestamp.js @@ -110,6 +110,6 @@ * @memberof google.protobuf * @see [google.protobuf.Timestamp definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto} */ -var Timestamp = { +const Timestamp = { // This is for documentation. Actual contents will be loaded by gRPC. }; \ No newline at end of file diff --git a/src/v1/key_management_service_client.js b/src/v1/key_management_service_client.js index d549572b..ace8df97 100644 --- a/src/v1/key_management_service_client.js +++ b/src/v1/key_management_service_client.js @@ -191,6 +191,9 @@ class KeyManagementServiceClient { 'updateCryptoKeyPrimaryVersion', 'destroyCryptoKeyVersion', 'restoreCryptoKeyVersion', + 'getPublicKey', + 'asymmetricDecrypt', + 'asymmetricSign', ]; for (const methodName of keyManagementServiceStubMethods) { this._innerApiCalls[methodName] = gax.createApiCall( @@ -311,16 +314,16 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * * // Iterate over all elements. - * var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); * * client.listKeyRings({parent: formattedParent}) * .then(responses => { - * var resources = responses[0]; + * const resources = responses[0]; * for (let i = 0; i < resources.length; i += 1) { * // doThingsWith(resources[i]) * } @@ -330,17 +333,17 @@ class KeyManagementServiceClient { * }); * * // Or obtain the paged response. - * var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); * * - * var options = {autoPaginate: false}; - * var callback = responses => { + * const options = {autoPaginate: false}; + * const callback = responses => { * // The actual resources in a response. - * var resources = responses[0]; + * const resources = responses[0]; * // The next request if the response shows that there are more responses. - * var nextRequest = responses[1]; + * const nextRequest = responses[1]; * // The actual response object, if necessary. - * // var rawResponse = responses[2]; + * // const rawResponse = responses[2]; * for (let i = 0; i < resources.length; i += 1) { * // doThingsWith(resources[i]); * } @@ -406,11 +409,11 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); * client.listKeyRingsStream({parent: formattedParent}) * .on('data', element => { * // doThingsWith(element) @@ -473,16 +476,16 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * * // Iterate over all elements. - * var formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); * * client.listCryptoKeys({parent: formattedParent}) * .then(responses => { - * var resources = responses[0]; + * const resources = responses[0]; * for (let i = 0; i < resources.length; i += 1) { * // doThingsWith(resources[i]) * } @@ -492,17 +495,17 @@ class KeyManagementServiceClient { * }); * * // Or obtain the paged response. - * var formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); * * - * var options = {autoPaginate: false}; - * var callback = responses => { + * const options = {autoPaginate: false}; + * const callback = responses => { * // The actual resources in a response. - * var resources = responses[0]; + * const resources = responses[0]; * // The next request if the response shows that there are more responses. - * var nextRequest = responses[1]; + * const nextRequest = responses[1]; * // The actual response object, if necessary. - * // var rawResponse = responses[2]; + * // const rawResponse = responses[2]; * for (let i = 0; i < resources.length; i += 1) { * // doThingsWith(resources[i]); * } @@ -572,11 +575,11 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); * client.listCryptoKeysStream({parent: formattedParent}) * .on('data', element => { * // doThingsWith(element) @@ -639,16 +642,16 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * * // Iterate over all elements. - * var formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); * * client.listCryptoKeyVersions({parent: formattedParent}) * .then(responses => { - * var resources = responses[0]; + * const resources = responses[0]; * for (let i = 0; i < resources.length; i += 1) { * // doThingsWith(resources[i]) * } @@ -658,17 +661,17 @@ class KeyManagementServiceClient { * }); * * // Or obtain the paged response. - * var formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); * * - * var options = {autoPaginate: false}; - * var callback = responses => { + * const options = {autoPaginate: false}; + * const callback = responses => { * // The actual resources in a response. - * var resources = responses[0]; + * const resources = responses[0]; * // The next request if the response shows that there are more responses. - * var nextRequest = responses[1]; + * const nextRequest = responses[1]; * // The actual response object, if necessary. - * // var rawResponse = responses[2]; + * // const rawResponse = responses[2]; * for (let i = 0; i < resources.length; i += 1) { * // doThingsWith(resources[i]); * } @@ -742,11 +745,11 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); * client.listCryptoKeyVersionsStream({parent: formattedParent}) * .on('data', element => { * // doThingsWith(element) @@ -786,14 +789,14 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const formattedName = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); * client.getKeyRing({name: formattedName}) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -840,14 +843,14 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const formattedName = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); * client.getCryptoKey({name: formattedName}) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -893,14 +896,14 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); + * const formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); * client.getCryptoKeyVersion({name: formattedName}) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -954,21 +957,21 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - * var keyRingId = ''; - * var keyRing = {}; - * var request = { + * const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + * const keyRingId = ''; + * const keyRing = {}; + * const request = { * parent: formattedParent, * keyRingId: keyRingId, * keyRing: keyRing, * }; * client.createKeyRing(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1026,34 +1029,34 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); - * var cryptoKeyId = 'my-app-key'; - * var purpose = 'ENCRYPT_DECRYPT'; - * var seconds = 2147483647; - * var nextRotationTime = { + * const formattedParent = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const cryptoKeyId = 'my-app-key'; + * const purpose = 'ENCRYPT_DECRYPT'; + * const seconds = 2147483647; + * const nextRotationTime = { * seconds: seconds, * }; - * var seconds2 = 604800; - * var rotationPeriod = { + * const seconds2 = 604800; + * const rotationPeriod = { * seconds: seconds2, * }; - * var cryptoKey = { + * const cryptoKey = { * purpose: purpose, * nextRotationTime: nextRotationTime, * rotationPeriod: rotationPeriod, * }; - * var request = { + * const request = { * parent: formattedParent, * cryptoKeyId: cryptoKeyId, * cryptoKey: cryptoKey, * }; * client.createCryptoKey(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1108,19 +1111,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); - * var cryptoKeyVersion = {}; - * var request = { + * const formattedParent = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const cryptoKeyVersion = {}; + * const request = { * parent: formattedParent, * cryptoKeyVersion: cryptoKeyVersion, * }; * client.createCryptoKeyVersion(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1176,19 +1179,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var cryptoKey = {}; - * var updateMask = {}; - * var request = { + * const cryptoKey = {}; + * const updateMask = {}; + * const request = { * cryptoKey: cryptoKey, * updateMask: updateMask, * }; * client.updateCryptoKey(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1246,19 +1249,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var cryptoKeyVersion = {}; - * var updateMask = {}; - * var request = { + * const cryptoKeyVersion = {}; + * const updateMask = {}; + * const request = { * cryptoKeyVersion: cryptoKeyVersion, * updateMask: updateMask, * }; * client.updateCryptoKeyVersion(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1333,19 +1336,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyPathPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY_PATH]'); - * var plaintext = ''; - * var request = { + * const formattedName = client.cryptoKeyPathPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY_PATH]'); + * const plaintext = ''; + * const request = { * name: formattedName, * plaintext: plaintext, * }; * client.encrypt(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1399,19 +1402,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); - * var ciphertext = ''; - * var request = { + * const formattedName = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const ciphertext = ''; + * const request = { * name: formattedName, * ciphertext: ciphertext, * }; * client.decrypt(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1461,19 +1464,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); - * var cryptoKeyVersionId = ''; - * var request = { + * const formattedName = client.cryptoKeyPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]'); + * const cryptoKeyVersionId = ''; + * const request = { * name: formattedName, * cryptoKeyVersionId: cryptoKeyVersionId, * }; * client.updateCryptoKeyPrimaryVersion(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1534,14 +1537,14 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); + * const formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); * client.destroyCryptoKeyVersion({name: formattedName}) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1597,14 +1600,14 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); + * const formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); * client.restoreCryptoKeyVersion({name: formattedName}) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1632,6 +1635,193 @@ class KeyManagementServiceClient { ); } + /** + * Returns the public key for the given CryptoKeyVersion. The + * CryptoKey.purpose must be + * ASYMMETRIC_SIGN or + * ASYMMETRIC_DECRYPT. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The name of the CryptoKeyVersion public key to + * get. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [PublicKey]{@link google.cloud.kms.v1.PublicKey}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PublicKey]{@link google.cloud.kms.v1.PublicKey}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const kms = require('@google-cloud/kms'); + * + * const client = new kms.v1.KeyManagementServiceClient({ + * // optional auth parameters. + * }); + * + * const formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); + * client.getPublicKey({name: formattedName}) + * .then(responses => { + * const response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + getPublicKey(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name, + }); + + return this._innerApiCalls.getPublicKey(request, options, callback); + } + + /** + * Decrypts data that was encrypted with a public key retrieved from + * GetPublicKey corresponding to a CryptoKeyVersion with + * CryptoKey.purpose ASYMMETRIC_DECRYPT. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the CryptoKeyVersion to use for + * decryption. + * @param {string} request.ciphertext + * Required. The data encrypted with the named CryptoKeyVersion's public + * key using OAEP. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [AsymmetricDecryptResponse]{@link google.cloud.kms.v1.AsymmetricDecryptResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AsymmetricDecryptResponse]{@link google.cloud.kms.v1.AsymmetricDecryptResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const kms = require('@google-cloud/kms'); + * + * const client = new kms.v1.KeyManagementServiceClient({ + * // optional auth parameters. + * }); + * + * const formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); + * const ciphertext = ''; + * const request = { + * name: formattedName, + * ciphertext: ciphertext, + * }; + * client.asymmetricDecrypt(request) + * .then(responses => { + * const response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + asymmetricDecrypt(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name, + }); + + return this._innerApiCalls.asymmetricDecrypt(request, options, callback); + } + + /** + * Signs data using a CryptoKeyVersion with CryptoKey.purpose + * ASYMMETRIC_SIGN, producing a signature that can be verified with the public + * key retrieved from GetPublicKey. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the CryptoKeyVersion to use for signing. + * @param {Object} request.digest + * Required. The digest of the data to sign. The digest must be produced with + * the same digest algorithm as specified by the key version's + * algorithm. + * + * This object should have the same structure as [Digest]{@link google.cloud.kms.v1.Digest} + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing [AsymmetricSignResponse]{@link google.cloud.kms.v1.AsymmetricSignResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AsymmetricSignResponse]{@link google.cloud.kms.v1.AsymmetricSignResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const kms = require('@google-cloud/kms'); + * + * const client = new kms.v1.KeyManagementServiceClient({ + * // optional auth parameters. + * }); + * + * const formattedName = client.cryptoKeyVersionPath('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]'); + * const digest = {}; + * const request = { + * name: formattedName, + * digest: digest, + * }; + * client.asymmetricSign(request) + * .then(responses => { + * const response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + asymmetricSign(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name, + }); + + return this._innerApiCalls.asymmetricSign(request, options, callback); + } + /** * Sets the access control policy on the specified resource. Replaces any * existing policy. @@ -1664,19 +1854,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedResource = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); - * var policy = {}; - * var request = { + * const formattedResource = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const policy = {}; + * const request = { * resource: formattedResource, * policy: policy, * }; * client.setIamPolicy(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1726,14 +1916,14 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedResource = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const formattedResource = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); * client.getIamPolicy({resource: formattedResource}) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { @@ -1788,19 +1978,19 @@ class KeyManagementServiceClient { * * const kms = require('@google-cloud/kms'); * - * var client = new kms.v1.KeyManagementServiceClient({ + * const client = new kms.v1.KeyManagementServiceClient({ * // optional auth parameters. * }); * - * var formattedResource = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); - * var permissions = []; - * var request = { + * const formattedResource = client.keyRingPath('[PROJECT]', '[LOCATION]', '[KEY_RING]'); + * const permissions = []; + * const request = { * resource: formattedResource, * permissions: permissions, * }; * client.testIamPermissions(request) * .then(responses => { - * var response = responses[0]; + * const response = responses[0]; * // doThingsWith(response) * }) * .catch(err => { diff --git a/src/v1/key_management_service_client_config.json b/src/v1/key_management_service_client_config.json index bd6e7686..c290d313 100644 --- a/src/v1/key_management_service_client_config.json +++ b/src/v1/key_management_service_client_config.json @@ -100,6 +100,21 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "GetPublicKey": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AsymmetricDecrypt": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AsymmetricSign": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "SetIamPolicy": { "timeout_millis": 60000, "retry_codes_name": "non_idempotent", diff --git a/test/gapic-v1.js b/test/gapic-v1.js index fdaeac1a..45c80fc3 100644 --- a/test/gapic-v1.js +++ b/test/gapic-v1.js @@ -1198,6 +1198,230 @@ describe('KeyManagementServiceClient', () => { }); }); + describe('getPublicKey', () => { + it('invokes getPublicKey without error', done => { + const client = new kmsModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const formattedName = client.cryptoKeyVersionPath( + '[PROJECT]', + '[LOCATION]', + '[KEY_RING]', + '[CRYPTO_KEY]', + '[CRYPTO_KEY_VERSION]' + ); + const request = { + name: formattedName, + }; + + // Mock response + const pem = 'pem110872'; + const expectedResponse = { + pem: pem, + }; + + // Mock Grpc layer + client._innerApiCalls.getPublicKey = mockSimpleGrpcMethod( + request, + expectedResponse + ); + + client.getPublicKey(request, (err, response) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes getPublicKey with error', done => { + const client = new kmsModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const formattedName = client.cryptoKeyVersionPath( + '[PROJECT]', + '[LOCATION]', + '[KEY_RING]', + '[CRYPTO_KEY]', + '[CRYPTO_KEY_VERSION]' + ); + const request = { + name: formattedName, + }; + + // Mock Grpc layer + client._innerApiCalls.getPublicKey = mockSimpleGrpcMethod( + request, + null, + error + ); + + client.getPublicKey(request, (err, response) => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + + describe('asymmetricDecrypt', () => { + it('invokes asymmetricDecrypt without error', done => { + const client = new kmsModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const formattedName = client.cryptoKeyVersionPath( + '[PROJECT]', + '[LOCATION]', + '[KEY_RING]', + '[CRYPTO_KEY]', + '[CRYPTO_KEY_VERSION]' + ); + const ciphertext = '-72'; + const request = { + name: formattedName, + ciphertext: ciphertext, + }; + + // Mock response + const plaintext = '-9'; + const expectedResponse = { + plaintext: plaintext, + }; + + // Mock Grpc layer + client._innerApiCalls.asymmetricDecrypt = mockSimpleGrpcMethod( + request, + expectedResponse + ); + + client.asymmetricDecrypt(request, (err, response) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes asymmetricDecrypt with error', done => { + const client = new kmsModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const formattedName = client.cryptoKeyVersionPath( + '[PROJECT]', + '[LOCATION]', + '[KEY_RING]', + '[CRYPTO_KEY]', + '[CRYPTO_KEY_VERSION]' + ); + const ciphertext = '-72'; + const request = { + name: formattedName, + ciphertext: ciphertext, + }; + + // Mock Grpc layer + client._innerApiCalls.asymmetricDecrypt = mockSimpleGrpcMethod( + request, + null, + error + ); + + client.asymmetricDecrypt(request, (err, response) => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + + describe('asymmetricSign', () => { + it('invokes asymmetricSign without error', done => { + const client = new kmsModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const formattedName = client.cryptoKeyVersionPath( + '[PROJECT]', + '[LOCATION]', + '[KEY_RING]', + '[CRYPTO_KEY]', + '[CRYPTO_KEY_VERSION]' + ); + const digest = {}; + const request = { + name: formattedName, + digest: digest, + }; + + // Mock response + const signature = '106'; + const expectedResponse = { + signature: signature, + }; + + // Mock Grpc layer + client._innerApiCalls.asymmetricSign = mockSimpleGrpcMethod( + request, + expectedResponse + ); + + client.asymmetricSign(request, (err, response) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes asymmetricSign with error', done => { + const client = new kmsModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + + // Mock request + const formattedName = client.cryptoKeyVersionPath( + '[PROJECT]', + '[LOCATION]', + '[KEY_RING]', + '[CRYPTO_KEY]', + '[CRYPTO_KEY_VERSION]' + ); + const digest = {}; + const request = { + name: formattedName, + digest: digest, + }; + + // Mock Grpc layer + client._innerApiCalls.asymmetricSign = mockSimpleGrpcMethod( + request, + null, + error + ); + + client.asymmetricSign(request, (err, response) => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('setIamPolicy', () => { it('invokes setIamPolicy without error', done => { const client = new kmsModule.v1.KeyManagementServiceClient({