( projectId = 'my-project', locationId = 'us-east1', namespaceId = 'my-namespace', serviceId = 'my-service' )
| 16 | 'use strict'; |
| 17 | |
| 18 | async function main( |
| 19 | projectId = 'my-project', |
| 20 | locationId = 'us-east1', |
| 21 | namespaceId = 'my-namespace', |
| 22 | serviceId = 'my-service' |
| 23 | ) { |
| 24 | // [START servicedirectory_create_service] |
| 25 | // |
| 26 | // TODO(developer): Uncomment these variables before running the sample. |
| 27 | // |
| 28 | // const projectId = 'my-project'; |
| 29 | // const locationId = 'us-central1'; |
| 30 | // const namespaceId = 'my-namespace'; |
| 31 | // const serviceId = 'my-service'; |
| 32 | |
| 33 | // Imports the Google Cloud client library |
| 34 | const { |
| 35 | RegistrationServiceClient, |
| 36 | } = require('@google-cloud/service-directory'); |
| 37 | |
| 38 | // Creates a client |
| 39 | const registrationServiceClient = new RegistrationServiceClient(); |
| 40 | |
| 41 | // Build the namespace name |
| 42 | const namespaceName = registrationServiceClient.namespacePath( |
| 43 | projectId, |
| 44 | locationId, |
| 45 | namespaceId |
| 46 | ); |
| 47 | |
| 48 | async function createService() { |
| 49 | const [service] = await registrationServiceClient.createService({ |
| 50 | parent: namespaceName, |
| 51 | serviceId: serviceId, |
| 52 | }); |
| 53 | |
| 54 | console.log(`Created service: ${service.name}`); |
| 55 | return service; |
| 56 | } |
| 57 | |
| 58 | return createService(); |
| 59 | // [END servicedirectory_create_service] |
| 60 | } |
| 61 | |
| 62 | const args = process.argv.slice(2); |
| 63 | main(...args).catch(console.error); |
no test coverage detected