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

Function main

service-directory/snippets/createService.js:18–60  ·  view source on GitHub ↗
(
  projectId = 'my-project',
  locationId = 'us-east1',
  namespaceId = 'my-namespace',
  serviceId = 'my-service'
)

Source from the content-addressed store, hash-verified

16'use strict';
17
18async 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
62const args = process.argv.slice(2);
63main(...args).catch(console.error);

Callers 1

createService.jsFile · 0.70

Calls 1

createServiceFunction · 0.85

Tested by

no test coverage detected