|
13 | 13 |
|
14 | 14 | 'use strict';
|
15 | 15 |
|
| 16 | +// sample-metadata: |
| 17 | +// title: Create Game Server Realm |
| 18 | +// description: Creates a new Realm within Cloud Game Servers |
| 19 | +// usage: node quickstart.js <project_id> <location> <realmId> |
| 20 | + |
16 | 21 | /**
|
17 | 22 | * Create a Game Servers realm.
|
18 | 23 | * @param {string} projectId string project identifier.
|
19 | 24 | * @param {string} location Compute Engine region.
|
20 | 25 | */
|
21 |
| -async function main(projectId, location) { |
| 26 | +async function main(projectId, location, realmId) { |
22 | 27 | // [START game_servers_quickstart]
|
23 | 28 | const {RealmsServiceClient} = require('@google-cloud/game-servers');
|
24 | 29 |
|
25 |
| - const client = new RealmsServiceClient(); |
| 30 | + async function quickstart() { |
| 31 | + const client = new RealmsServiceClient(); |
| 32 | + |
| 33 | + // TODO(developer): uncomment the following section, and add values |
| 34 | + // const projectId = 'YOUR_PROJECT_ID'; |
| 35 | + // const location = 'us-central1; |
| 36 | + // const realIm = 'DESIRED_REALM_ID'; |
26 | 37 |
|
27 |
| - const request = { |
28 |
| - parent: `projects/${projectId}/locations/${location}`, |
29 |
| - realmId: 'my-realm', |
30 |
| - realm: { |
31 |
| - // Must use a valid support time zone. |
32 |
| - // See https://cloud.google.com/dataprep/docs/html/Supported-Time-Zone-Values_66194188 |
33 |
| - timeZone: 'US/Pacific', |
34 |
| - description: 'My Game Server realm', |
35 |
| - }, |
36 |
| - }; |
| 38 | + const request = { |
| 39 | + parent: `projects/${projectId}/locations/${location}`, |
| 40 | + realmId, |
| 41 | + realm: { |
| 42 | + // Must use a valid support time zone. |
| 43 | + // See https://cloud.google.com/dataprep/docs/html/Supported-Time-Zone-Values_66194188 |
| 44 | + timeZone: 'US/Pacific', |
| 45 | + description: 'My Game Server realm', |
| 46 | + }, |
| 47 | + }; |
37 | 48 |
|
38 |
| - const [operation] = await client.createRealm(request); |
39 |
| - const results = await operation.promise(); |
40 |
| - const [realm] = results; |
| 49 | + const [operation] = await client.createRealm(request); |
| 50 | + const results = await operation.promise(); |
| 51 | + const [realm] = results; |
41 | 52 |
|
42 |
| - console.log('Realm created:'); |
| 53 | + console.log('Realm created:'); |
43 | 54 |
|
44 |
| - console.log(`\tRealm name: ${realm.name}`); |
45 |
| - console.log(`\tRealm description: ${realm.description}`); |
46 |
| - console.log(`\tRealm time zone: ${realm.timeZone}`); |
| 55 | + console.log(`\tRealm name: ${realm.name}`); |
| 56 | + console.log(`\tRealm description: ${realm.description}`); |
| 57 | + console.log(`\tRealm time zone: ${realm.timeZone}`); |
| 58 | + } |
| 59 | + quickstart(); |
47 | 60 | // [END game_servers_quickstart]
|
48 | 61 | }
|
49 | 62 |
|
|
0 commit comments