|
| 1 | +// Copyright 2021 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 | +// http://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 | +'use strict'; |
| 16 | + |
| 17 | +function main(parent, connectionProfileId, connectionProfile) { |
| 18 | + // [START datamigration_v1_generated_DataMigrationService_CreateConnectionProfile_async] |
| 19 | + /** |
| 20 | + * TODO(developer): Uncomment these variables before running the sample. |
| 21 | + */ |
| 22 | + /** |
| 23 | + * Required. The parent, which owns this collection of connection profiles. |
| 24 | + */ |
| 25 | + // const parent = 'abc123' |
| 26 | + /** |
| 27 | + * Required. The connection profile identifier. |
| 28 | + */ |
| 29 | + // const connectionProfileId = 'abc123' |
| 30 | + /** |
| 31 | + * Required. The create request body including the connection profile data |
| 32 | + */ |
| 33 | + // const connectionProfile = '' |
| 34 | + /** |
| 35 | + * A unique id used to identify the request. If the server receives two |
| 36 | + * requests with the same id, then the second request will be ignored. |
| 37 | + * It is recommended to always set this value to a UUID. |
| 38 | + * The id must contain only letters (a-z, A-Z), numbers (0-9), underscores |
| 39 | + * (_), and hyphens (-). The maximum length is 40 characters. |
| 40 | + */ |
| 41 | + // const requestId = 'abc123' |
| 42 | + |
| 43 | + // Imports the Clouddms library |
| 44 | + const {DataMigrationServiceClient} = require('@google-cloud/dms').v1; |
| 45 | + |
| 46 | + // Instantiates a client |
| 47 | + const clouddmsClient = new DataMigrationServiceClient(); |
| 48 | + |
| 49 | + async function createConnectionProfile() { |
| 50 | + // Construct request |
| 51 | + const request = { |
| 52 | + parent, |
| 53 | + connectionProfileId, |
| 54 | + connectionProfile, |
| 55 | + }; |
| 56 | + |
| 57 | + // Run request |
| 58 | + const [operation] = await clouddmsClient.createConnectionProfile(request); |
| 59 | + const [response] = await operation.promise(); |
| 60 | + console.log(response); |
| 61 | + } |
| 62 | + |
| 63 | + createConnectionProfile(); |
| 64 | + // [END datamigration_v1_generated_DataMigrationService_CreateConnectionProfile_async] |
| 65 | +} |
| 66 | + |
| 67 | +process.on('unhandledRejection', err => { |
| 68 | + console.error(err.message); |
| 69 | + process.exitCode = 1; |
| 70 | +}); |
| 71 | +main(...process.argv.slice(2)); |
0 commit comments