diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.asymmetric_decrypt.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.asymmetric_decrypt.js new file mode 100644 index 00000000000..1e7967553e2 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.asymmetric_decrypt.js @@ -0,0 +1,75 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, ciphertext) { + // [START kms_v1_generated_KeyManagementService_AsymmetricDecrypt_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for + * decryption. + */ + // const name = 'abc123' + /** + * Required. The data encrypted with the named [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s public + * key using OAEP. + */ + // const ciphertext = 'Buffer.from('string')' + /** + * Optional. An optional CRC32C checksum of the [AsymmetricDecryptRequest.ciphertext][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext]. + * If specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [AsymmetricDecryptRequest.ciphertext][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([AsymmetricDecryptRequest.ciphertext][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext]) is equal to + * [AsymmetricDecryptRequest.ciphertext_crc32c][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c], and if so, perform a + * limited number of retries. A persistent mismatch may indicate an issue in + * your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const ciphertextCrc32c = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function asymmetricDecrypt() { + // Construct request + const request = { + name, + ciphertext, + }; + + // Run request + const response = await kmsClient.asymmetricDecrypt(request); + console.log(response); + } + + asymmetricDecrypt(); + // [END kms_v1_generated_KeyManagementService_AsymmetricDecrypt_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.asymmetric_sign.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.asymmetric_sign.js new file mode 100644 index 00000000000..30088cdc12a --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.asymmetric_sign.js @@ -0,0 +1,75 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, digest) { + // [START kms_v1_generated_KeyManagementService_AsymmetricSign_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing. + */ + // const name = 'abc123' + /** + * 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][google.cloud.kms.v1.CryptoKeyVersion.algorithm]. + */ + // const digest = '' + /** + * Optional. An optional CRC32C checksum of the [AsymmetricSignRequest.digest][google.cloud.kms.v1.AsymmetricSignRequest.digest]. If + * specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [AsymmetricSignRequest.digest][google.cloud.kms.v1.AsymmetricSignRequest.digest] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([AsymmetricSignRequest.digest][google.cloud.kms.v1.AsymmetricSignRequest.digest]) is equal to + * [AsymmetricSignRequest.digest_crc32c][google.cloud.kms.v1.AsymmetricSignRequest.digest_crc32c], and if so, perform a limited + * number of retries. A persistent mismatch may indicate an issue in your + * computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const digestCrc32c = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function asymmetricSign() { + // Construct request + const request = { + name, + digest, + }; + + // Run request + const response = await kmsClient.asymmetricSign(request); + console.log(response); + } + + asymmetricSign(); + // [END kms_v1_generated_KeyManagementService_AsymmetricSign_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_crypto_key.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_crypto_key.js new file mode 100644 index 00000000000..31cf4591c75 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_crypto_key.js @@ -0,0 +1,72 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent, cryptoKeyId, cryptoKey) { + // [START kms_v1_generated_KeyManagementService_CreateCryptoKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.KeyRing.name] of the KeyRing associated with the + * [CryptoKeys][google.cloud.kms.v1.CryptoKey]. + */ + // const parent = 'abc123' + /** + * Required. It must be unique within a KeyRing and match the regular + * expression `[a-zA-Z0-9_-]{1,63}` + */ + // const cryptoKeyId = 'abc123' + /** + * Required. A [CryptoKey][google.cloud.kms.v1.CryptoKey] with initial field values. + */ + // const cryptoKey = '' + /** + * If set to true, the request will create a [CryptoKey][google.cloud.kms.v1.CryptoKey] without any + * [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion]. You must manually call + * [CreateCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.CreateCryptoKeyVersion] or + * [ImportCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.ImportCryptoKeyVersion] + * before you can use this [CryptoKey][google.cloud.kms.v1.CryptoKey]. + */ + // const skipInitialVersionCreation = true + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function createCryptoKey() { + // Construct request + const request = { + parent, + cryptoKeyId, + cryptoKey, + }; + + // Run request + const response = await kmsClient.createCryptoKey(request); + console.log(response); + } + + createCryptoKey(); + // [END kms_v1_generated_KeyManagementService_CreateCryptoKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_crypto_key_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_crypto_key_version.js new file mode 100644 index 00000000000..932459c9e31 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_crypto_key_version.js @@ -0,0 +1,58 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent, cryptoKeyVersion) { + // [START kms_v1_generated_KeyManagementService_CreateCryptoKeyVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] associated with + * the [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion]. + */ + // const parent = 'abc123' + /** + * Required. A [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with initial field values. + */ + // const cryptoKeyVersion = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function createCryptoKeyVersion() { + // Construct request + const request = { + parent, + cryptoKeyVersion, + }; + + // Run request + const response = await kmsClient.createCryptoKeyVersion(request); + console.log(response); + } + + createCryptoKeyVersion(); + // [END kms_v1_generated_KeyManagementService_CreateCryptoKeyVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_import_job.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_import_job.js new file mode 100644 index 00000000000..d9c5ccc04a9 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_import_job.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent, importJobId, importJob) { + // [START kms_v1_generated_KeyManagementService_CreateImportJob_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.KeyRing.name] of the [KeyRing][google.cloud.kms.v1.KeyRing] associated with the + * [ImportJobs][google.cloud.kms.v1.ImportJob]. + */ + // const parent = 'abc123' + /** + * Required. It must be unique within a KeyRing and match the regular + * expression `[a-zA-Z0-9_-]{1,63}` + */ + // const importJobId = 'abc123' + /** + * Required. An [ImportJob][google.cloud.kms.v1.ImportJob] with initial field values. + */ + // const importJob = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function createImportJob() { + // Construct request + const request = { + parent, + importJobId, + importJob, + }; + + // Run request + const response = await kmsClient.createImportJob(request); + console.log(response); + } + + createImportJob(); + // [END kms_v1_generated_KeyManagementService_CreateImportJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_key_ring.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_key_ring.js new file mode 100644 index 00000000000..789db69aad7 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.create_key_ring.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent, keyRingId, keyRing) { + // [START kms_v1_generated_KeyManagementService_CreateKeyRing_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the location associated with the + * [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/* /locations/*`. + */ + // const parent = 'abc123' + /** + * Required. It must be unique within a location and match the regular + * expression `[a-zA-Z0-9_-]{1,63}` + */ + // const keyRingId = 'abc123' + /** + * Required. A [KeyRing][google.cloud.kms.v1.KeyRing] with initial field values. + */ + // const keyRing = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function createKeyRing() { + // Construct request + const request = { + parent, + keyRingId, + keyRing, + }; + + // Run request + const response = await kmsClient.createKeyRing(request); + console.log(response); + } + + createKeyRing(); + // [END kms_v1_generated_KeyManagementService_CreateKeyRing_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.decrypt.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.decrypt.js new file mode 100644 index 00000000000..7ae0e409812 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.decrypt.js @@ -0,0 +1,97 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, ciphertext) { + // [START kms_v1_generated_KeyManagementService_Decrypt_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to use for decryption. + * The server will choose the appropriate version. + */ + // const name = 'abc123' + /** + * Required. The encrypted data originally returned in + * [EncryptResponse.ciphertext][google.cloud.kms.v1.EncryptResponse.ciphertext]. + */ + // const ciphertext = 'Buffer.from('string')' + /** + * Optional. Optional data that must match the data originally supplied in + * [EncryptRequest.additional_authenticated_data][google.cloud.kms.v1.EncryptRequest.additional_authenticated_data]. + */ + // const additionalAuthenticatedData = 'Buffer.from('string')' + /** + * Optional. An optional CRC32C checksum of the [DecryptRequest.ciphertext][google.cloud.kms.v1.DecryptRequest.ciphertext]. If + * specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [DecryptRequest.ciphertext][google.cloud.kms.v1.DecryptRequest.ciphertext] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([DecryptRequest.ciphertext][google.cloud.kms.v1.DecryptRequest.ciphertext]) is equal to + * [DecryptRequest.ciphertext_crc32c][google.cloud.kms.v1.DecryptRequest.ciphertext_crc32c], and if so, perform a limited number + * of retries. A persistent mismatch may indicate an issue in your computation + * of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const ciphertextCrc32c = '' + /** + * Optional. An optional CRC32C checksum of the + * [DecryptRequest.additional_authenticated_data][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data]. If specified, + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the received + * [DecryptRequest.additional_authenticated_data][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([DecryptRequest.additional_authenticated_data][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data]) is equal to + * [DecryptRequest.additional_authenticated_data_crc32c][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data_crc32c], and if so, perform + * a limited number of retries. A persistent mismatch may indicate an issue in + * your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const additionalAuthenticatedDataCrc32c = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function decrypt() { + // Construct request + const request = { + name, + ciphertext, + }; + + // Run request + const response = await kmsClient.decrypt(request); + console.log(response); + } + + decrypt(); + // [END kms_v1_generated_KeyManagementService_Decrypt_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.destroy_crypto_key_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.destroy_crypto_key_version.js new file mode 100644 index 00000000000..2614ccf50aa --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.destroy_crypto_key_version.js @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_DestroyCryptoKeyVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to destroy. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function destroyCryptoKeyVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.destroyCryptoKeyVersion(request); + console.log(response); + } + + destroyCryptoKeyVersion(); + // [END kms_v1_generated_KeyManagementService_DestroyCryptoKeyVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.encrypt.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.encrypt.js new file mode 100644 index 00000000000..c03ee3028b3 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.encrypt.js @@ -0,0 +1,110 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, plaintext) { + // [START kms_v1_generated_KeyManagementService_Encrypt_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] + * to use for encryption. + * If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its + * [primary version][google.cloud.kms.v1.CryptoKey.primary]. + */ + // const name = 'abc123' + /** + * Required. The data to encrypt. Must be no larger than 64KiB. + * The maximum size depends on the key version's + * [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For + * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no larger + * than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the + * plaintext and additional_authenticated_data fields must be no larger than + * 8KiB. + */ + // const plaintext = 'Buffer.from('string')' + /** + * Optional. Optional data that, if specified, must also be provided during decryption + * through [DecryptRequest.additional_authenticated_data][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data]. + * The maximum size depends on the key version's + * [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For + * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the AAD must be no larger than + * 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the + * plaintext and additional_authenticated_data fields must be no larger than + * 8KiB. + */ + // const additionalAuthenticatedData = 'Buffer.from('string')' + /** + * Optional. An optional CRC32C checksum of the [EncryptRequest.plaintext][google.cloud.kms.v1.EncryptRequest.plaintext]. If + * specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [EncryptRequest.plaintext][google.cloud.kms.v1.EncryptRequest.plaintext] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([EncryptRequest.plaintext][google.cloud.kms.v1.EncryptRequest.plaintext]) is equal to + * [EncryptRequest.plaintext_crc32c][google.cloud.kms.v1.EncryptRequest.plaintext_crc32c], and if so, perform a limited number of + * retries. A persistent mismatch may indicate an issue in your computation of + * the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const plaintextCrc32c = '' + /** + * Optional. An optional CRC32C checksum of the + * [EncryptRequest.additional_authenticated_data][google.cloud.kms.v1.EncryptRequest.additional_authenticated_data]. If specified, + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the received + * [EncryptRequest.additional_authenticated_data][google.cloud.kms.v1.EncryptRequest.additional_authenticated_data] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([EncryptRequest.additional_authenticated_data][google.cloud.kms.v1.EncryptRequest.additional_authenticated_data]) is equal to + * [EncryptRequest.additional_authenticated_data_crc32c][google.cloud.kms.v1.EncryptRequest.additional_authenticated_data_crc32c], and if so, perform + * a limited number of retries. A persistent mismatch may indicate an issue in + * your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const additionalAuthenticatedDataCrc32c = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function encrypt() { + // Construct request + const request = { + name, + plaintext, + }; + + // Run request + const response = await kmsClient.encrypt(request); + console.log(response); + } + + encrypt(); + // [END kms_v1_generated_KeyManagementService_Encrypt_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.generate_random_bytes.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.generate_random_bytes.js new file mode 100644 index 00000000000..898a9a03814 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.generate_random_bytes.js @@ -0,0 +1,61 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main() { + // [START kms_v1_generated_KeyManagementService_GenerateRandomBytes_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The project-specific location in which to generate random bytes. + * For example, "projects/my-project/locations/us-central1". + */ + // const location = 'abc123' + /** + * The length in bytes of the amount of randomness to retrieve. Minimum 8 + * bytes, maximum 1024 bytes. + */ + // const lengthBytes = 1234 + /** + * The [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] to use when generating the random data. Defaults to + * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE]. + */ + // const protectionLevel = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function generateRandomBytes() { + // Construct request + const request = {}; + + // Run request + const response = await kmsClient.generateRandomBytes(request); + console.log(response); + } + + generateRandomBytes(); + // [END kms_v1_generated_KeyManagementService_GenerateRandomBytes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_crypto_key.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_crypto_key.js new file mode 100644 index 00000000000..92664b7c5aa --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_crypto_key.js @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_GetCryptoKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to get. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function getCryptoKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.getCryptoKey(request); + console.log(response); + } + + getCryptoKey(); + // [END kms_v1_generated_KeyManagementService_GetCryptoKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_crypto_key_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_crypto_key_version.js new file mode 100644 index 00000000000..cf25bc470f3 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_crypto_key_version.js @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_GetCryptoKeyVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to get. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function getCryptoKeyVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.getCryptoKeyVersion(request); + console.log(response); + } + + getCryptoKeyVersion(); + // [END kms_v1_generated_KeyManagementService_GetCryptoKeyVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_import_job.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_import_job.js new file mode 100644 index 00000000000..e8826b7e84a --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_import_job.js @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_GetImportJob_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.ImportJob.name] of the [ImportJob][google.cloud.kms.v1.ImportJob] to get. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function getImportJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.getImportJob(request); + console.log(response); + } + + getImportJob(); + // [END kms_v1_generated_KeyManagementService_GetImportJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_key_ring.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_key_ring.js new file mode 100644 index 00000000000..4fba8747efe --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_key_ring.js @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_GetKeyRing_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.KeyRing.name] of the [KeyRing][google.cloud.kms.v1.KeyRing] to get. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function getKeyRing() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.getKeyRing(request); + console.log(response); + } + + getKeyRing(); + // [END kms_v1_generated_KeyManagementService_GetKeyRing_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_public_key.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_public_key.js new file mode 100644 index 00000000000..0bbaaf48e07 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.get_public_key.js @@ -0,0 +1,53 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_GetPublicKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.CryptoKeyVersion.name] of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] public key to + * get. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function getPublicKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.getPublicKey(request); + console.log(response); + } + + getPublicKey(); + // [END kms_v1_generated_KeyManagementService_GetPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.import_crypto_key_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.import_crypto_key_version.js new file mode 100644 index 00000000000..33ec027ccf4 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.import_crypto_key_version.js @@ -0,0 +1,108 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent, algorithm, importJob) { + // [START kms_v1_generated_KeyManagementService_ImportCryptoKeyVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The [name][google.cloud.kms.v1.CryptoKey.name] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to be imported into. + * The create permission is only required on this key when creating a new + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. + */ + // const parent = 'abc123' + /** + * Optional. The optional [name][google.cloud.kms.v1.CryptoKeyVersion.name] of an existing + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to target for an import operation. + * If this field is not present, a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] containing the + * supplied key material is created. + * If this field is present, the supplied key material is imported into + * the existing [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. To import into an existing + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion], the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] must be a child of + * [ImportCryptoKeyVersionRequest.parent][google.cloud.kms.v1.ImportCryptoKeyVersionRequest.parent], have been previously created via + * [ImportCryptoKeyVersion][], and be in + * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED] or + * [IMPORT_FAILED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.IMPORT_FAILED] + * state. The key material and algorithm must match the previous + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] exactly if the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] has ever contained + * key material. + */ + // const cryptoKeyVersion = 'abc123' + /** + * Required. The [algorithm][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm] of + * the key being imported. This does not need to match the + * [version_template][google.cloud.kms.v1.CryptoKey.version_template] of the [CryptoKey][google.cloud.kms.v1.CryptoKey] this + * version imports into. + */ + // const algorithm = '' + /** + * Required. The [name][google.cloud.kms.v1.ImportJob.name] of the [ImportJob][google.cloud.kms.v1.ImportJob] that was used to + * wrap this key material. + */ + // const importJob = 'abc123' + /** + * Wrapped key material produced with + * [RSA_OAEP_3072_SHA1_AES_256][google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA1_AES_256] + * or + * [RSA_OAEP_4096_SHA1_AES_256][google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA1_AES_256]. + * This field contains the concatenation of two wrapped keys: + *
    + *
  1. An ephemeral AES-256 wrapping key wrapped with the + * [public_key][google.cloud.kms.v1.ImportJob.public_key] using RSAES-OAEP with SHA-1, + * MGF1 with SHA-1, and an empty label. + *
  2. + *
  3. The key to be imported, wrapped with the ephemeral AES-256 key + * using AES-KWP (RFC 5649). + *
  4. + *
+ * If importing symmetric key material, it is expected that the unwrapped + * key contains plain bytes. If importing asymmetric key material, it is + * expected that the unwrapped key is in PKCS#8-encoded DER format (the + * PrivateKeyInfo structure from RFC 5208). + * This format is the same as the format produced by PKCS#11 mechanism + * CKM_RSA_AES_KEY_WRAP. + */ + // const rsaAesWrappedKey = 'Buffer.from('string')' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function importCryptoKeyVersion() { + // Construct request + const request = { + parent, + algorithm, + importJob, + }; + + // Run request + const response = await kmsClient.importCryptoKeyVersion(request); + console.log(response); + } + + importCryptoKeyVersion(); + // [END kms_v1_generated_KeyManagementService_ImportCryptoKeyVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_crypto_key_versions.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_crypto_key_versions.js new file mode 100644 index 00000000000..620e91d3dce --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_crypto_key_versions.js @@ -0,0 +1,86 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent) { + // [START kms_v1_generated_KeyManagementService_ListCryptoKeyVersions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to list, in the format + * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. + */ + // const parent = 'abc123' + /** + * Optional. Optional limit on the number of [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion] to + * include in the response. Further [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion] can + * subsequently be obtained by including the + * [ListCryptoKeyVersionsResponse.next_page_token][google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token] in a subsequent request. + * If unspecified, the server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. Optional pagination token, returned earlier via + * [ListCryptoKeyVersionsResponse.next_page_token][google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token]. + */ + // const pageToken = 'abc123' + /** + * The fields to include in the response. + */ + // const view = '' + /** + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const filter = 'abc123' + /** + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const orderBy = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function listCryptoKeyVersions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await kmsClient.listCryptoKeyVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listCryptoKeyVersions(); + // [END kms_v1_generated_KeyManagementService_ListCryptoKeyVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_crypto_keys.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_crypto_keys.js new file mode 100644 index 00000000000..3f8d0fc05f6 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_crypto_keys.js @@ -0,0 +1,85 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent) { + // [START kms_v1_generated_KeyManagementService_ListCryptoKeys_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to list, in the format + * `projects/* /locations/* /keyRings/*`. + */ + // const parent = 'abc123' + /** + * Optional. Optional limit on the number of [CryptoKeys][google.cloud.kms.v1.CryptoKey] to include in the + * response. Further [CryptoKeys][google.cloud.kms.v1.CryptoKey] can subsequently be obtained by + * including the [ListCryptoKeysResponse.next_page_token][google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token] in a subsequent + * request. If unspecified, the server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. Optional pagination token, returned earlier via + * [ListCryptoKeysResponse.next_page_token][google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token]. + */ + // const pageToken = 'abc123' + /** + * The fields of the primary version to include in the response. + */ + // const versionView = '' + /** + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const filter = 'abc123' + /** + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const orderBy = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function listCryptoKeys() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await kmsClient.listCryptoKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listCryptoKeys(); + // [END kms_v1_generated_KeyManagementService_ListCryptoKeys_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_import_jobs.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_import_jobs.js new file mode 100644 index 00000000000..dd29935b8b2 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_import_jobs.js @@ -0,0 +1,81 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent) { + // [START kms_v1_generated_KeyManagementService_ListImportJobs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [KeyRing][google.cloud.kms.v1.KeyRing] to list, in the format + * `projects/* /locations/* /keyRings/*`. + */ + // const parent = 'abc123' + /** + * Optional. Optional limit on the number of [ImportJobs][google.cloud.kms.v1.ImportJob] to include in the + * response. Further [ImportJobs][google.cloud.kms.v1.ImportJob] can subsequently be obtained by + * including the [ListImportJobsResponse.next_page_token][google.cloud.kms.v1.ListImportJobsResponse.next_page_token] in a subsequent + * request. If unspecified, the server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. Optional pagination token, returned earlier via + * [ListImportJobsResponse.next_page_token][google.cloud.kms.v1.ListImportJobsResponse.next_page_token]. + */ + // const pageToken = 'abc123' + /** + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const filter = 'abc123' + /** + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const orderBy = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function listImportJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await kmsClient.listImportJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listImportJobs(); + // [END kms_v1_generated_KeyManagementService_ListImportJobs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_key_rings.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_key_rings.js new file mode 100644 index 00000000000..30a3981ee2c --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.list_key_rings.js @@ -0,0 +1,81 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(parent) { + // [START kms_v1_generated_KeyManagementService_ListKeyRings_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the location associated with the + * [KeyRings][google.cloud.kms.v1.KeyRing], in the format `projects/* /locations/*`. + */ + // const parent = 'abc123' + /** + * Optional. Optional limit on the number of [KeyRings][google.cloud.kms.v1.KeyRing] to include in the + * response. Further [KeyRings][google.cloud.kms.v1.KeyRing] can subsequently be obtained by + * including the [ListKeyRingsResponse.next_page_token][google.cloud.kms.v1.ListKeyRingsResponse.next_page_token] in a subsequent + * request. If unspecified, the server will pick an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. Optional pagination token, returned earlier via + * [ListKeyRingsResponse.next_page_token][google.cloud.kms.v1.ListKeyRingsResponse.next_page_token]. + */ + // const pageToken = 'abc123' + /** + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const filter = 'abc123' + /** + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + */ + // const orderBy = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function listKeyRings() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await kmsClient.listKeyRingsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listKeyRings(); + // [END kms_v1_generated_KeyManagementService_ListKeyRings_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.mac_sign.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.mac_sign.js new file mode 100644 index 00000000000..26c9f9b6761 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.mac_sign.js @@ -0,0 +1,74 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, data) { + // [START kms_v1_generated_KeyManagementService_MacSign_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for signing. + */ + // const name = 'abc123' + /** + * Required. The data to sign. The MAC tag is computed over this data field based on + * the specific algorithm. + */ + // const data = 'Buffer.from('string')' + /** + * Optional. An optional CRC32C checksum of the [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data]. If + * specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data]) is equal to + * [MacSignRequest.data_crc32c][google.cloud.kms.v1.MacSignRequest.data_crc32c], and if so, perform a limited + * number of retries. A persistent mismatch may indicate an issue in your + * computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const dataCrc32c = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function macSign() { + // Construct request + const request = { + name, + data, + }; + + // Run request + const response = await kmsClient.macSign(request); + console.log(response); + } + + macSign(); + // [END kms_v1_generated_KeyManagementService_MacSign_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.mac_verify.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.mac_verify.js new file mode 100644 index 00000000000..0aa19ef1046 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.mac_verify.js @@ -0,0 +1,95 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, data, mac) { + // [START kms_v1_generated_KeyManagementService_MacVerify_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for verification. + */ + // const name = 'abc123' + /** + * Required. The data used previously as a [MacSignRequest.data][google.cloud.kms.v1.MacSignRequest.data] to generate the MAC + * tag. + */ + // const data = 'Buffer.from('string')' + /** + * Optional. An optional CRC32C checksum of the [MacVerifyRequest.data][google.cloud.kms.v1.MacVerifyRequest.data]. If + * specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [MacVerifyRequest.data][google.cloud.kms.v1.MacVerifyRequest.data] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([MacVerifyRequest.data][google.cloud.kms.v1.MacVerifyRequest.data]) is equal to + * [MacVerifyRequest.data_crc32c][google.cloud.kms.v1.MacVerifyRequest.data_crc32c], and if so, perform a limited + * number of retries. A persistent mismatch may indicate an issue in your + * computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const dataCrc32c = '' + /** + * Required. The signature to verify. + */ + // const mac = 'Buffer.from('string')' + /** + * Optional. An optional CRC32C checksum of the [MacVerifyRequest.mac][google.cloud.kms.v1.MacVerifyRequest.mac]. If + * specified, [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will verify the integrity of the + * received [MacVerifyRequest.mac][google.cloud.kms.v1.MacVerifyRequest.mac] using this checksum. + * [KeyManagementService][google.cloud.kms.v1.KeyManagementService] will report an error if the checksum verification + * fails. If you receive a checksum error, your client should verify that + * CRC32C([MacVerifyRequest.tag][]) is equal to + * [MacVerifyRequest.mac_crc32c][google.cloud.kms.v1.MacVerifyRequest.mac_crc32c], and if so, perform a limited + * number of retries. A persistent mismatch may indicate an issue in your + * computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + */ + // const macCrc32c = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function macVerify() { + // Construct request + const request = { + name, + data, + mac, + }; + + // Run request + const response = await kmsClient.macVerify(request); + console.log(response); + } + + macVerify(); + // [END kms_v1_generated_KeyManagementService_MacVerify_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.restore_crypto_key_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.restore_crypto_key_version.js new file mode 100644 index 00000000000..ccb877011c6 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.restore_crypto_key_version.js @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name) { + // [START kms_v1_generated_KeyManagementService_RestoreCryptoKeyVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to restore. + */ + // const name = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function restoreCryptoKeyVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await kmsClient.restoreCryptoKeyVersion(request); + console.log(response); + } + + restoreCryptoKeyVersion(); + // [END kms_v1_generated_KeyManagementService_RestoreCryptoKeyVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key.js new file mode 100644 index 00000000000..10b29223860 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key.js @@ -0,0 +1,57 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(cryptoKey, updateMask) { + // [START kms_v1_generated_KeyManagementService_UpdateCryptoKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. [CryptoKey][google.cloud.kms.v1.CryptoKey] with updated values. + */ + // const cryptoKey = '' + /** + * Required. List of fields to be updated in this request. + */ + // const updateMask = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function updateCryptoKey() { + // Construct request + const request = { + cryptoKey, + updateMask, + }; + + // Run request + const response = await kmsClient.updateCryptoKey(request); + console.log(response); + } + + updateCryptoKey(); + // [END kms_v1_generated_KeyManagementService_UpdateCryptoKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key_primary_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key_primary_version.js new file mode 100644 index 00000000000..6a956c86b65 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key_primary_version.js @@ -0,0 +1,57 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(name, cryptoKeyVersionId) { + // [START kms_v1_generated_KeyManagementService_UpdateCryptoKeyPrimaryVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] to update. + */ + // const name = 'abc123' + /** + * Required. The id of the child [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use as primary. + */ + // const cryptoKeyVersionId = 'abc123' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function updateCryptoKeyPrimaryVersion() { + // Construct request + const request = { + name, + cryptoKeyVersionId, + }; + + // Run request + const response = await kmsClient.updateCryptoKeyPrimaryVersion(request); + console.log(response); + } + + updateCryptoKeyPrimaryVersion(); + // [END kms_v1_generated_KeyManagementService_UpdateCryptoKeyPrimaryVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key_version.js b/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key_version.js new file mode 100644 index 00000000000..3ed95735cc7 --- /dev/null +++ b/packages/google-cloud-kms/samples/generated/v1/key_management_service.update_crypto_key_version.js @@ -0,0 +1,57 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main(cryptoKeyVersion, updateMask) { + // [START kms_v1_generated_KeyManagementService_UpdateCryptoKeyVersion_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with updated values. + */ + // const cryptoKeyVersion = '' + /** + * Required. List of fields to be updated in this request. + */ + // const updateMask = '' + + // Imports the Kms library + const {KeyManagementServiceClient} = require('@google-cloud/kms').v1; + + // Instantiates a client + const kmsClient = new KeyManagementServiceClient(); + + async function updateCryptoKeyVersion() { + // Construct request + const request = { + cryptoKeyVersion, + updateMask, + }; + + // Run request + const response = await kmsClient.updateCryptoKeyVersion(request); + console.log(response); + } + + updateCryptoKeyVersion(); + // [END kms_v1_generated_KeyManagementService_UpdateCryptoKeyVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-kms/samples/package.json b/packages/google-cloud-kms/samples/package.json index 3a1eedb0690..59bf31e2b8e 100644 --- a/packages/google-cloud-kms/samples/package.json +++ b/packages/google-cloud-kms/samples/package.json @@ -8,7 +8,7 @@ "author": "Google LLC", "repository": "googleapis/nodejs-kms", "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "test": "c8 mocha --recursive test/ --timeout=800000" diff --git a/packages/google-cloud-kms/src/v1/key_management_service_client.ts b/packages/google-cloud-kms/src/v1/key_management_service_client.ts index 3441ecc5a34..43d633abe2a 100644 --- a/packages/google-cloud-kms/src/v1/key_management_service_client.ts +++ b/packages/google-cloud-kms/src/v1/key_management_service_client.ts @@ -2776,7 +2776,8 @@ export class KeyManagementServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listKeyRings']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listKeyRings.createStream( this.innerApiCalls.listKeyRings as gax.GaxCall, @@ -2841,7 +2842,8 @@ export class KeyManagementServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listKeyRings']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listKeyRings.asyncIterate( this.innerApiCalls['listKeyRings'] as GaxCall, @@ -3008,7 +3010,8 @@ export class KeyManagementServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listCryptoKeys']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listCryptoKeys.createStream( this.innerApiCalls.listCryptoKeys as gax.GaxCall, @@ -3075,7 +3078,8 @@ export class KeyManagementServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listCryptoKeys']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listCryptoKeys.asyncIterate( this.innerApiCalls['listCryptoKeys'] as GaxCall, @@ -3252,7 +3256,8 @@ export class KeyManagementServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listCryptoKeyVersions']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listCryptoKeyVersions.createStream( this.innerApiCalls.listCryptoKeyVersions as gax.GaxCall, @@ -3320,7 +3325,8 @@ export class KeyManagementServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listCryptoKeyVersions']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listCryptoKeyVersions.asyncIterate( this.innerApiCalls['listCryptoKeyVersions'] as GaxCall, @@ -3483,7 +3489,8 @@ export class KeyManagementServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listImportJobs']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listImportJobs.createStream( this.innerApiCalls.listImportJobs as gax.GaxCall, @@ -3548,7 +3555,8 @@ export class KeyManagementServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listImportJobs']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listImportJobs.asyncIterate( this.innerApiCalls['listImportJobs'] as GaxCall,