MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

kms/checkStateImportJob.js:17–59  ·  view source on GitHub ↗
(
  projectId = 'my-project',
  locationId = 'us-east1',
  keyRingId = 'my-key-ring',
  importJobId = 'my-import-job'
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17async function main(
18 projectId = 'my-project',
19 locationId = 'us-east1',
20 keyRingId = 'my-key-ring',
21 importJobId = 'my-import-job'
22) {
23 // [START kms_check_state_import_job]
24 //
25 // TODO(developer): Uncomment these variables before running the sample.
26 //
27 // const projectId = 'my-project';
28 // const locationId = 'us-east1';
29 // const keyRingId = 'my-key-ring';
30 // const importJobId = 'my-import-job';
31
32 // Imports the Cloud KMS library
33 const {KeyManagementServiceClient} = require('@google-cloud/kms');
34
35 // Instantiates a client
36 const client = new KeyManagementServiceClient();
37
38 // Build the import job name
39 const importJobName = client.importJobPath(
40 projectId,
41 locationId,
42 keyRingId,
43 importJobId
44 );
45
46 async function checkStateImportJob() {
47 const [importJob] = await client.getImportJob({
48 name: importJobName,
49 });
50
51 console.log(
52 `Current state of import job ${importJob.name}: ${importJob.state}`
53 );
54 return importJob;
55 }
56
57 return checkStateImportJob();
58 // [END kms_check_state_import_job]
59}
60module.exports.main = main;
61
62/* c8 ignore next 10 */

Callers 1

Calls 1

checkStateImportJobFunction · 0.85

Tested by

no test coverage detected