From 6f4050102a23d53740a822f9bd708f5dce933104 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 1 May 2024 22:29:04 -0700 Subject: [PATCH] fix: remove unused game-servers --- .github/auto-label.yaml | 1 - .github/workflows/game-servers-snippets.yaml | 56 ----- .github/workflows/utils/workflows.json | 3 +- game-servers/snippets/create_cluster.js | 86 ------- game-servers/snippets/create_config.js | 144 ------------ game-servers/snippets/create_deployment.js | 66 ------ game-servers/snippets/create_realm.js | 72 ------ game-servers/snippets/delete_cluster.js | 71 ------ game-servers/snippets/delete_config.js | 68 ------ game-servers/snippets/delete_deployment.js | 61 ----- game-servers/snippets/delete_realm.js | 61 ----- game-servers/snippets/get_cluster.js | 85 ------- game-servers/snippets/get_config.js | 72 ------ game-servers/snippets/get_deployment.js | 64 ------ game-servers/snippets/get_realm.js | 66 ------ game-servers/snippets/get_rollout.js | 70 ------ game-servers/snippets/list_clusters.js | 80 ------- game-servers/snippets/list_configs.js | 69 ------ game-servers/snippets/list_deployments.js | 62 ----- game-servers/snippets/list_realms.js | 60 ----- game-servers/snippets/package.json | 24 -- game-servers/snippets/quickstart.js | 67 ------ game-servers/snippets/test/clean.js | 70 ------ .../snippets/test/create_cluster.test.js | 90 -------- .../snippets/test/create_realm.test.js | 55 ----- .../snippets/test/crud_config.test.js | 95 -------- .../snippets/test/crud_deployment.test.js | 79 ------- .../snippets/test/delete_cluster.test.js | 96 -------- .../snippets/test/delete_realm.test.js | 59 ----- .../snippets/test/get_cluster.test.js | 109 --------- game-servers/snippets/test/get_realm.test.js | 68 ------ .../snippets/test/list_clusters.test.js | 109 --------- .../snippets/test/list_realms.test.js | 68 ------ game-servers/snippets/test/quickstart.js | 53 ----- game-servers/snippets/test/quickstart.test.js | 55 ----- game-servers/snippets/test/rollout.js | 212 ------------------ .../snippets/test/update_cluster_test.js | 113 ---------- .../snippets/test/update_realm_test.js | 70 ------ game-servers/snippets/update_cluster.js | 80 ------- game-servers/snippets/update_deployment.js | 73 ------ game-servers/snippets/update_realm.js | 71 ------ .../snippets/update_rollout_default.js | 73 ------ .../snippets/update_rollout_override.js | 86 ------- .../snippets/update_rollout_remove_default.js | 70 ------ .../update_rollout_remove_override.js | 69 ------ 45 files changed, 1 insertion(+), 3330 deletions(-) delete mode 100644 .github/workflows/game-servers-snippets.yaml delete mode 100644 game-servers/snippets/create_cluster.js delete mode 100644 game-servers/snippets/create_config.js delete mode 100644 game-servers/snippets/create_deployment.js delete mode 100644 game-servers/snippets/create_realm.js delete mode 100644 game-servers/snippets/delete_cluster.js delete mode 100644 game-servers/snippets/delete_config.js delete mode 100644 game-servers/snippets/delete_deployment.js delete mode 100644 game-servers/snippets/delete_realm.js delete mode 100644 game-servers/snippets/get_cluster.js delete mode 100644 game-servers/snippets/get_config.js delete mode 100644 game-servers/snippets/get_deployment.js delete mode 100644 game-servers/snippets/get_realm.js delete mode 100644 game-servers/snippets/get_rollout.js delete mode 100644 game-servers/snippets/list_clusters.js delete mode 100644 game-servers/snippets/list_configs.js delete mode 100644 game-servers/snippets/list_deployments.js delete mode 100644 game-servers/snippets/list_realms.js delete mode 100644 game-servers/snippets/package.json delete mode 100644 game-servers/snippets/quickstart.js delete mode 100644 game-servers/snippets/test/clean.js delete mode 100644 game-servers/snippets/test/create_cluster.test.js delete mode 100644 game-servers/snippets/test/create_realm.test.js delete mode 100644 game-servers/snippets/test/crud_config.test.js delete mode 100644 game-servers/snippets/test/crud_deployment.test.js delete mode 100644 game-servers/snippets/test/delete_cluster.test.js delete mode 100644 game-servers/snippets/test/delete_realm.test.js delete mode 100644 game-servers/snippets/test/get_cluster.test.js delete mode 100644 game-servers/snippets/test/get_realm.test.js delete mode 100644 game-servers/snippets/test/list_clusters.test.js delete mode 100644 game-servers/snippets/test/list_realms.test.js delete mode 100644 game-servers/snippets/test/quickstart.js delete mode 100644 game-servers/snippets/test/quickstart.test.js delete mode 100644 game-servers/snippets/test/rollout.js delete mode 100644 game-servers/snippets/test/update_cluster_test.js delete mode 100644 game-servers/snippets/test/update_realm_test.js delete mode 100644 game-servers/snippets/update_cluster.js delete mode 100644 game-servers/snippets/update_deployment.js delete mode 100644 game-servers/snippets/update_realm.js delete mode 100644 game-servers/snippets/update_rollout_default.js delete mode 100644 game-servers/snippets/update_rollout_override.js delete mode 100644 game-servers/snippets/update_rollout_remove_default.js delete mode 100644 game-servers/snippets/update_rollout_remove_override.js diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml index 450d366f8a..01f6d2b337 100644 --- a/.github/auto-label.yaml +++ b/.github/auto-label.yaml @@ -46,7 +46,6 @@ path: error-reporting: "clouderrorreporting" functions: "cloudfunctions" generative-ai: "genai" - game-servers: "gameservices" healthcare: "healhcare" iam: "iam" kms: "cloudkms" diff --git a/.github/workflows/game-servers-snippets.yaml b/.github/workflows/game-servers-snippets.yaml deleted file mode 100644 index 519a1eb467..0000000000 --- a/.github/workflows/game-servers-snippets.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: game-servers-snippets -on: - push: - branches: - - main - paths: - - 'game-servers/snippets/**' - - '.github/workflows/game-servers-snippets.yaml' - - '.github/workflows/test.yaml' - pull_request: - paths: - - 'game-servers/snippets/**' - - '.github/workflows/game-servers-snippets.yaml' - - '.github/workflows/test.yaml' - pull_request_target: - types: [labeled] - paths: - - 'game-servers/snippets/**' - - '.github/workflows/game-servers-snippets.yaml' - - '.github/workflows/test.yaml' - schedule: - - cron: '0 0 * * 0' -jobs: - # ----------------- - # Issue to revisit skip: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/3466 - # ----------------- - # test: - # permissions: - # contents: 'read' - # id-token: 'write' - # if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' - # uses: ./.github/workflows/test.yaml - # with: - # name: 'game-servers-snippets' - # path: 'game-servers/snippets' - flakybot: - permissions: - contents: 'read' - id-token: 'write' - if: github.event_name == 'schedule' && always() # always() submits logs even if tests fail - uses: ./.github/workflows/flakybot.yaml - # needs: [test] diff --git a/.github/workflows/utils/workflows.json b/.github/workflows/utils/workflows.json index 7d5fad553f..ff954978f8 100644 --- a/.github/workflows/utils/workflows.json +++ b/.github/workflows/utils/workflows.json @@ -49,7 +49,7 @@ "functions/memorystore/redis", "functions/scheduleinstance", "functions/security", - "functions/spanner", + "functions/spanner", "functions/speech-to-speech/functions", "functions/v2/autoLabelInstance", "functions/v2/cloudEventLogging", @@ -68,7 +68,6 @@ "functions/v2/tips/retry", "functions/v2/typed/greeting", "functions/v2/typed/googlechatbot", - "game-servers/snippets", "healthcare/consent", "healthcare/datasets", "healthcare/dicom", diff --git a/game-servers/snippets/create_cluster.js b/game-servers/snippets/create_cluster.js deleted file mode 100644 index 71b177fe07..0000000000 --- a/game-servers/snippets/create_cluster.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Create a Game Servers cluster. - * @param {string} projectId string project identifier - * @param {string} location Compute Engine region - * @param {string} realmId the realm to use - * @param {string} gameClusterId unique identifier for the new Game Cluster - * @param {string} gkeClusterName The full resource name of the GKE cluster to use - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID', - gameClusterId = 'GAME_CLUSTER_ID', - gkeClusterName = 'GKE_CLUSTER_NAME' -) { - // [START cloud_game_servers_cluster_create] - const { - GameServerClustersServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerClustersServiceClient(); - - async function createGameServerCluster() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'The ID of the realm to locate this cluster in'; - // const gameClusterId = 'A unique ID for this Game Server Cluster'; - // const gkeClusterName= 'The full resource name of the GKE cluster to use'; - const request = { - // Provide full resource name of a Game Server Realm - parent: client.realmPath(projectId, location, realmId), - gameServerClusterId: gameClusterId, - gameServerCluster: { - description: 'My Game Server Cluster', - connectionInfo: { - gkeClusterReference: { - // Provide full resource name of a Kubernetes Engine cluster - // In the form of 'projects//locations//clusters/' - cluster: gkeClusterName, - }, - namespace: 'default', - }, - }, - }; - - const [operation] = await client.createGameServerCluster(request); - const [result] = await operation.promise(); - - console.log('Game Server Cluster created:'); - console.log(`\tCluster name: ${result.name}`); - console.log(`\tCluster description: ${result.description}`); - console.log( - `\tGKE cluster: ${result.connectionInfo.gkeClusterReference.cluster}` - ); - } - - createGameServerCluster(); - // [END cloud_game_servers_cluster_create] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/create_config.js b/game-servers/snippets/create_config.js deleted file mode 100644 index db1b526157..0000000000 --- a/game-servers/snippets/create_config.js +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Create a Game Servers Config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the parent Game Server Deployment - * @param {string} configId unique identifier for the new Game Server Config - * @param {string} fleetName fleet name to be stored in Agones - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID', - configId = 'CONFIG_ID', - fleetName = 'FLEET_NAME' -) { - // [START cloud_game_servers_config_create] - const { - GameServerConfigsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerConfigsServiceClient(); - - async function createGameServerConfig() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - // const configId = 'A unique ID for the Game Server Config'; - // const fleetName = 'The fleet name to be stored in Agones'; - // fleet is the spec portion of an agones Fleet. It must be in JSON format. - // See https://agones.dev/site/docs/reference/fleet/ for more on fleets. - const fleet = ` -{ - "replicas": 10, - "scheduling": "Packed", - "strategy": { - "type": "RollingUpdate", - "rollingUpdate": { - "maxSurge": "25%", - "maxUnavailable": "25%" - } - }, - "template": { - "metadata": { - "labels": { - "gameName": "udp-server" - } - }, - "spec": { - "ports": [ - { - "name": "default", - "portPolicy": "Dynamic", - "containerPort": 2156, - "protocol": "TCP" - } - ], - "health": { - "initialDelaySeconds": 30, - "periodSeconds": 60 - }, - "sdkServer": { - "logLevel": "Info", - "grpcPort": 9357, - "httpPort": 9358 - }, - "template": { - "spec": { - "containers": [ - { - "name": "dedicated", - "image": "gcr.io/agones-images/udp-server:0.17", - "imagePullPolicy": "Always", - "resources": { - "requests": { - "memory": "200Mi", - "cpu": "500m" - }, - "limits": { - "memory": "200Mi", - "cpu": "500m" - } - } - } - ] - } - } - } - } -} -`; - const request = { - parent: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - configId: configId, - gameServerConfig: { - fleetConfigs: [ - { - name: fleetName, - fleetSpec: fleet, - }, - ], - description: 'nodejs test config', - }, - }; - - const [operation] = await client.createGameServerConfig(request); - const [result] = await operation.promise(); - - console.log('Game Server Config created:'); - console.log(`\t Config name: ${result.name}`); - console.log(`\t Config description: ${result.description}`); - } - - createGameServerConfig(); - - // [END cloud_game_servers_config_create] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/create_deployment.js b/game-servers/snippets/create_deployment.js deleted file mode 100644 index 4b057352f7..0000000000 --- a/game-servers/snippets/create_deployment.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Create a Game Servers Deployment. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_deployment_create] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function createGameServerDeployment() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - parent: `projects/${projectId}/locations/global`, - deploymentId: deploymentId, - gameServerDeployment: { - description: 'nodejs test deployment', - }, - }; - - const [operation] = await client.createGameServerDeployment(request); - const [result] = await operation.promise(); - - console.log('Game Server Deployment created:'); - console.log(`\t Deployment name: ${result.name}`); - console.log(`\t Deployment description: ${result.description}`); - } - - createGameServerDeployment(); - - // [END cloud_game_servers_deployment_create] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/create_realm.js b/game-servers/snippets/create_realm.js deleted file mode 100644 index 456de890f7..0000000000 --- a/game-servers/snippets/create_realm.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Create a Game Servers realm. - * @param {string} projectId string project identifier. - * @param {string} location Compute Engine region. - * @param {string} realmId a unique identifier for the new realm - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID' -) { - // [START cloud_game_servers_realm_create] - const {RealmsServiceClient} = require('@google-cloud/game-servers'); - - const client = new RealmsServiceClient(); - - async function createRealm() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'A unique identifier for the realm'; - const request = { - parent: `projects/${projectId}/locations/${location}`, - realmId: realmId, - realm: { - // Must use a supported time zone name. - // 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}`); - } - - createRealm(); - // [END cloud_game_servers_realm_create] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/delete_cluster.js b/game-servers/snippets/delete_cluster.js deleted file mode 100644 index ec1266bc88..0000000000 --- a/game-servers/snippets/delete_cluster.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Delete a Game Server cluster - * @param {string} projectId string project identifier - * @param {string} location Compute Engine region - * @param {string} realmId the realm to use - * @param {string} gameClusterId the game cluster to delete - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID', - gameClusterId = 'GAME_CLUSTER_ID' -) { - // [START cloud_game_servers_cluster_delete] - const { - GameServerClustersServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerClustersServiceClient(); - - async function deleteGameServerCluster() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'The ID of the realm to locate this cluster in'; - // const gameClusterId = 'The unique ID for this Game Server Cluster'; - const request = { - // Provide full resource name of a Game Server Realm - name: client.gameServerClusterPath( - projectId, - location, - realmId, - gameClusterId - ), - }; - - const [operation] = await client.deleteGameServerCluster(request); - await operation.promise(); - - console.log('Game Server cluster deleted'); - } - - deleteGameServerCluster(); - // [END cloud_game_servers_cluster_delete] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/delete_config.js b/game-servers/snippets/delete_config.js deleted file mode 100644 index b083f29813..0000000000 --- a/game-servers/snippets/delete_config.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Delete a Game Servers Config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - * @param {string} configId unique identifier for the new Game Server Config - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID', - configId = 'CONFIG_ID' -) { - // [START cloud_game_servers_config_delete] - const { - GameServerConfigsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerConfigsServiceClient(); - - async function deleteGameServerConfig() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - // const configId = 'A unique ID for the Game Server Config'; - const request = { - // The full resource name - name: client.gameServerConfigPath( - projectId, - 'global', - deploymentId, - configId - ), - }; - - const [operation] = await client.deleteGameServerConfig(request); - await operation.promise(); - console.log(`Config with name ${request.name} deleted.`); - } - - deleteGameServerConfig(); - - // [END cloud_game_servers_config_delete] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/delete_deployment.js b/game-servers/snippets/delete_deployment.js deleted file mode 100644 index e45b144f50..0000000000 --- a/game-servers/snippets/delete_deployment.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Delete a Game Servers Deployment. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_deployment_delete] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function deleteGameServerDeployment() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - // The full resource name - name: client.gameServerDeploymentPath(projectId, 'global', deploymentId), - }; - - const [operation] = await client.deleteGameServerDeployment(request); - await operation.promise(); - - console.log(`Deployment with name ${request.name} deleted.`); - } - - deleteGameServerDeployment(); - - // [END cloud_game_servers_deployment_delete] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/delete_realm.js b/game-servers/snippets/delete_realm.js deleted file mode 100644 index da1f98ba19..0000000000 --- a/game-servers/snippets/delete_realm.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Delete a realm by ID - * @param {string} projectId string project identifier. - * @param {string} location Compute Engine region. - * @param {string} realmId the unique ID of the realm - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID' -) { - // [START cloud_game_servers_realm_delete] - const {RealmsServiceClient} = require('@google-cloud/game-servers'); - - const client = new RealmsServiceClient(); - - async function deleteRealm() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'Unique identifier of the realm'; - const request = { - // Realm name is the full resource name including project ID,location, - // and the realm ID. - name: client.realmPath(projectId, location, realmId), - }; - - const [operation] = await client.deleteRealm(request); - await operation.promise(); - console.log(`Realm with ID ${realmId} deleted.`); - } - - deleteRealm(); - // [END cloud_game_servers_realm_delete] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/get_cluster.js b/game-servers/snippets/get_cluster.js deleted file mode 100644 index 8701ac805b..0000000000 --- a/game-servers/snippets/get_cluster.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Get a Game Server cluster - * @param {string} projectId string project identifier - * @param {string} location Compute Engine region - * @param {string} realmId the realm to use - * @param {string} gameClusterId the game cluster to get - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID', - gameClusterId = 'GAME_CLUSTER_ID' -) { - // [START cloud_game_servers_cluster_get] - const { - GameServerClustersServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerClustersServiceClient(); - - async function getGameServerCluster() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'The ID of the realm to locate this cluster in'; - // const gameClusterId = 'The unique ID for this Game Server Cluster'; - const request = { - // Provide full resource name of a Game Server Realm - name: client.gameServerClusterPath( - projectId, - location, - realmId, - gameClusterId - ), - view: 'FULL', - }; - - const [cluster] = await client.getGameServerCluster(request); - - console.log('Game Server Cluster:'); - console.log(`\tCluster name: ${cluster.name}`); - console.log(`\tCluster description: ${cluster.description}`); - console.log( - `\tCluster installed Agones version: ${cluster.clusterState.agonesVersionInstalled}` - ); - console.log( - `\tCluster installed Kubernetes version: ${cluster.clusterState.kubernetesVersionInstalled}` - ); - console.log( - `\tCluster installation state: ${cluster.clusterState.installationState}` - ); - console.log( - `\tGKE cluster: ${cluster.connectionInfo.gkeClusterReference.cluster}` - ); - } - - getGameServerCluster(); - // [END cloud_game_servers_cluster_get] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/get_config.js b/game-servers/snippets/get_config.js deleted file mode 100644 index 1272918fec..0000000000 --- a/game-servers/snippets/get_config.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Get a Game Servers Config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - * @param {string} configId unique identifier for the new Game Server Config - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID', - configId = 'CONFIG_ID' -) { - // [START cloud_game_servers_config_get] - const { - GameServerConfigsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerConfigsServiceClient(); - - async function getGameServerConfig() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - // const configId = 'A unique ID for the Game Server Config'; - const request = { - // The full resource name - name: client.gameServerConfigPath( - projectId, - 'global', - deploymentId, - configId - ), - }; - - const [config] = await client.getGameServerConfig(request); - console.log(`Config name: ${config.name}`); - console.log(`Config description: ${config.description}`); - - const createTime = config.createTime; - const createDate = new Date(createTime.seconds * 1000); - console.log(`Config created on: ${createDate.toLocaleDateString()}\n`); - } - - getGameServerConfig(); - - // [END cloud_game_servers_config_get] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/get_deployment.js b/game-servers/snippets/get_deployment.js deleted file mode 100644 index d1b65c936f..0000000000 --- a/game-servers/snippets/get_deployment.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Get a Game Servers Deployment. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_deployment_get] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function getGameServerDeployment() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - // The full resource name - name: client.gameServerDeploymentPath(projectId, 'global', deploymentId), - }; - - const [deployment] = await client.getGameServerDeployment(request); - console.log(`Deployment name: ${deployment.name}`); - console.log(`Deployment description: ${deployment.description}`); - - const createTime = deployment.createTime; - const createDate = new Date(createTime.seconds * 1000); - console.log(`Deployment created on: ${createDate.toLocaleDateString()}\n`); - } - - getGameServerDeployment(); - - // [END cloud_game_servers_deployment_get] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/get_realm.js b/game-servers/snippets/get_realm.js deleted file mode 100644 index ae35dd99c0..0000000000 --- a/game-servers/snippets/get_realm.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Get a realm by ID - * @param {string} projectId string project identifier. - * @param {string} location Compute Engine region. - * @param {string} realmId the unique ID of the realm - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID' -) { - // [START cloud_game_servers_realm_get] - const {RealmsServiceClient} = require('@google-cloud/game-servers'); - - const client = new RealmsServiceClient(); - - async function getRealm() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'Unique identifier of the realm'; - const request = { - // Realm name is the full resource name including project ID and location - name: client.realmPath(projectId, location, realmId), - }; - - const [realm] = await client.getRealm(request); - console.log(`Realm name: ${realm.name}`); - console.log(`Realm description: ${realm.description}`); - console.log(`Realm time zone: ${realm.timeZone}`); - - const createTime = realm.createTime; - const createDate = new Date(createTime.seconds * 1000); - - console.log(`Realm created on: ${createDate.toLocaleDateString()}`); - } - - getRealm(); - // [END cloud_game_servers_realm_get] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/get_rollout.js b/game-servers/snippets/get_rollout.js deleted file mode 100644 index 72ba1ff80c..0000000000 --- a/game-servers/snippets/get_rollout.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Get a Game Servers Rollout. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_rollout_get] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function getGameServerDeploymentRollout() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - // The full resource name - name: client.gameServerDeploymentPath(projectId, 'global', deploymentId), - }; - - const [rollout] = await client.getGameServerDeploymentRollout(request); - console.log(`Rollout name: ${rollout.name}`); - console.log(`Rollout default: ${rollout.defaultGameServerConfig}`); - for (const override of rollout.gameServerConfigOverrides) { - console.log(`Rollout config overrides: ${override.configVersion}`); - console.log( - `Rollout realm overrides: ${JSON.stringify(override.realmsSelector)}` - ); - } - - const updateTime = rollout.updateTime; - const updateDate = new Date(updateTime.seconds * 1000); - console.log(`Rollout updated on: ${updateDate.toLocaleDateString()}\n`); - } - - getGameServerDeploymentRollout(); - - // [END cloud_game_servers_rollout_get] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/list_clusters.js b/game-servers/snippets/list_clusters.js deleted file mode 100644 index c73a7f0d26..0000000000 --- a/game-servers/snippets/list_clusters.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * List Game Server clusters - * @param {string} projectId string project identifier - * @param {string} location Compute Engine region - * @param {string} realmId the realm to use - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID' -) { - // [START cloud_game_servers_cluster_list] - const { - GameServerClustersServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerClustersServiceClient(); - - async function listGameServerClusters() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'The ID of the realm to locate this cluster in'; - const request = { - // Provide full resource name of a Game Server Realm - parent: client.realmPath(projectId, location, realmId), - view: 'FULL', - }; - - const results = await client.listGameServerClusters(request); - const [clusters] = results; - - for (const cluster of clusters) { - console.log('Game Server Cluster:'); - console.log(`\tCluster name: ${cluster.name}`); - console.log(`\tCluster description: ${cluster.description}`); - console.log( - `\tCluster installed Agones version: ${cluster.clusterState.agonesVersionInstalled}` - ); - console.log( - `\tCluster installed Kubernetes version: ${cluster.clusterState.kubernetesVersionInstalled}` - ); - console.log( - `\tCluster installation state: ${cluster.clusterState.installationState}` - ); - console.log( - `\tGKE cluster: ${cluster.connectionInfo.gkeClusterReference.cluster}` - ); - } - } - - listGameServerClusters(); - // [END cloud_game_servers_cluster_list] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/list_configs.js b/game-servers/snippets/list_configs.js deleted file mode 100644 index f6a844b50c..0000000000 --- a/game-servers/snippets/list_configs.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * List all the Game Servers Configs. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_config_list] - const { - GameServerConfigsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerConfigsServiceClient(); - - async function listGameServerConfigs() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - parent: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - }; - - const [results] = await client.listGameServerConfigs(request); - for (const config of results) { - console.log(`Config name: ${config.name}`); - console.log(`Config description: ${config.description}`); - - const createTime = config.createTime; - const createDate = new Date(createTime.seconds * 1000); - console.log(`Config created on: ${createDate.toLocaleDateString()}\n`); - } - } - - listGameServerConfigs(); - - // [END cloud_game_servers_config_list] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/list_deployments.js b/game-servers/snippets/list_deployments.js deleted file mode 100644 index d79534ecd0..0000000000 --- a/game-servers/snippets/list_deployments.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * List all the Game Servers Deployments. - * @param {string} projectId string project identifier - */ -async function main(projectId = 'YOUR_PROJECT_ID') { - // [START cloud_game_servers_deployment_list] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function listGameServerDeployments() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - const request = { - parent: `projects/${projectId}/locations/global`, - }; - - const [results] = await client.listGameServerDeployments(request); - for (const deployment of results) { - console.log(`Deployment name: ${deployment.name}`); - console.log(`Deployment description: ${deployment.description}`); - - const createTime = deployment.createTime; - const createDate = new Date(createTime.seconds * 1000); - console.log( - `Deployment created on: ${createDate.toLocaleDateString()}\n` - ); - } - } - - listGameServerDeployments(); - - // [END cloud_game_servers_deployment_list] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/list_realms.js b/game-servers/snippets/list_realms.js deleted file mode 100644 index ded96df687..0000000000 --- a/game-servers/snippets/list_realms.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * List all of the realms in a project. - * @param {string} projectId string project identifier. - * @param {string} location Compute Engine region. - */ -async function main(projectId = 'YOUR_PROJECT_ID', location = 'LOCATION_ID') { - // [START cloud_game_servers_realm_list] - const {RealmsServiceClient} = require('@google-cloud/game-servers'); - - const client = new RealmsServiceClient(); - - async function listRealms() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - const request = { - parent: `projects/${projectId}/locations/${location}`, - }; - - const [results] = await client.listRealms(request); - for (const realm of results) { - console.log(`Realm name: ${realm.name}`); - console.log(`Realm description: ${realm.description}`); - console.log(`Realm time zone: ${realm.timeZone}`); - - const createTime = realm.createTime; - const createDate = new Date(createTime.seconds * 1000); - console.log(`Realm created on: ${createDate.toLocaleDateString()}\n`); - } - } - - listRealms(); - // [END cloud_game_servers_realm_list] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/package.json b/game-servers/snippets/package.json deleted file mode 100644 index 7a29802842..0000000000 --- a/game-servers/snippets/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "nodejs-game-server-samples", - "private": true, - "license": "Apache-2.0", - "author": "Google LLC", - "engines": { - "node": ">=12.0.0" - }, - "files": [ - "*.js" - ], - "scripts": { - "test": "c8 mocha -p -j 2 --timeout 600000 test/*.js" - }, - "dependencies": { - "@google-cloud/game-servers": "^3.1.3" - }, - "devDependencies": { - "c8": "^8.0.0", - "chai": "^4.2.0", - "mocha": "^10.0.0", - "uuid": "^9.0.0" - } -} diff --git a/game-servers/snippets/quickstart.js b/game-servers/snippets/quickstart.js deleted file mode 100644 index 3a9c542322..0000000000 --- a/game-servers/snippets/quickstart.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -// sample-metadata: -// title: Create Game Server Realm -// description: Creates a new Realm within Cloud Game Servers -// usage: node quickstart.js - -/** - * Create a Game Servers realm. - * @param {string} projectId string project identifier. - * @param {string} location Compute Engine region. - * @param {string} realmId unique identifier for the realm. - */ -async function main(projectId, location, realmId) { - // [START cloud_game_servers_quickstart] - const {RealmsServiceClient} = require('@google-cloud/game-servers'); - - async function quickstart() { - const client = new RealmsServiceClient(); - - // TODO(developer): uncomment the following section, and add values - // const projectId = 'YOUR_PROJECT_ID'; - // const location = 'us-central1; - // const realmId = 'DESIRED_REALM_ID'; - - const request = { - parent: `projects/${projectId}/locations/${location}`, - realmId, - 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}`); - } - quickstart(); - // [END cloud_game_servers_quickstart] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/test/clean.js b/game-servers/snippets/test/clean.js deleted file mode 100644 index a02f2c15e4..0000000000 --- a/game-servers/snippets/test/clean.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const {GameServerClustersServiceClient} = require('@google-cloud/game-servers'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const gameServerClusterClient = new GameServerClustersServiceClient(); -const realmsClient = new RealmsServiceClient(); - -/** - * Utility function for removing unneeded realms from project. - */ -module.exports = async () => { - const projectId = await realmsClient.getProjectId(); - const location = 'us-central1'; - - const request = { - parent: `projects/${projectId}/locations/${location}`, - }; - - const MAX_REALM_LIFESPAN = 3600000; // One hour (in milliseconds) - const NOW = new Date(); - - const [results] = await realmsClient.listRealms(request); - for (const realm of results) { - // Check age of realm. If older than maximum life span, delete. - const ageOfRealm = new Date(realm.createTime.seconds * 1000); - if (NOW - ageOfRealm > MAX_REALM_LIFESPAN) { - // First, delete all clusters associated with this realm. - const clustersRequest = { - parent: realm.name, - }; - - const clustersResult = - await gameServerClusterClient.listGameServerClusters(clustersRequest); - const [clusters] = clustersResult; - for (const cluster of clusters) { - const deleteClusterRequest = { - name: cluster.name, - }; - - const [deleteClusterOperation] = - await gameServerClusterClient.deleteGameServerCluster( - deleteClusterRequest - ); - await deleteClusterOperation.promise(); - } - - // Then delete the realm itself. - const realmDeleteRequest = { - name: realm.name, - }; - - const [deleteRealmOperation] = - await realmsClient.deleteRealm(realmDeleteRequest); - await deleteRealmOperation.promise(); - } - } -}; diff --git a/game-servers/snippets/test/create_cluster.test.js b/game-servers/snippets/test/create_cluster.test.js deleted file mode 100644 index aef6e5761f..0000000000 --- a/game-servers/snippets/test/create_cluster.test.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const { - RealmsServiceClient, - GameServerClustersServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; -const GKE_CLUSTER_NAME = - process.env.SAMPLE_CLUSTER_NAME || - 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; - -describe('Game Servers Create Cluster Test', () => { - const realmsClient = new RealmsServiceClient(); - const gameClustersClient = new GameServerClustersServiceClient(); - let realmId, gameClusterId; - - before(async () => { - await cleanup(); - - // Create a realm - const projectId = await realmsClient.getProjectId(); - realmId = `create-realm-${uuid.v4()}`; - gameClusterId = `test-${uuid.v4()}`; - - const request = { - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Server realm', - }, - }; - - const [operation] = await realmsClient.createRealm(request); - await operation.promise(); - }); - - it('should create a Game Server cluster', async () => { - const projectId = await realmsClient.getProjectId(); - gameClusterId = `test-${uuid.v4()}`; - - const create_output = execSync( - `node create_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId} ${GKE_CLUSTER_NAME}` - ); - assert.match(create_output, /Cluster name:/); - }); - - after(async () => { - const projectId = await realmsClient.getProjectId(); - - // Delete the Game Server cluster - const deleteClusterRequest = { - // Provide full resource name of a Game Server Realm - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, - }; - const [operation1] = - await gameClustersClient.deleteGameServerCluster(deleteClusterRequest); - await operation1.promise(); - - // Delete the realm - const deleteRealmRequest = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); - await operation2.promise(); - }); -}); diff --git a/game-servers/snippets/test/create_realm.test.js b/game-servers/snippets/test/create_realm.test.js deleted file mode 100644 index 93a49344e7..0000000000 --- a/game-servers/snippets/test/create_realm.test.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, before, it, after} = require('mocha'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; - -describe('Game Servers Create Realm Test', () => { - const client = new RealmsServiceClient(); - let realmId; - - before(async () => { - await cleanup(); - }); - - it('should create a realm', async () => { - const projectId = await client.getProjectId(); - realmId = `test-${uuid.v4()}`; - - const create_output = execSync( - `node create_realm.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(create_output, /Realm time zone:/); - }); - - after(async () => { - const projectId = await client.getProjectId(); - const request = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation] = await client.deleteRealm(request); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/crud_config.test.js b/game-servers/snippets/test/crud_config.test.js deleted file mode 100644 index dd199b1db6..0000000000 --- a/game-servers/snippets/test/crud_config.test.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, before, after, it} = require('mocha'); -const { - GameServerConfigsServiceClient, - GameServerDeploymentsServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -describe('Game Server Config Test', () => { - const client = new GameServerConfigsServiceClient(); - const deploymentClient = new GameServerDeploymentsServiceClient(); - let deploymentId; - let configId; - let projectId; - - before(async () => { - await cleanup(); - - projectId = await client.getProjectId(); - deploymentId = `test-${uuid.v4()}`; - configId = `test-${uuid.v4()}`; - - const request = { - parent: `projects/${projectId}/locations/global`, - deploymentId: deploymentId, - }; - const [operation] = - await deploymentClient.createGameServerDeployment(request); - await operation.promise(); - }); - - it('should create a game server config', async () => { - const create_output = execSync( - `node create_config.js ${projectId} ${deploymentId} ${configId} nodejs_fleet_name` - ); - assert.match(create_output, /Config name:/); - }); - - it('should get a game server config', async () => { - const get_output = execSync( - `node get_config.js ${projectId} ${deploymentId} ${configId}` - ); - assert.match(get_output, /Config name:/); - }); - - it('should list a game server config', async () => { - const list_output = execSync( - `node list_configs.js ${projectId} ${deploymentId} ${configId}` - ); - assert.match(list_output, /Config name:/); - }); - - it('should delete a game server config', async () => { - const delete_output = execSync( - `node delete_config.js ${projectId} ${deploymentId} ${configId}` - ); - assert.match(delete_output, /deleted./); - }); - - after(async () => { - // Delete the Game Server Deployment - const request = { - // Provide full resource name of a Game Server Deployment - name: deploymentClient.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - }; - const [operation] = - await deploymentClient.deleteGameServerDeployment(request); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/crud_deployment.test.js b/game-servers/snippets/test/crud_deployment.test.js deleted file mode 100644 index 5dd7218b30..0000000000 --- a/game-servers/snippets/test/crud_deployment.test.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, before, it} = require('mocha'); -const { - GameServerDeploymentsServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -describe('Game Server Deployment Test', () => { - const client = new GameServerDeploymentsServiceClient(); - let deploymentId; - let projectId; - - before(async () => { - projectId = await client.getProjectId(); - deploymentId = `test-${uuid.v4()}`; - - await cleanup(); - }); - - it('should create a game server deployment', async () => { - const create_output = execSync( - `node create_deployment.js ${projectId} ${deploymentId}` - ); - assert.match(create_output, /Deployment name:/); - }); - - it('should update a game server deployment', async () => { - const update_output = execSync( - `node update_deployment.js ${projectId} ${deploymentId}` - ); - assert.match(update_output, /Deployment updated:/); - }); - - it('should get a game server deployment', async () => { - const get_output = execSync( - `node get_deployment.js ${projectId} ${deploymentId}` - ); - assert.match(get_output, /Deployment name:/); - assert.match( - get_output, - /Deployment description: My updated Game Server deployment/ - ); - }); - - it('should list a game server deployment', async () => { - const list_output = execSync( - `node list_deployments.js ${projectId} ${deploymentId}` - ); - assert.match(list_output, /Deployment name:/); - }); - - it('should delete a game server deployment', async () => { - const delete_output = execSync( - `node delete_deployment.js ${projectId} ${deploymentId}` - ); - assert.match(delete_output, /deleted./); - }); -}); diff --git a/game-servers/snippets/test/delete_cluster.test.js b/game-servers/snippets/test/delete_cluster.test.js deleted file mode 100644 index d92259bcad..0000000000 --- a/game-servers/snippets/test/delete_cluster.test.js +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const { - RealmsServiceClient, - GameServerClustersServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; -const GKE_CLUSTER_NAME = - process.env.SAMPLE_CLUSTER_NAME || - 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; - -describe('Game Servers Delete Cluster Test', () => { - const realmsClient = new RealmsServiceClient(); - const gameClustersClient = new GameServerClustersServiceClient(); - let projectId, realmId, gameClusterId; - - before(async () => { - await cleanup(); - - // Create a realm - projectId = await realmsClient.getProjectId(); - realmId = `delete-realm-${uuid.v4()}`; - gameClusterId = `test-${uuid.v4()}`; - - const createRealmRequest = { - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Server realm', - }, - }; - - const [operation1] = await realmsClient.createRealm(createRealmRequest); - await operation1.promise(); - - // Create a cluster - const createClusterRequest = { - parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - gameServerClusterId: gameClusterId, - gameServerCluster: { - description: 'My Game Server Cluster', - connectionInfo: { - gkeClusterReference: { - // Provide full resource name of a Kubernetes Engine cluster - cluster: GKE_CLUSTER_NAME, - }, - namespace: 'default', - }, - }, - }; - - const [operation2] = - await gameClustersClient.createGameServerCluster(createClusterRequest); - await operation2.promise(); - }); - - it('should delete a Game Server cluster in a realm', async () => { - const create_output = execSync( - `node delete_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` - ); - assert.match(create_output, /Game Server cluster deleted/); - }); - - after(async () => { - // Delete the realm - const deleteRealmRequest = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation] = await realmsClient.deleteRealm(deleteRealmRequest); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/delete_realm.test.js b/game-servers/snippets/test/delete_realm.test.js deleted file mode 100644 index 915aa83b8e..0000000000 --- a/game-servers/snippets/test/delete_realm.test.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before} = require('mocha'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; - -describe('Game Servers Delete Realm Test', () => { - const client = new RealmsServiceClient(); - let realmId; - - before(async () => { - const projectId = await client.getProjectId(); - - // Clean up any stray realms - await cleanup(); - - realmId = `test-${uuid.v4()}`; - - await client.createRealm({ - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Realm', - }, - }); - }); - - it('should delete a realm', async () => { - const projectId = await client.getProjectId(); - - const delete_output = execSync( - `node delete_realm.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(delete_output, /deleted./); - }); -}); diff --git a/game-servers/snippets/test/get_cluster.test.js b/game-servers/snippets/test/get_cluster.test.js deleted file mode 100644 index 6a49547381..0000000000 --- a/game-servers/snippets/test/get_cluster.test.js +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const { - RealmsServiceClient, - GameServerClustersServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; -const GKE_CLUSTER_NAME = - process.env.SAMPLE_CLUSTER_NAME || - 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; - -describe('Game Servers Get Cluster Test', () => { - const realmsClient = new RealmsServiceClient(); - const gameClustersClient = new GameServerClustersServiceClient(); - let realmId, gameClusterId; - - before(async () => { - await cleanup(); - - // Create a realm - const projectId = await realmsClient.getProjectId(); - realmId = `get-realm-${uuid.v4()}`; - gameClusterId = `test-${uuid.v4()}`; - - const createRealmRequest = { - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Server realm', - }, - }; - - const [operation1] = await realmsClient.createRealm(createRealmRequest); - await operation1.promise(); - - // Create a cluster - const createClusterRequest = { - parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - gameServerClusterId: gameClusterId, - gameServerCluster: { - description: 'My Game Server Cluster', - connectionInfo: { - gkeClusterReference: { - // Provide full resource name of a Kubernetes Engine cluster - cluster: GKE_CLUSTER_NAME, - }, - namespace: 'default', - }, - }, - }; - - const [operation2] = - await gameClustersClient.createGameServerCluster(createClusterRequest); - await operation2.promise(); - }); - - it('should get a Game Server cluster in a realm', async () => { - const projectId = await realmsClient.getProjectId(); - - const create_output = execSync( - `node get_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` - ); - assert.match(create_output, /Cluster name:/); - }); - - after(async () => { - const projectId = await realmsClient.getProjectId(); - - // Delete the Game Server cluster - const deleteClusterRequest = { - // Provide full resource name of a Game Server Realm - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, - }; - const [operation1] = - await gameClustersClient.deleteGameServerCluster(deleteClusterRequest); - await operation1.promise(); - - // Delete the realm - const deleteRealmRequest = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); - await operation2.promise(); - }); -}); diff --git a/game-servers/snippets/test/get_realm.test.js b/game-servers/snippets/test/get_realm.test.js deleted file mode 100644 index 43b6ecb494..0000000000 --- a/game-servers/snippets/test/get_realm.test.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; - -describe('Game Servers Get Realms Test', () => { - const client = new RealmsServiceClient(); - let realmId; - - before(async () => { - const projectId = await client.getProjectId(); - - // Clean up any stray realms - await cleanup(); - - realmId = `test-${uuid.v4()}`; - - await client.createRealm({ - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Realm', - }, - }); - }); - - it('should get a realm', async () => { - const projectId = await client.getProjectId(); - - const get_output = execSync( - `node get_realm.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(get_output, /Realm description:/); - }); - - after(async () => { - const projectId = await client.getProjectId(); - const request = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation] = await client.deleteRealm(request); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/list_clusters.test.js b/game-servers/snippets/test/list_clusters.test.js deleted file mode 100644 index 005c777977..0000000000 --- a/game-servers/snippets/test/list_clusters.test.js +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const { - RealmsServiceClient, - GameServerClustersServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; -const GKE_CLUSTER_NAME = - process.env.SAMPLE_CLUSTER_NAME || - 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; - -describe('Game Servers List Clusters Test', () => { - const realmsClient = new RealmsServiceClient(); - const gameClustersClient = new GameServerClustersServiceClient(); - let realmId, gameClusterId; - - before(async () => { - await cleanup(); - - // Create a realm - const projectId = await realmsClient.getProjectId(); - realmId = `list-realm-${uuid.v4()}`; - gameClusterId = `test-${uuid.v4()}`; - - const createRealmRequest = { - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Server realm', - }, - }; - - const [operation1] = await realmsClient.createRealm(createRealmRequest); - await operation1.promise(); - - // Create a cluster - const createClusterRequest = { - parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - gameServerClusterId: gameClusterId, - gameServerCluster: { - description: 'My Game Server Cluster', - connectionInfo: { - gkeClusterReference: { - // Provide full resource name of a Kubernetes Engine cluster - cluster: GKE_CLUSTER_NAME, - }, - namespace: 'default', - }, - }, - }; - - const [operation2] = - await gameClustersClient.createGameServerCluster(createClusterRequest); - await operation2.promise(); - }); - - it('should list Game Server clusters in a realm', async () => { - const projectId = await realmsClient.getProjectId(); - - const create_output = execSync( - `node list_clusters.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(create_output, /Cluster name:/); - }); - - after(async () => { - const projectId = await realmsClient.getProjectId(); - - // Delete the Game Server cluster - const deleteClusterRequest = { - // Provide full resource name of a Game Server Realm - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, - }; - const [operation1] = - await gameClustersClient.deleteGameServerCluster(deleteClusterRequest); - await operation1.promise(); - - // Delete the realm - const deleteRealmRequest = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); - await operation2.promise(); - }); -}); diff --git a/game-servers/snippets/test/list_realms.test.js b/game-servers/snippets/test/list_realms.test.js deleted file mode 100644 index 574b6a5187..0000000000 --- a/game-servers/snippets/test/list_realms.test.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; - -describe('Game Servers List Realms Test', () => { - const client = new RealmsServiceClient(); - let realmId; - - before(async () => { - const projectId = await client.getProjectId(); - - // Clean up any stray realms - await cleanup(); - - realmId = `test-${uuid.v4()}`; - - await client.createRealm({ - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Realm', - }, - }); - }); - - it('should list realms', async () => { - const projectId = await client.getProjectId(); - - const list_output = execSync( - `node list_realms.js ${projectId} ${LOCATION}` - ); - assert.match(list_output, /Realm name:/); - }); - - after(async () => { - const projectId = await client.getProjectId(); - const request = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation] = await client.deleteRealm(request); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/quickstart.js b/game-servers/snippets/test/quickstart.js deleted file mode 100644 index e9faf4f075..0000000000 --- a/game-servers/snippets/test/quickstart.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -const {assert} = require('chai'); -const cp = require('child_process'); -const {describe, it, after, before} = require('mocha'); -const uuid = require('uuid'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -describe('Quickstart', () => { - let projectId; - let client; - const location = 'us-central1'; - const realmId = `realm-${uuid.v4().split('-')[0]}`; - - before(async () => { - client = new RealmsServiceClient(); - projectId = await client.getProjectId(); - }); - - it('should run quickstart', async () => { - const stdout = execSync( - `node quickstart.js ${projectId} ${location} ${realmId}` - ); - assert.include(stdout, 'Realm created:'); - }); - - after(async () => { - const [operation] = await client.deleteRealm({ - name: client.realmPath(projectId, location, realmId), - }); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/quickstart.test.js b/game-servers/snippets/test/quickstart.test.js deleted file mode 100644 index 8d370fa7d5..0000000000 --- a/game-servers/snippets/test/quickstart.test.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; - -describe('Game Servers Quickstart Test', () => { - const client = new RealmsServiceClient(); - let realmId; - - before(async () => { - await cleanup(); - }); - - it('should create a realm', async () => { - const projectId = await client.getProjectId(); - realmId = `test-${uuid.v4()}`; - - const quickstart_output = execSync( - `node quickstart.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(quickstart_output, /Realm time zone:/); - }); - - after(async () => { - const projectId = await client.getProjectId(); - const request = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation] = await client.deleteRealm(request); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/test/rollout.js b/game-servers/snippets/test/rollout.js deleted file mode 100644 index d5a79e752d..0000000000 --- a/game-servers/snippets/test/rollout.js +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, before, after, it} = require('mocha'); -const { - GameServerConfigsServiceClient, - GameServerDeploymentsServiceClient, - RealmsServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -describe('Game Server Rollout Test', () => { - const configClient = new GameServerConfigsServiceClient(); - const deploymentClient = new GameServerDeploymentsServiceClient(); - const realmClient = new RealmsServiceClient(); - let projectId; - const deploymentId = `test-nodejs-${uuid.v4()}`; - const configId = `test-nodejs-${uuid.v4()}`; - const realmId = `test-nodejs-${uuid.v4()}`; - const realmLocation = 'us-central1'; - - before(async () => { - await cleanup(); - - projectId = await deploymentClient.getProjectId(); - - const request = { - parent: `projects/${projectId}/locations/global`, - deploymentId: deploymentId, - }; - const [operation] = - await deploymentClient.createGameServerDeployment(request); - await operation.promise(); - - const request2 = { - parent: configClient.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - configId: configId, - }; - const [operation2] = await configClient.createGameServerConfig(request2); - await operation2.promise(); - - const request3 = { - parent: `projects/${projectId}/locations/${realmLocation}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Server realm', - }, - }; - - const [operation3] = await realmClient.createRealm(request3); - await operation3.promise(); - }); - - it('should update rollout default', async () => { - const updateDefaultOutput = execSync( - `node update_rollout_default.js ${projectId} ${deploymentId} ${configId}` - ); - - assert.match(updateDefaultOutput, /Deployment updated:/); - - const getRolloutOutput = execSync( - `node get_rollout.js ${projectId} ${deploymentId} ${configId}` - ); - - const configName = configClient.gameServerConfigPath( - projectId, - 'global', - deploymentId, - configId - ); - assert.match(getRolloutOutput, /Rollout name:/); - assert.match( - getRolloutOutput, - new RegExp(`Rollout default: ${configName}`) - ); - }); - - it('should remove rollout default', async () => { - const removeDefaultOutput = execSync( - `node update_rollout_remove_default.js ${projectId} ${deploymentId} ${configId}` - ); - - assert.match(removeDefaultOutput, /Deployment updated:/); - - const request = { - // The full resource name - name: deploymentClient.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - }; - - const [rollout] = - await deploymentClient.getGameServerDeploymentRollout(request); - assert.strictEqual(rollout.defaultGameServerConfig, ''); - }); - - it('should update rollout override', async () => { - const updateOverrideOutput = execSync( - `node update_rollout_override.js ${projectId} ${deploymentId} ${configId} ${realmId} ${realmLocation}` - ); - assert.match(updateOverrideOutput, /Deployment updated:/); - - const getRolloutOutput = execSync( - `node get_rollout.js ${projectId} ${deploymentId} ${configId}` - ); - - const configName = configClient.gameServerConfigPath( - projectId, - 'global', - deploymentId, - configId - ); - const realmName = realmClient.realmPath(projectId, realmLocation, realmId); - assert.match( - getRolloutOutput, - new RegExp(`Rollout config overrides: .*${configName}`) - ); - assert.match(getRolloutOutput, new RegExp(realmName)); - }); - - it('should remove rollout override', async () => { - const removeOverrideOutput = execSync( - `node update_rollout_remove_override.js ${projectId} ${deploymentId}` - ); - - assert.match(removeOverrideOutput, /Deployment updated:/); - - const request = { - // The full resource name - name: deploymentClient.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - }; - - let rollout; - try { - [rollout] = - await deploymentClient.getGameServerDeploymentRollout(request); - } catch (err) { - if (err.message.includes(/The service is currently unavailable/)) { - return; - } - throw err; - } - - assert.strictEqual(rollout.gameServerConfigOverrides.length, 0); - }); - - after(async () => { - // Delete the Game Server Config - const request = { - // Provide full resource name of a Game Server Config - name: configClient.gameServerConfigPath( - projectId, - 'global', - deploymentId, - configId - ), - }; - const [operation] = await configClient.deleteGameServerConfig(request); - await operation.promise(); - - // Delete the Game Server Deployment - const request2 = { - // Provide full resource name of a Game Server Deployment - name: deploymentClient.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - }; - const [operation2] = - await deploymentClient.deleteGameServerDeployment(request2); - await operation2.promise(); - - // Delete the Realm - const request3 = { - // Provide full resource name of a Realm - name: realmClient.realmPath(projectId, realmLocation, realmId), - }; - const [operation3] = await realmClient.deleteRealm(request3); - await operation3.promise(); - }); -}); diff --git a/game-servers/snippets/test/update_cluster_test.js b/game-servers/snippets/test/update_cluster_test.js deleted file mode 100644 index b55634bda0..0000000000 --- a/game-servers/snippets/test/update_cluster_test.js +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const { - RealmsServiceClient, - GameServerClustersServiceClient, -} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; -const GKE_CLUSTER_NAME = - process.env.SAMPLE_CLUSTER_NAME || - 'projects/217093627905/locations/us-central1/clusters/gke-shared-default'; - -describe('Game Servers Update Cluster Test', () => { - const realmsClient = new RealmsServiceClient(); - const gameClustersClient = new GameServerClustersServiceClient(); - let realmId, gameClusterId, projectId; - - before(async () => { - await cleanup(); - - // Create a realm - projectId = await realmsClient.getProjectId(); - realmId = `update-realm-${uuid.v4()}`; - gameClusterId = `test-${uuid.v4()}`; - - const createRealmRequest = { - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Server realm', - }, - }; - - const [operation1] = await realmsClient.createRealm(createRealmRequest); - await operation1.promise(); - - // Create a cluster - const createClusterRequest = { - parent: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - gameServerClusterId: gameClusterId, - gameServerCluster: { - description: 'My Game Server Cluster', - connectionInfo: { - gkeClusterReference: { - // Provide full resource name of a Kubernetes Engine cluster - cluster: GKE_CLUSTER_NAME, - }, - namespace: 'default', - }, - }, - }; - - const [operation2] = - await gameClustersClient.createGameServerCluster(createClusterRequest); - await operation2.promise(); - }); - - it('should update a Game Server cluster in a realm', async () => { - const update_output = execSync( - `node update_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` - ); - assert.match(update_output, /Cluster updated:/); - - const get_output = execSync( - `node get_cluster.js ${projectId} ${LOCATION} ${realmId} ${gameClusterId}` - ); - assert.match( - get_output, - /Cluster description: My updated Game Server Cluster/ - ); - }); - - after(async () => { - // Delete the Game Server cluster - const deleteClusterRequest = { - // Provide full resource name of a Game Server Realm - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}/gameServerClusters/${gameClusterId}`, - }; - const [operation1] = - await gameClustersClient.deleteGameServerCluster(deleteClusterRequest); - await operation1.promise(); - - // Delete the realm - const deleteRealmRequest = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation2] = await realmsClient.deleteRealm(deleteRealmRequest); - await operation2.promise(); - }); -}); diff --git a/game-servers/snippets/test/update_realm_test.js b/game-servers/snippets/test/update_realm_test.js deleted file mode 100644 index f55ae28291..0000000000 --- a/game-servers/snippets/test/update_realm_test.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -const {assert} = require('chai'); -const cleanup = require('./clean.js'); -const {describe, it, before, after} = require('mocha'); -const {RealmsServiceClient} = require('@google-cloud/game-servers'); - -const cp = require('child_process'); -const uuid = require('uuid'); - -const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); - -const LOCATION = 'us-central1'; - -describe('Game Servers Update Realms Test', () => { - const client = new RealmsServiceClient(); - let realmId, projectId; - - before(async () => { - projectId = await client.getProjectId(); - - // Clean up any stray realms - await cleanup(); - - realmId = `test-${uuid.v4()}`; - - await client.createRealm({ - parent: `projects/${projectId}/locations/${LOCATION}`, - realmId: realmId, - realm: { - timeZone: 'US/Pacific', - description: 'Test Game Realm', - }, - }); - }); - - it('should update a realm', async () => { - const update_output = execSync( - `node update_realm.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(update_output, /Realm updated:/); - - const get_output = execSync( - `node get_realm.js ${projectId} ${LOCATION} ${realmId}` - ); - assert.match(get_output, /Realm description: My updated Game Server realm/); - }); - - after(async () => { - const request = { - name: `projects/${projectId}/locations/${LOCATION}/realms/${realmId}`, - }; - const [operation] = await client.deleteRealm(request); - await operation.promise(); - }); -}); diff --git a/game-servers/snippets/update_cluster.js b/game-servers/snippets/update_cluster.js deleted file mode 100644 index b07342fc39..0000000000 --- a/game-servers/snippets/update_cluster.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2021, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Update a Game Servers cluster. - * @param {string} projectId string project identifier - * @param {string} location Compute Engine region for the realm - * @param {string} realmId the realm to use - * @param {string} gameClusterId unique identifier for the Game Cluster - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID', - gameClusterId = 'GAME_CLUSTER_ID' -) { - // [START cloud_game_servers_cluster_update] - const { - GameServerClustersServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerClustersServiceClient(); - - async function updateGameServerCluster() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'The ID of the realm of this cluster'; - // const gameClusterId = 'A unique ID for this Game Server Cluster'; - const request = { - // Provide full resource name of a Game Server Cluster - gameServerCluster: { - name: client.gameServerClusterPath( - projectId, - location, - realmId, - gameClusterId - ), - labels: { - 'label-key-1': 'label-value-1', - }, - description: 'My updated Game Server Cluster', - }, - updateMask: { - paths: ['labels', 'description'], - }, - }; - - const [operation] = await client.updateGameServerCluster(request); - const [result] = await operation.promise(); - - console.log(`Cluster updated: ${result.name}`); - } - - updateGameServerCluster(); - // [END cloud_game_servers_cluster_update] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/update_deployment.js b/game-servers/snippets/update_deployment.js deleted file mode 100644 index dde260eacf..0000000000 --- a/game-servers/snippets/update_deployment.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2021, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Update a Game Servers Deployment. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_deployment_update] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function updateGameServerDeployment() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'The unique ID for the Game Server Deployment'; - const request = { - gameServerDeployment: { - name: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - labels: { - 'label-key-1': 'label-value-1', - }, - description: 'My updated Game Server deployment', - }, - updateMask: { - paths: ['labels', 'description'], - }, - }; - - const [operation] = await client.updateGameServerDeployment(request); - const [result] = await operation.promise(); - - console.log(`Deployment updated: ${result.name}`); - } - - updateGameServerDeployment(); - - // [END cloud_game_servers_deployment_update] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/update_realm.js b/game-servers/snippets/update_realm.js deleted file mode 100644 index ffdd19a817..0000000000 --- a/game-servers/snippets/update_realm.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2021, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Update a Game Servers realm. - * @param {string} projectId string project identifier. - * @param {string} location Compute Engine region. - * @param {string} realmId unique identifier for the realm - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - location = 'LOCATION_ID', - realmId = 'REALM_ID' -) { - // [START cloud_game_servers_realm_update] - const {RealmsServiceClient} = require('@google-cloud/game-servers'); - - const client = new RealmsServiceClient(); - - async function updateRealm() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const location = 'A Compute Engine region, e.g. "us-central1"'; - // const realmId = 'The unique identifier for the realm'; - const request = { - realm: { - name: client.realmPath(projectId, location, realmId), - labels: { - 'label-key-1': 'label-value-1', - }, - timeZone: 'US/Pacific', - description: 'My updated Game Server realm', - }, - updateMask: { - paths: ['labels', 'time_zone', 'description'], - }, - }; - - const [operation] = await client.updateRealm(request); - const results = await operation.promise(); - const [realm] = results; - - console.log(`Realm updated: ${realm.name}`); - } - - updateRealm(); - // [END cloud_game_servers_realm_update] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/update_rollout_default.js b/game-servers/snippets/update_rollout_default.js deleted file mode 100644 index 1aa9edf372..0000000000 --- a/game-servers/snippets/update_rollout_default.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Rollout update to add default config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - * @param {string} configId unique identifier for the new Game Server Config - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID', - configId = 'CONFIG_ID' -) { - // [START cloud_game_servers_deployment_rollout_default] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function rolloutDefaultGameServerDeployment() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - // const configId = 'A unique ID for the Game Server Config'; - const request = { - rollout: { - name: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - defaultGameServerConfig: configId, - }, - updateMask: { - paths: ['default_game_server_config'], - }, - }; - - const [operation] = await client.updateGameServerDeploymentRollout(request); - const [deployment] = await operation.promise(); - - console.log(`Deployment updated: ${deployment.name}`); - } - - rolloutDefaultGameServerDeployment(); - - // [END cloud_game_servers_deployment_rollout_default] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/update_rollout_override.js b/game-servers/snippets/update_rollout_override.js deleted file mode 100644 index ee27d4b738..0000000000 --- a/game-servers/snippets/update_rollout_override.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Rollout update to add override config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - * @param {string} configId unique identifier for the new Game Server Config - * @param {string} realmId the unique ID of the realm - * @param {string} realmLocation Compute Engine region for realm location. - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID', - configId = 'CONFIG_ID', - realmId = 'REALM_ID', - realmLocation = 'REALM_LOCATION' -) { - // [START cloud_game_servers_deployment_rollout_override] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function rolloutGameServerDeploymentOverride() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - // const configId = 'A unique ID for the Game Server Config'; - // const realmId = 'A unique ID for the realm' - // const realmLocation = 'compute engine region for realm location' - const request = { - rollout: { - name: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - gameServerConfigOverrides: [ - { - realmsSelector: { - realms: [client.realmPath(projectId, realmLocation, realmId)], - }, - configVersion: configId, - }, - ], - }, - updateMask: { - paths: ['game_server_config_overrides'], - }, - }; - - const [operation] = await client.updateGameServerDeploymentRollout(request); - const [deployment] = await operation.promise(); - - console.log(`Deployment updated: ${deployment.name}`); - } - - rolloutGameServerDeploymentOverride(); - - // [END cloud_game_servers_deployment_rollout_override] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/update_rollout_remove_default.js b/game-servers/snippets/update_rollout_remove_default.js deleted file mode 100644 index 7584a00bfc..0000000000 --- a/game-servers/snippets/update_rollout_remove_default.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Rollout update to remove default config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_deployment_rollout_remove_default] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function removeRolloutDefaultGameServerDeployment() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - rollout: { - name: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - defaultGameServerConfig: '', - }, - updateMask: { - paths: ['default_game_server_config'], - }, - }; - - const [operation] = await client.updateGameServerDeploymentRollout(request); - const [deployment] = await operation.promise(); - - console.log(`Deployment updated: ${deployment.name}`); - } - - removeRolloutDefaultGameServerDeployment(); - - // [END cloud_game_servers_deployment_rollout_remove_default] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); diff --git a/game-servers/snippets/update_rollout_remove_override.js b/game-servers/snippets/update_rollout_remove_override.js deleted file mode 100644 index 031e950c01..0000000000 --- a/game-servers/snippets/update_rollout_remove_override.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2020, Google LLC. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -'use strict'; - -/** - * Rollout update to remove override config. - * @param {string} projectId string project identifier - * @param {string} deploymentId unique identifier for the new Game Server Deployment - */ -async function main( - projectId = 'YOUR_PROJECT_ID', - deploymentId = 'DEPLOYMENT_ID' -) { - // [START cloud_game_servers_deployment_rollout_remove_override] - const { - GameServerDeploymentsServiceClient, - } = require('@google-cloud/game-servers'); - - const client = new GameServerDeploymentsServiceClient(); - - async function removeRolloutGameServerDeploymentOverride() { - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'Your Google Cloud Project ID'; - // const deploymentId = 'A unique ID for the Game Server Deployment'; - const request = { - rollout: { - name: client.gameServerDeploymentPath( - projectId, - 'global', - deploymentId - ), - }, - updateMask: { - paths: ['game_server_config_overrides'], - }, - }; - - const [operation] = await client.updateGameServerDeploymentRollout(request); - const [deployment] = await operation.promise(); - - console.log(`Deployment updated: ${deployment.name}`); - } - - removeRolloutGameServerDeploymentOverride(); - - // [END cloud_game_servers_deployment_rollout_remove_override] -} - -main(...process.argv.slice(2)).catch(err => { - console.error(err.message); - process.exitCode = 1; -}); -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -});