( projectId = 'my-project', locationId = 'us-east1', keyRingId = 'my-key-ring', id = 'my-import-job' )
| 15 | 'use strict'; |
| 16 | |
| 17 | async function main( |
| 18 | projectId = 'my-project', |
| 19 | locationId = 'us-east1', |
| 20 | keyRingId = 'my-key-ring', |
| 21 | id = 'my-import-job' |
| 22 | ) { |
| 23 | // [START kms_create_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 id = '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 parent key ring name |
| 39 | const keyRingName = client.keyRingPath(projectId, locationId, keyRingId); |
| 40 | |
| 41 | async function createImportJob() { |
| 42 | const [importJob] = await client.createImportJob({ |
| 43 | parent: keyRingName, |
| 44 | importJobId: id, |
| 45 | importJob: { |
| 46 | protectionLevel: 'HSM', |
| 47 | importMethod: 'RSA_OAEP_3072_SHA256', |
| 48 | }, |
| 49 | }); |
| 50 | |
| 51 | console.log(`Created import job: ${importJob.name}`); |
| 52 | return importJob; |
| 53 | } |
| 54 | |
| 55 | return createImportJob(); |
| 56 | // [END kms_create_import_job] |
| 57 | } |
| 58 | module.exports.main = main; |
| 59 | |
| 60 | /* c8 ignore next 10 */ |
no test coverage detected