|
| 1 | +// Copyright 2022 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// |
| 15 | +// ** This file is automatically generated by gapic-generator-typescript. ** |
| 16 | +// ** https://github.com/googleapis/gapic-generator-typescript ** |
| 17 | +// ** All changes to this file may be overwritten. ** |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +'use strict'; |
| 22 | + |
| 23 | +function main(parent, backupId, backup) { |
| 24 | + // [START metastore_v1_generated_DataprocMetastore_CreateBackup_async] |
| 25 | + /** |
| 26 | + * TODO(developer): Uncomment these variables before running the sample. |
| 27 | + */ |
| 28 | + /** |
| 29 | + * Required. The relative resource name of the service in which to create a backup |
| 30 | + * of the following form: |
| 31 | + * `projects/{project_number}/locations/{location_id}/services/{service_id}`. |
| 32 | + */ |
| 33 | + // const parent = 'abc123' |
| 34 | + /** |
| 35 | + * Required. The ID of the backup, which is used as the final component of the |
| 36 | + * backup's name. |
| 37 | + * This value must be between 1 and 64 characters long, begin with a letter, |
| 38 | + * end with a letter or number, and consist of alpha-numeric ASCII characters |
| 39 | + * or hyphens. |
| 40 | + */ |
| 41 | + // const backupId = 'abc123' |
| 42 | + /** |
| 43 | + * Required. The backup to create. The `name` field is ignored. The ID of the created |
| 44 | + * backup must be provided in the request's `backup_id` field. |
| 45 | + */ |
| 46 | + // const backup = {} |
| 47 | + /** |
| 48 | + * Optional. A request ID. Specify a unique request ID to allow the server to ignore the |
| 49 | + * request if it has completed. The server will ignore subsequent requests |
| 50 | + * that provide a duplicate request ID for at least 60 minutes after the first |
| 51 | + * request. |
| 52 | + * For example, if an initial request times out, followed by another request |
| 53 | + * with the same request ID, the server ignores the second request to prevent |
| 54 | + * the creation of duplicate commitments. |
| 55 | + * The request ID must be a valid |
| 56 | + * UUID (https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) |
| 57 | + * A zero UUID (00000000-0000-0000-0000-000000000000) is not supported. |
| 58 | + */ |
| 59 | + // const requestId = 'abc123' |
| 60 | + |
| 61 | + // Imports the Metastore library |
| 62 | + const {DataprocMetastoreClient} = require('@google-cloud/dataproc-metastore').v1; |
| 63 | + |
| 64 | + // Instantiates a client |
| 65 | + const metastoreClient = new DataprocMetastoreClient(); |
| 66 | + |
| 67 | + async function callCreateBackup() { |
| 68 | + // Construct request |
| 69 | + const request = { |
| 70 | + parent, |
| 71 | + backupId, |
| 72 | + backup, |
| 73 | + }; |
| 74 | + |
| 75 | + // Run request |
| 76 | + const [operation] = await metastoreClient.createBackup(request); |
| 77 | + const [response] = await operation.promise(); |
| 78 | + console.log(response); |
| 79 | + } |
| 80 | + |
| 81 | + callCreateBackup(); |
| 82 | + // [END metastore_v1_generated_DataprocMetastore_CreateBackup_async] |
| 83 | +} |
| 84 | + |
| 85 | +process.on('unhandledRejection', err => { |
| 86 | + console.error(err.message); |
| 87 | + process.exitCode = 1; |
| 88 | +}); |
| 89 | +main(...process.argv.slice(2)); |
0 commit comments