Skip to content

Commit

Permalink
Adds quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
telpirion authored and NimJay committed Nov 11, 2022
1 parent 4d70810 commit f882c34
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions game-servers/snippets/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,37 @@
'use strict';

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

// [END LIBRARY_NAME_quickstart]
const client = new RealmsServiceClient();

const request = {
parent: `projects/${projectId}/locations/${location}`,
realmId: 'my-realm',
realm: {
// Must use a valid support time zone.
// See https://cloud.google.com/dataprep/docs/html/Supported-Time-Zone-Values_66194188
timeZone: 'US/Pacific',
description: 'My Game Server realm',
},
};

const [operation] = await client.createRealm(request);
const results = await operation.promise();
const [realm] = results;

console.log('Realm created:');

console.log(`\tRealm name: ${realm.name}`);
console.log(`\tRealm description: ${realm.description}`);
console.log(`\tRealm time zone: ${realm.timeZone}`);
// [END game_servers_quickstart]
}

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

0 comments on commit f882c34

Please sign in to comment.