Skip to content

Commit 80f618f

Browse files
committed
Adds quickstart
1 parent 472db86 commit 80f618f

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

cloud-game-servers/snippets/quickstart.js

+30-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,37 @@
1414
'use strict';
1515

1616
/**
17-
* DESCRIBE WHAT THIS SAMPLE DOES.
18-
* @param {string} LIST EXPECTED ARGUMENTS.
19-
*/
20-
async function main() {
21-
// [START LIBRARY_NAME_quickstart]
17+
* Create a Game Servers realm.
18+
* @param {string} projectId string project identifier.
19+
* @param {string} location Compute Engine region.
20+
*/
21+
async function main(projectId, location) {
22+
// [START game_servers_quickstart]
23+
const {RealmsServiceClient} = require('@google-cloud/game-servers');
2224

23-
// [END LIBRARY_NAME_quickstart]
25+
const client = new RealmsServiceClient();
26+
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+
};
37+
38+
const [operation] = await client.createRealm(request);
39+
const results = await operation.promise();
40+
const [realm] = results;
41+
42+
console.log('Realm created:');
43+
44+
console.log(`\tRealm name: ${realm.name}`);
45+
console.log(`\tRealm description: ${realm.description}`);
46+
console.log(`\tRealm time zone: ${realm.timeZone}`);
47+
// [END game_servers_quickstart]
2448
}
2549

2650
main(...process.argv.slice(2)).catch(err => {

0 commit comments

Comments
 (0)