diff --git a/build/build-sdk-images/node/gen.sh b/build/build-sdk-images/node/gen.sh index 7931e08f99..1841f5fb82 100644 --- a/build/build-sdk-images/node/gen.sh +++ b/build/build-sdk-images/node/gen.sh @@ -23,11 +23,20 @@ header() { sdk=/go/src/agones.dev/agones/proto/sdk googleapis=/go/src/agones.dev/agones/proto/googleapis +mkdir -p ./sdks/nodejs/lib/alpha + cd /go/src/agones.dev/agones grpc_tools_node_protoc --proto_path=${googleapis} --proto_path=${sdk} --js_out=import_style=commonjs,binary:./sdks/nodejs/lib google/api/annotations.proto google/api/http.proto +grpc_tools_node_protoc --proto_path=${googleapis} --proto_path=${sdk}/alpha --js_out=import_style=commonjs,binary:./sdks/nodejs/lib/alpha google/api/annotations.proto google/api/http.proto + grpc_tools_node_protoc --proto_path=${googleapis} --proto_path=${sdk} --grpc_out=generate_package_definition:./sdks/nodejs/lib --js_out=import_style=commonjs,binary:./sdks/nodejs/lib sdk.proto +grpc_tools_node_protoc --proto_path=${googleapis} --proto_path=${sdk}/alpha --grpc_out=generate_package_definition:./sdks/nodejs/lib/alpha --js_out=import_style=commonjs,binary:./sdks/nodejs/lib/alpha alpha.proto header ./sdks/nodejs/lib/sdk_pb.js header ./sdks/nodejs/lib/google/api/annotations_pb.js header ./sdks/nodejs/lib/google/api/http_pb.js + +header ./sdks/nodejs/lib/alpha/alpha_pb.js +header ./sdks/nodejs/lib/alpha/google/api/annotations_pb.js +header ./sdks/nodejs/lib/alpha/google/api/http_pb.js diff --git a/examples/nodejs-simple/Makefile b/examples/nodejs-simple/Makefile index 57e20b3b0f..fcfa590d7d 100644 --- a/examples/nodejs-simple/Makefile +++ b/examples/nodejs-simple/Makefile @@ -38,7 +38,7 @@ root_path = $(realpath $(project_path)/../..) # |_|\__,_|_| \__, |\___|\__|___/ # |___/ -# build the cpp-simple binary +# build the nodejs-simple binary build: cd $(root_path) && docker build -f $(project_path)/Dockerfile --tag=$(server_tag) . diff --git a/examples/nodejs-simple/README.md b/examples/nodejs-simple/README.md index c520810a17..7cc9272885 100644 --- a/examples/nodejs-simple/README.md +++ b/examples/nodejs-simple/README.md @@ -12,6 +12,10 @@ It will: - After the shutdown duration (default 60 seconds), shut the server down - Parse options to get help or set the shutdown timeout duration +If alpha features are enabled it will additionally: +- Set and get the player capacity (this is not enforced) +- Add, get and remove players, and test if they are present + To learn how to deploy this example service to GKE, please see the tutorial [Build and Run a Simple Gameserver (node.js)](https://agones.dev/site/docs/tutorials/simple-gameserver-nodejs/). ## Building @@ -56,7 +60,7 @@ Connecting to the SDK server... ...connected to SDK server ``` -To see help, pass `--help` as the argument (all are equivalent): +To see help, pass `--help` as the argument (use the preferred command below, all are equivalent): ``` $ make args="--help" run $ docker run --network=host gcr.io/agones-images/nodejs-simple-server:0.5 --help @@ -76,4 +80,16 @@ To make run indefinitely use the special timeout value of 0: $ make args="--timeout=0" run $ docker run --network=host gcr.io/agones-images/nodejs-simple-server:0.5 --timeout=0 $ npm start -- --timeout=0 -``` \ No newline at end of file +``` + +To enable alpha features ensure the feature gate is enabled: +```bash +$ cd ../../build; make run-sdk-conformance-local TIMEOUT=120 FEATURE_GATES="PlayerTracking=true" TESTS=ready,watch,health,gameserver +``` + +Then enable the alpha suite: +``` +$ make args="--alpha" run +$ docker run --network=host gcr.io/agones-images/nodejs-simple-server:0.5 --alpha +$ npm start -- --alpha +``` diff --git a/examples/nodejs-simple/package-lock.json b/examples/nodejs-simple/package-lock.json index a7baa5d5bf..bff7d236eb 100644 --- a/examples/nodejs-simple/package-lock.json +++ b/examples/nodejs-simple/package-lock.json @@ -3,31 +3,120 @@ "lockfileVersion": 1, "dependencies": { "@google-cloud/agones-sdk": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@google-cloud/agones-sdk/-/agones-sdk-1.6.0.tgz", - "integrity": "sha512-p2M0Y3ADf1f6uXrBb+FXPOGkQhpaQJtN3eURT0BIVohVPZOoqYtWpqhfvQVX7mL8BtKnjd/WFYAiNGc60vMSgw==", - "requires": { - "@grpc/grpc-js": "1.0.3", - "google-protobuf": "3.11.4" + "version": "file:../../sdks/nodejs", + "dependencies": { + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "resolve-from": { + "version": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" + }, + "rimraf": { + "version": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==" + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" + }, + "source-map": { + "version": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "supports-color": { + "version": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==" + } } - }, - "@grpc/grpc-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.0.3.tgz", - "integrity": "sha512-JKV3f5Bv2TZxK6eJSB9EarsZrnLxrvcFNwI9goq0YRXa3S6NNoCSnI3cG3lkXVIJ03Wng1WXe76kc2JQtRe7AQ==", - "requires": { - "semver": "^6.2.0" - } - }, - "google-protobuf": { - "version": "3.11.4", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.11.4.tgz", - "integrity": "sha512-lL6b04rDirurUBOgsY2+LalI6Evq8eH5TcNzi7TYQ3BsIWelT0KSOQSBsXuavEkNf+odQU6c0lgz3UsZXeNX9Q==" - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" } } } diff --git a/examples/nodejs-simple/package.json b/examples/nodejs-simple/package.json index 28074863bd..158cac3604 100644 --- a/examples/nodejs-simple/package.json +++ b/examples/nodejs-simple/package.json @@ -1,7 +1,8 @@ { "dependencies": { - "@google-cloud/agones-sdk": "1.6.0" + "@google-cloud/agones-sdk": "file:../../sdks/nodejs" }, + "description": "replace @google-cloud/agones-sdk dependency with the latest version once published", "scripts": { "start": "node src/index.js" } diff --git a/examples/nodejs-simple/src/index.js b/examples/nodejs-simple/src/index.js index fa454b57d3..8bcda3fb3d 100644 --- a/examples/nodejs-simple/src/index.js +++ b/examples/nodejs-simple/src/index.js @@ -17,12 +17,12 @@ const util = require('util'); const sleep = util.promisify(setTimeout); -const agonesSDK = new AgonesSDK(); - const DEFAULT_TIMEOUT = 60; const MAX_TIMEOUT = 2147483; -const connect = async (timeout) => { +const connect = async (timeout, enableAlpha) => { + let agonesSDK = new AgonesSDK(); + let lifetimeInterval; let healthInterval; @@ -41,7 +41,16 @@ const connect = async (timeout) => { console.log('Health ping sent'); }, 20000); agonesSDK.watchGameServer((result) => { - console.log(`GameServer Update:\n\tname: ${result.objectMeta.name}\n\tstate: ${result.status.state}\n\tlabels: ${result.objectMeta.labelsMap.join(' & ')}\n\tannotations: ${result.objectMeta.annotationsMap.join(' & ')}`); + let output = `GameServer Update: + name: ${result.objectMeta.name} + state: ${result.status.state} + labels: ${result.objectMeta.labelsMap.join(' & ')} + annotations: ${result.objectMeta.annotationsMap.join(' & ')}`; + if (enableAlpha) { + output += ` + players: ${result.status.players.count}/${result.status.players.capacity} [${result.status.players.idsList}]`; + } + console.log(output); }); await sleep(10000); @@ -65,6 +74,11 @@ const connect = async (timeout) => { await agonesSDK.reserve(10); await sleep(20000); + if (enableAlpha) { + console.log('Running alpha suite'); + await runAlphaSuite(agonesSDK); + } + if (timeout === 0) { do { await sleep(MAX_TIMEOUT); @@ -91,16 +105,72 @@ const connect = async (timeout) => { console.error(error); clearInterval(healthInterval); clearInterval(lifetimeInterval); + process.exit(0); } }; +const runAlphaSuite = async (agonesSDK) => { + await sleep(10000); + console.log('Setting capacity'); + await agonesSDK.alpha.setPlayerCapacity(64); + + await sleep(10000); + console.log('Getting capacity'); + let result = await agonesSDK.alpha.getPlayerCapacity(); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Connecting a player'); + result = await agonesSDK.alpha.playerConnect('firstPlayerID'); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Connecting a duplicate player'); + result = await agonesSDK.alpha.playerConnect('firstPlayerID'); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Connecting another player'); + await agonesSDK.alpha.playerConnect('secondPlayerID'); + + await sleep(10000); + console.log('Getting player count'); + result = await agonesSDK.alpha.getPlayerCount(); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Finding if firstPlayerID connected'); + result = await agonesSDK.alpha.isPlayerConnected('firstPlayerID'); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Getting connected players'); + result = await agonesSDK.alpha.getConnectedPlayers(); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Disconnecting a player'); + result = await agonesSDK.alpha.playerDisconnect('firstPlayerID'); + console.log(`result: ${result}`); + + await sleep(10000); + console.log('Disconnecting the same player'); + result = await agonesSDK.alpha.playerDisconnect('firstPlayerID'); + console.log(`result: ${result}`); +}; + let args = process.argv.slice(2); let timeout = DEFAULT_TIMEOUT; +let enableAlpha = false; for (let arg of args) { let [argName, argValue] = arg.split('='); if (argName === '--help') { - console.log(`Example to call each SDK feature in turn. Once complete will call shutdown and close after a default timeout of ${DEFAULT_TIMEOUT} seconds.\n\nOptions:\n\t--timeout=...\t\tshutdown timeout in seconds. Use 0 to never shut down`); + console.log(`Example to call each SDK feature in turn. Once complete will call shutdown and close after a default timeout of ${DEFAULT_TIMEOUT} seconds. + +Options: + --timeout=...\t\tshutdown timeout in seconds. Use 0 to never shut down + --alpha\t\t\tenable alpha features`); return; } if (argName === '--timeout') { @@ -116,6 +186,11 @@ for (let arg of args) { console.log(`Using shutdown timeout of ${timeout} seconds`); } } + + if (argName === '--alpha') { + console.log('Enabling alpha features!'); + enableAlpha = true; + } } -connect(timeout); +connect(timeout, enableAlpha); diff --git a/sdks/nodejs/.eslintrc.json b/sdks/nodejs/.eslintrc.json index 87e0f8fdb9..2089352162 100644 --- a/sdks/nodejs/.eslintrc.json +++ b/sdks/nodejs/.eslintrc.json @@ -9,7 +9,9 @@ "ecmaVersion": 2018 }, "rules": { + "indent": ["error", "tab"], "lines-between-class-members": "error", + "quotes": ["error", "single"], "semi": "error", "space-before-blocks": "error" } diff --git a/sdks/nodejs/lib/alpha/alpha_grpc_pb.js b/sdks/nodejs/lib/alpha/alpha_grpc_pb.js new file mode 100644 index 0000000000..0381d978c2 --- /dev/null +++ b/sdks/nodejs/lib/alpha/alpha_grpc_pb.js @@ -0,0 +1,204 @@ +// GENERATED CODE -- DO NOT EDIT! + +// Original file comments: +// Copyright 2020 Google LLC All Rights Reserved. +// +// 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'; +var alpha_pb = require('./alpha_pb.js'); +var google_api_annotations_pb = require('./google/api/annotations_pb.js'); + +function serialize_agones_dev_sdk_alpha_Bool(arg) { + if (!(arg instanceof alpha_pb.Bool)) { + throw new Error('Expected argument of type agones.dev.sdk.alpha.Bool'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_agones_dev_sdk_alpha_Bool(buffer_arg) { + return alpha_pb.Bool.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_agones_dev_sdk_alpha_Count(arg) { + if (!(arg instanceof alpha_pb.Count)) { + throw new Error('Expected argument of type agones.dev.sdk.alpha.Count'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_agones_dev_sdk_alpha_Count(buffer_arg) { + return alpha_pb.Count.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_agones_dev_sdk_alpha_Empty(arg) { + if (!(arg instanceof alpha_pb.Empty)) { + throw new Error('Expected argument of type agones.dev.sdk.alpha.Empty'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_agones_dev_sdk_alpha_Empty(buffer_arg) { + return alpha_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_agones_dev_sdk_alpha_PlayerID(arg) { + if (!(arg instanceof alpha_pb.PlayerID)) { + throw new Error('Expected argument of type agones.dev.sdk.alpha.PlayerID'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_agones_dev_sdk_alpha_PlayerID(buffer_arg) { + return alpha_pb.PlayerID.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_agones_dev_sdk_alpha_PlayerIDList(arg) { + if (!(arg instanceof alpha_pb.PlayerIDList)) { + throw new Error('Expected argument of type agones.dev.sdk.alpha.PlayerIDList'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_agones_dev_sdk_alpha_PlayerIDList(buffer_arg) { + return alpha_pb.PlayerIDList.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +// SDK service to be used in the GameServer SDK to the Pod Sidecar. +var SDKService = exports['agones.dev.sdk.alpha.SDK'] = { + // PlayerConnect increases the SDK’s stored player count by one, and appends this playerID to GameServer.Status.Players.IDs. +// +// GameServer.Status.Players.Count and GameServer.Status.Players.IDs are then set to update the player count and id list a second from now, +// unless there is already an update pending, in which case the update joins that batch operation. +// +// PlayerConnect returns true and adds the playerID to the list of playerIDs if this playerID was not already in the +// list of connected playerIDs. +// +// If the playerID exists within the list of connected playerIDs, PlayerConnect will return false, and the list of +// connected playerIDs will be left unchanged. +// +// An error will be returned if the playerID was not already in the list of connected playerIDs but the player capacity for +// the server has been reached. The playerID will not be added to the list of playerIDs. +// +// Warning: Do not use this method if you are manually managing GameServer.Status.Players.IDs and GameServer.Status.Players.Count +// through the Kubernetes API, as indeterminate results will occur. +playerConnect: { + path: '/agones.dev.sdk.alpha.SDK/PlayerConnect', + requestStream: false, + responseStream: false, + requestType: alpha_pb.PlayerID, + responseType: alpha_pb.Bool, + requestSerialize: serialize_agones_dev_sdk_alpha_PlayerID, + requestDeserialize: deserialize_agones_dev_sdk_alpha_PlayerID, + responseSerialize: serialize_agones_dev_sdk_alpha_Bool, + responseDeserialize: deserialize_agones_dev_sdk_alpha_Bool, + }, + // Decreases the SDK’s stored player count by one, and removes the playerID from GameServer.Status.Players.IDs. +// +// GameServer.Status.Players.Count and GameServer.Status.Players.IDs are then set to update the player count and id list a second from now, +// unless there is already an update pending, in which case the update joins that batch operation. +// +// PlayerDisconnect will return true and remove the supplied playerID from the list of connected playerIDs if the +// playerID value exists within the list. +// +// If the playerID was not in the list of connected playerIDs, the call will return false, and the connected playerID list +// will be left unchanged. +// +// Warning: Do not use this method if you are manually managing GameServer.status.players.IDs and GameServer.status.players.Count +// through the Kubernetes API, as indeterminate results will occur. +playerDisconnect: { + path: '/agones.dev.sdk.alpha.SDK/PlayerDisconnect', + requestStream: false, + responseStream: false, + requestType: alpha_pb.PlayerID, + responseType: alpha_pb.Bool, + requestSerialize: serialize_agones_dev_sdk_alpha_PlayerID, + requestDeserialize: deserialize_agones_dev_sdk_alpha_PlayerID, + responseSerialize: serialize_agones_dev_sdk_alpha_Bool, + responseDeserialize: deserialize_agones_dev_sdk_alpha_Bool, + }, + // Update the GameServer.Status.Players.Capacity value with a new capacity. +setPlayerCapacity: { + path: '/agones.dev.sdk.alpha.SDK/SetPlayerCapacity', + requestStream: false, + responseStream: false, + requestType: alpha_pb.Count, + responseType: alpha_pb.Empty, + requestSerialize: serialize_agones_dev_sdk_alpha_Count, + requestDeserialize: deserialize_agones_dev_sdk_alpha_Count, + responseSerialize: serialize_agones_dev_sdk_alpha_Empty, + responseDeserialize: deserialize_agones_dev_sdk_alpha_Empty, + }, + // Retrieves the current player capacity. This is always accurate from what has been set through this SDK, +// even if the value has yet to be updated on the GameServer status resource. +// +// If GameServer.Status.Players.Capacity is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to view this value. +getPlayerCapacity: { + path: '/agones.dev.sdk.alpha.SDK/GetPlayerCapacity', + requestStream: false, + responseStream: false, + requestType: alpha_pb.Empty, + responseType: alpha_pb.Count, + requestSerialize: serialize_agones_dev_sdk_alpha_Empty, + requestDeserialize: deserialize_agones_dev_sdk_alpha_Empty, + responseSerialize: serialize_agones_dev_sdk_alpha_Count, + responseDeserialize: deserialize_agones_dev_sdk_alpha_Count, + }, + // Retrieves the current player count. This is always accurate from what has been set through this SDK, +// even if the value has yet to be updated on the GameServer status resource. +// +// If GameServer.Status.Players.Count is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to view this value. +getPlayerCount: { + path: '/agones.dev.sdk.alpha.SDK/GetPlayerCount', + requestStream: false, + responseStream: false, + requestType: alpha_pb.Empty, + responseType: alpha_pb.Count, + requestSerialize: serialize_agones_dev_sdk_alpha_Empty, + requestDeserialize: deserialize_agones_dev_sdk_alpha_Empty, + responseSerialize: serialize_agones_dev_sdk_alpha_Count, + responseDeserialize: deserialize_agones_dev_sdk_alpha_Count, + }, + // Returns if the playerID is currently connected to the GameServer. This is always accurate from what has been set through this SDK, +// even if the value has yet to be updated on the GameServer status resource. +// +// If GameServer.Status.Players.IDs is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to determine connected status. +isPlayerConnected: { + path: '/agones.dev.sdk.alpha.SDK/IsPlayerConnected', + requestStream: false, + responseStream: false, + requestType: alpha_pb.PlayerID, + responseType: alpha_pb.Bool, + requestSerialize: serialize_agones_dev_sdk_alpha_PlayerID, + requestDeserialize: deserialize_agones_dev_sdk_alpha_PlayerID, + responseSerialize: serialize_agones_dev_sdk_alpha_Bool, + responseDeserialize: deserialize_agones_dev_sdk_alpha_Bool, + }, + // Returns the list of the currently connected player ids. This is always accurate from what has been set through this SDK, +// even if the value has yet to be updated on the GameServer status resource. +// +// If GameServer.Status.Players.IDs is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to view this value. +getConnectedPlayers: { + path: '/agones.dev.sdk.alpha.SDK/GetConnectedPlayers', + requestStream: false, + responseStream: false, + requestType: alpha_pb.Empty, + responseType: alpha_pb.PlayerIDList, + requestSerialize: serialize_agones_dev_sdk_alpha_Empty, + requestDeserialize: deserialize_agones_dev_sdk_alpha_Empty, + responseSerialize: serialize_agones_dev_sdk_alpha_PlayerIDList, + responseDeserialize: deserialize_agones_dev_sdk_alpha_PlayerIDList, + }, +}; + diff --git a/sdks/nodejs/lib/alpha/alpha_pb.js b/sdks/nodejs/lib/alpha/alpha_pb.js new file mode 100644 index 0000000000..378b6654b0 --- /dev/null +++ b/sdks/nodejs/lib/alpha/alpha_pb.js @@ -0,0 +1,743 @@ +// Copyright 2020 Google LLC All Rights Reserved. +// +// 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. + +// This code was autogenerated. Do not edit directly. +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +var google_api_annotations_pb = require('./google/api/annotations_pb.js'); +goog.object.extend(proto, google_api_annotations_pb); +goog.exportSymbol('proto.agones.dev.sdk.alpha.Bool', null, global); +goog.exportSymbol('proto.agones.dev.sdk.alpha.Count', null, global); +goog.exportSymbol('proto.agones.dev.sdk.alpha.Empty', null, global); +goog.exportSymbol('proto.agones.dev.sdk.alpha.PlayerID', null, global); +goog.exportSymbol('proto.agones.dev.sdk.alpha.PlayerIDList', null, global); + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.agones.dev.sdk.alpha.Empty = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.agones.dev.sdk.alpha.Empty, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.agones.dev.sdk.alpha.Empty.displayName = 'proto.agones.dev.sdk.alpha.Empty'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.agones.dev.sdk.alpha.Empty.prototype.toObject = function(opt_includeInstance) { + return proto.agones.dev.sdk.alpha.Empty.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.agones.dev.sdk.alpha.Empty} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.Empty.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.agones.dev.sdk.alpha.Empty} + */ +proto.agones.dev.sdk.alpha.Empty.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.agones.dev.sdk.alpha.Empty; + return proto.agones.dev.sdk.alpha.Empty.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.agones.dev.sdk.alpha.Empty} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.agones.dev.sdk.alpha.Empty} + */ +proto.agones.dev.sdk.alpha.Empty.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.agones.dev.sdk.alpha.Empty.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.agones.dev.sdk.alpha.Empty.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.agones.dev.sdk.alpha.Empty} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.Empty.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.agones.dev.sdk.alpha.Count = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.agones.dev.sdk.alpha.Count, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.agones.dev.sdk.alpha.Count.displayName = 'proto.agones.dev.sdk.alpha.Count'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.agones.dev.sdk.alpha.Count.prototype.toObject = function(opt_includeInstance) { + return proto.agones.dev.sdk.alpha.Count.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.agones.dev.sdk.alpha.Count} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.Count.toObject = function(includeInstance, msg) { + var f, obj = { + count: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.agones.dev.sdk.alpha.Count} + */ +proto.agones.dev.sdk.alpha.Count.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.agones.dev.sdk.alpha.Count; + return proto.agones.dev.sdk.alpha.Count.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.agones.dev.sdk.alpha.Count} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.agones.dev.sdk.alpha.Count} + */ +proto.agones.dev.sdk.alpha.Count.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.agones.dev.sdk.alpha.Count.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.agones.dev.sdk.alpha.Count.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.agones.dev.sdk.alpha.Count} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.Count.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCount(); + if (f !== 0) { + writer.writeInt64( + 1, + f + ); + } +}; + + +/** + * optional int64 count = 1; + * @return {number} + */ +proto.agones.dev.sdk.alpha.Count.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** @param {number} value */ +proto.agones.dev.sdk.alpha.Count.prototype.setCount = function(value) { + jspb.Message.setProto3IntField(this, 1, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.agones.dev.sdk.alpha.Bool = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.agones.dev.sdk.alpha.Bool, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.agones.dev.sdk.alpha.Bool.displayName = 'proto.agones.dev.sdk.alpha.Bool'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.agones.dev.sdk.alpha.Bool.prototype.toObject = function(opt_includeInstance) { + return proto.agones.dev.sdk.alpha.Bool.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.agones.dev.sdk.alpha.Bool} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.Bool.toObject = function(includeInstance, msg) { + var f, obj = { + bool: jspb.Message.getFieldWithDefault(msg, 1, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.agones.dev.sdk.alpha.Bool} + */ +proto.agones.dev.sdk.alpha.Bool.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.agones.dev.sdk.alpha.Bool; + return proto.agones.dev.sdk.alpha.Bool.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.agones.dev.sdk.alpha.Bool} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.agones.dev.sdk.alpha.Bool} + */ +proto.agones.dev.sdk.alpha.Bool.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setBool(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.agones.dev.sdk.alpha.Bool.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.agones.dev.sdk.alpha.Bool.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.agones.dev.sdk.alpha.Bool} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.Bool.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getBool(); + if (f) { + writer.writeBool( + 1, + f + ); + } +}; + + +/** + * optional bool bool = 1; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.agones.dev.sdk.alpha.Bool.prototype.getBool = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 1, false)); +}; + + +/** @param {boolean} value */ +proto.agones.dev.sdk.alpha.Bool.prototype.setBool = function(value) { + jspb.Message.setProto3BooleanField(this, 1, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.agones.dev.sdk.alpha.PlayerID = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.agones.dev.sdk.alpha.PlayerID, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.agones.dev.sdk.alpha.PlayerID.displayName = 'proto.agones.dev.sdk.alpha.PlayerID'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.agones.dev.sdk.alpha.PlayerID.prototype.toObject = function(opt_includeInstance) { + return proto.agones.dev.sdk.alpha.PlayerID.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.agones.dev.sdk.alpha.PlayerID} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.PlayerID.toObject = function(includeInstance, msg) { + var f, obj = { + playerid: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.agones.dev.sdk.alpha.PlayerID} + */ +proto.agones.dev.sdk.alpha.PlayerID.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.agones.dev.sdk.alpha.PlayerID; + return proto.agones.dev.sdk.alpha.PlayerID.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.agones.dev.sdk.alpha.PlayerID} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.agones.dev.sdk.alpha.PlayerID} + */ +proto.agones.dev.sdk.alpha.PlayerID.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setPlayerid(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.agones.dev.sdk.alpha.PlayerID.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.agones.dev.sdk.alpha.PlayerID.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.agones.dev.sdk.alpha.PlayerID} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.PlayerID.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getPlayerid(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string playerID = 1; + * @return {string} + */ +proto.agones.dev.sdk.alpha.PlayerID.prototype.getPlayerid = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.agones.dev.sdk.alpha.PlayerID.prototype.setPlayerid = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.agones.dev.sdk.alpha.PlayerIDList = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.agones.dev.sdk.alpha.PlayerIDList.repeatedFields_, null); +}; +goog.inherits(proto.agones.dev.sdk.alpha.PlayerIDList, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.agones.dev.sdk.alpha.PlayerIDList.displayName = 'proto.agones.dev.sdk.alpha.PlayerIDList'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.agones.dev.sdk.alpha.PlayerIDList.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.agones.dev.sdk.alpha.PlayerIDList.prototype.toObject = function(opt_includeInstance) { + return proto.agones.dev.sdk.alpha.PlayerIDList.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.agones.dev.sdk.alpha.PlayerIDList} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.PlayerIDList.toObject = function(includeInstance, msg) { + var f, obj = { + listList: jspb.Message.getRepeatedField(msg, 1) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.agones.dev.sdk.alpha.PlayerIDList} + */ +proto.agones.dev.sdk.alpha.PlayerIDList.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.agones.dev.sdk.alpha.PlayerIDList; + return proto.agones.dev.sdk.alpha.PlayerIDList.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.agones.dev.sdk.alpha.PlayerIDList} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.agones.dev.sdk.alpha.PlayerIDList} + */ +proto.agones.dev.sdk.alpha.PlayerIDList.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.addList(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.agones.dev.sdk.alpha.PlayerIDList.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.agones.dev.sdk.alpha.PlayerIDList.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.agones.dev.sdk.alpha.PlayerIDList} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.agones.dev.sdk.alpha.PlayerIDList.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getListList(); + if (f.length > 0) { + writer.writeRepeatedString( + 1, + f + ); + } +}; + + +/** + * repeated string list = 1; + * @return {!Array} + */ +proto.agones.dev.sdk.alpha.PlayerIDList.prototype.getListList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +}; + + +/** @param {!Array} value */ +proto.agones.dev.sdk.alpha.PlayerIDList.prototype.setListList = function(value) { + jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + */ +proto.agones.dev.sdk.alpha.PlayerIDList.prototype.addList = function(value, opt_index) { + jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +proto.agones.dev.sdk.alpha.PlayerIDList.prototype.clearListList = function() { + this.setListList([]); +}; + + +goog.object.extend(exports, proto.agones.dev.sdk.alpha); diff --git a/sdks/nodejs/lib/alpha/google/api/annotations_pb.js b/sdks/nodejs/lib/alpha/google/api/annotations_pb.js new file mode 100644 index 0000000000..8852d64eab --- /dev/null +++ b/sdks/nodejs/lib/alpha/google/api/annotations_pb.js @@ -0,0 +1,59 @@ +// Copyright 2020 Google LLC All Rights Reserved. +// +// 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. + +// This code was autogenerated. Do not edit directly. +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +var google_api_http_pb = require('../../google/api/http_pb.js'); +goog.object.extend(proto, google_api_http_pb); +var google_protobuf_descriptor_pb = require('google-protobuf/google/protobuf/descriptor_pb.js'); +goog.object.extend(proto, google_protobuf_descriptor_pb); +goog.exportSymbol('proto.google.api.http', null, global); + +/** + * A tuple of {field number, class constructor} for the extension + * field named `http`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.google.api.http = new jspb.ExtensionFieldInfo( + 72295728, + {http: 0}, + google_api_http_pb.HttpRule, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + google_api_http_pb.HttpRule.toObject), + 0); + +google_protobuf_descriptor_pb.MethodOptions.extensionsBinary[72295728] = new jspb.ExtensionFieldBinaryInfo( + proto.google.api.http, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + google_api_http_pb.HttpRule.serializeBinaryToWriter, + google_api_http_pb.HttpRule.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +google_protobuf_descriptor_pb.MethodOptions.extensions[72295728] = proto.google.api.http; + +goog.object.extend(exports, proto.google.api); diff --git a/sdks/nodejs/lib/alpha/google/api/http_pb.js b/sdks/nodejs/lib/alpha/google/api/http_pb.js new file mode 100644 index 0000000000..b93aa17b4e --- /dev/null +++ b/sdks/nodejs/lib/alpha/google/api/http_pb.js @@ -0,0 +1,926 @@ +// Copyright 2020 Google LLC All Rights Reserved. +// +// 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. + +// This code was autogenerated. Do not edit directly. +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.google.api.CustomHttpPattern', null, global); +goog.exportSymbol('proto.google.api.Http', null, global); +goog.exportSymbol('proto.google.api.HttpRule', null, global); + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.google.api.Http = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.google.api.Http.repeatedFields_, null); +}; +goog.inherits(proto.google.api.Http, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.google.api.Http.displayName = 'proto.google.api.Http'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.google.api.Http.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.google.api.Http.prototype.toObject = function(opt_includeInstance) { + return proto.google.api.Http.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.google.api.Http} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.google.api.Http.toObject = function(includeInstance, msg) { + var f, obj = { + rulesList: jspb.Message.toObjectList(msg.getRulesList(), + proto.google.api.HttpRule.toObject, includeInstance), + fullyDecodeReservedExpansion: jspb.Message.getFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.google.api.Http} + */ +proto.google.api.Http.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.google.api.Http; + return proto.google.api.Http.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.google.api.Http} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.google.api.Http} + */ +proto.google.api.Http.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.google.api.HttpRule; + reader.readMessage(value,proto.google.api.HttpRule.deserializeBinaryFromReader); + msg.addRules(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFullyDecodeReservedExpansion(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.google.api.Http.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.google.api.Http.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.google.api.Http} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.google.api.Http.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRulesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.google.api.HttpRule.serializeBinaryToWriter + ); + } + f = message.getFullyDecodeReservedExpansion(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * repeated HttpRule rules = 1; + * @return {!Array} + */ +proto.google.api.Http.prototype.getRulesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.google.api.HttpRule, 1)); +}; + + +/** @param {!Array} value */ +proto.google.api.Http.prototype.setRulesList = function(value) { + jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.google.api.HttpRule=} opt_value + * @param {number=} opt_index + * @return {!proto.google.api.HttpRule} + */ +proto.google.api.Http.prototype.addRules = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.google.api.HttpRule, opt_index); +}; + + +proto.google.api.Http.prototype.clearRulesList = function() { + this.setRulesList([]); +}; + + +/** + * optional bool fully_decode_reserved_expansion = 2; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.google.api.Http.prototype.getFullyDecodeReservedExpansion = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 2, false)); +}; + + +/** @param {boolean} value */ +proto.google.api.Http.prototype.setFullyDecodeReservedExpansion = function(value) { + jspb.Message.setProto3BooleanField(this, 2, value); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.google.api.HttpRule = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.google.api.HttpRule.repeatedFields_, proto.google.api.HttpRule.oneofGroups_); +}; +goog.inherits(proto.google.api.HttpRule, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.google.api.HttpRule.displayName = 'proto.google.api.HttpRule'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.google.api.HttpRule.repeatedFields_ = [11]; + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.google.api.HttpRule.oneofGroups_ = [[2,3,4,5,6,8]]; + +/** + * @enum {number} + */ +proto.google.api.HttpRule.PatternCase = { + PATTERN_NOT_SET: 0, + GET: 2, + PUT: 3, + POST: 4, + DELETE: 5, + PATCH: 6, + CUSTOM: 8 +}; + +/** + * @return {proto.google.api.HttpRule.PatternCase} + */ +proto.google.api.HttpRule.prototype.getPatternCase = function() { + return /** @type {proto.google.api.HttpRule.PatternCase} */(jspb.Message.computeOneofCase(this, proto.google.api.HttpRule.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.google.api.HttpRule.prototype.toObject = function(opt_includeInstance) { + return proto.google.api.HttpRule.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.google.api.HttpRule} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.google.api.HttpRule.toObject = function(includeInstance, msg) { + var f, obj = { + selector: jspb.Message.getFieldWithDefault(msg, 1, ""), + get: jspb.Message.getFieldWithDefault(msg, 2, ""), + put: jspb.Message.getFieldWithDefault(msg, 3, ""), + post: jspb.Message.getFieldWithDefault(msg, 4, ""), + pb_delete: jspb.Message.getFieldWithDefault(msg, 5, ""), + patch: jspb.Message.getFieldWithDefault(msg, 6, ""), + custom: (f = msg.getCustom()) && proto.google.api.CustomHttpPattern.toObject(includeInstance, f), + body: jspb.Message.getFieldWithDefault(msg, 7, ""), + responseBody: jspb.Message.getFieldWithDefault(msg, 12, ""), + additionalBindingsList: jspb.Message.toObjectList(msg.getAdditionalBindingsList(), + proto.google.api.HttpRule.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.google.api.HttpRule} + */ +proto.google.api.HttpRule.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.google.api.HttpRule; + return proto.google.api.HttpRule.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.google.api.HttpRule} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.google.api.HttpRule} + */ +proto.google.api.HttpRule.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setSelector(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setGet(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setPut(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setPost(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setDelete(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setPatch(value); + break; + case 8: + var value = new proto.google.api.CustomHttpPattern; + reader.readMessage(value,proto.google.api.CustomHttpPattern.deserializeBinaryFromReader); + msg.setCustom(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setBody(value); + break; + case 12: + var value = /** @type {string} */ (reader.readString()); + msg.setResponseBody(value); + break; + case 11: + var value = new proto.google.api.HttpRule; + reader.readMessage(value,proto.google.api.HttpRule.deserializeBinaryFromReader); + msg.addAdditionalBindings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.google.api.HttpRule.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.google.api.HttpRule.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.google.api.HttpRule} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.google.api.HttpRule.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSelector(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeString( + 5, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeString( + 6, + f + ); + } + f = message.getCustom(); + if (f != null) { + writer.writeMessage( + 8, + f, + proto.google.api.CustomHttpPattern.serializeBinaryToWriter + ); + } + f = message.getBody(); + if (f.length > 0) { + writer.writeString( + 7, + f + ); + } + f = message.getResponseBody(); + if (f.length > 0) { + writer.writeString( + 12, + f + ); + } + f = message.getAdditionalBindingsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 11, + f, + proto.google.api.HttpRule.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string selector = 1; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getSelector = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setSelector = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string get = 2; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getGet = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setGet = function(value) { + jspb.Message.setOneofField(this, 2, proto.google.api.HttpRule.oneofGroups_[0], value); +}; + + +proto.google.api.HttpRule.prototype.clearGet = function() { + jspb.Message.setOneofField(this, 2, proto.google.api.HttpRule.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.google.api.HttpRule.prototype.hasGet = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string put = 3; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getPut = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setPut = function(value) { + jspb.Message.setOneofField(this, 3, proto.google.api.HttpRule.oneofGroups_[0], value); +}; + + +proto.google.api.HttpRule.prototype.clearPut = function() { + jspb.Message.setOneofField(this, 3, proto.google.api.HttpRule.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.google.api.HttpRule.prototype.hasPut = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional string post = 4; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getPost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setPost = function(value) { + jspb.Message.setOneofField(this, 4, proto.google.api.HttpRule.oneofGroups_[0], value); +}; + + +proto.google.api.HttpRule.prototype.clearPost = function() { + jspb.Message.setOneofField(this, 4, proto.google.api.HttpRule.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.google.api.HttpRule.prototype.hasPost = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional string delete = 5; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getDelete = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setDelete = function(value) { + jspb.Message.setOneofField(this, 5, proto.google.api.HttpRule.oneofGroups_[0], value); +}; + + +proto.google.api.HttpRule.prototype.clearDelete = function() { + jspb.Message.setOneofField(this, 5, proto.google.api.HttpRule.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.google.api.HttpRule.prototype.hasDelete = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional string patch = 6; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getPatch = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setPatch = function(value) { + jspb.Message.setOneofField(this, 6, proto.google.api.HttpRule.oneofGroups_[0], value); +}; + + +proto.google.api.HttpRule.prototype.clearPatch = function() { + jspb.Message.setOneofField(this, 6, proto.google.api.HttpRule.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.google.api.HttpRule.prototype.hasPatch = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional CustomHttpPattern custom = 8; + * @return {?proto.google.api.CustomHttpPattern} + */ +proto.google.api.HttpRule.prototype.getCustom = function() { + return /** @type{?proto.google.api.CustomHttpPattern} */ ( + jspb.Message.getWrapperField(this, proto.google.api.CustomHttpPattern, 8)); +}; + + +/** @param {?proto.google.api.CustomHttpPattern|undefined} value */ +proto.google.api.HttpRule.prototype.setCustom = function(value) { + jspb.Message.setOneofWrapperField(this, 8, proto.google.api.HttpRule.oneofGroups_[0], value); +}; + + +proto.google.api.HttpRule.prototype.clearCustom = function() { + this.setCustom(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.google.api.HttpRule.prototype.hasCustom = function() { + return jspb.Message.getField(this, 8) != null; +}; + + +/** + * optional string body = 7; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getBody = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setBody = function(value) { + jspb.Message.setProto3StringField(this, 7, value); +}; + + +/** + * optional string response_body = 12; + * @return {string} + */ +proto.google.api.HttpRule.prototype.getResponseBody = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 12, "")); +}; + + +/** @param {string} value */ +proto.google.api.HttpRule.prototype.setResponseBody = function(value) { + jspb.Message.setProto3StringField(this, 12, value); +}; + + +/** + * repeated HttpRule additional_bindings = 11; + * @return {!Array} + */ +proto.google.api.HttpRule.prototype.getAdditionalBindingsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.google.api.HttpRule, 11)); +}; + + +/** @param {!Array} value */ +proto.google.api.HttpRule.prototype.setAdditionalBindingsList = function(value) { + jspb.Message.setRepeatedWrapperField(this, 11, value); +}; + + +/** + * @param {!proto.google.api.HttpRule=} opt_value + * @param {number=} opt_index + * @return {!proto.google.api.HttpRule} + */ +proto.google.api.HttpRule.prototype.addAdditionalBindings = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 11, opt_value, proto.google.api.HttpRule, opt_index); +}; + + +proto.google.api.HttpRule.prototype.clearAdditionalBindingsList = function() { + this.setAdditionalBindingsList([]); +}; + + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.google.api.CustomHttpPattern = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.google.api.CustomHttpPattern, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.google.api.CustomHttpPattern.displayName = 'proto.google.api.CustomHttpPattern'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.google.api.CustomHttpPattern.prototype.toObject = function(opt_includeInstance) { + return proto.google.api.CustomHttpPattern.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.google.api.CustomHttpPattern} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.google.api.CustomHttpPattern.toObject = function(includeInstance, msg) { + var f, obj = { + kind: jspb.Message.getFieldWithDefault(msg, 1, ""), + path: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.google.api.CustomHttpPattern} + */ +proto.google.api.CustomHttpPattern.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.google.api.CustomHttpPattern; + return proto.google.api.CustomHttpPattern.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.google.api.CustomHttpPattern} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.google.api.CustomHttpPattern} + */ +proto.google.api.CustomHttpPattern.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setKind(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setPath(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.google.api.CustomHttpPattern.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.google.api.CustomHttpPattern.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.google.api.CustomHttpPattern} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.google.api.CustomHttpPattern.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKind(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getPath(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string kind = 1; + * @return {string} + */ +proto.google.api.CustomHttpPattern.prototype.getKind = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.google.api.CustomHttpPattern.prototype.setKind = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string path = 2; + * @return {string} + */ +proto.google.api.CustomHttpPattern.prototype.getPath = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.google.api.CustomHttpPattern.prototype.setPath = function(value) { + jspb.Message.setProto3StringField(this, 2, value); +}; + + +goog.object.extend(exports, proto.google.api); diff --git a/sdks/nodejs/package-lock.json b/sdks/nodejs/package-lock.json index 85bad99149..555c66fae5 100644 --- a/sdks/nodejs/package-lock.json +++ b/sdks/nodejs/package-lock.json @@ -245,9 +245,9 @@ } }, "@grpc/grpc-js": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.1.1.tgz", - "integrity": "sha512-mhZRszS0SKwnWPJaNyrECePZ9U7vaHFGqrzxQbWinWR3WznBIU+nmh2L5J3elF+lp5DEUIzARXkifbs6LQVAHA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.1.2.tgz", + "integrity": "sha512-k2u86Bkm/3xrjUaSWeIyzXScBt/cC8uE7BznR0cpueQi11R33W6qfJdMrkrsmSHirp5likR55JSXUrcWG6ybHA==", "requires": { "semver": "^6.2.0" }, @@ -313,9 +313,9 @@ "dev": true }, "agent-base": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.0.tgz", - "integrity": "sha512-j1Q7cSCqN+AwrmDd+pzgqc0/NpC655x2bUf5ZjRIO77DcNBFmh+OgRNzF6OKdCC9RSCb19fGd99+bhXFdkRNqw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.1.tgz", + "integrity": "sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==", "requires": { "debug": "4" } @@ -331,9 +331,9 @@ } }, "ajv": { - "version": "6.12.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", - "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", + "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -343,9 +343,9 @@ } }, "ansi-colors": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", - "integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true }, "ansi-regex": { @@ -647,12 +647,12 @@ "dev": true }, "enquirer": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.5.tgz", - "integrity": "sha512-BNT1C08P9XD0vNg3J475yIUG+mVdp9T6towYFHUv897X0KoHBjB1shyrNmhmtHWKP17iSWgo7Gqh7BBuzLZMSA==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", "dev": true, "requires": { - "ansi-colors": "^3.2.1" + "ansi-colors": "^4.1.1" } }, "es6-error": { @@ -668,9 +668,9 @@ "dev": true }, "eslint": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.3.1.tgz", - "integrity": "sha512-cQC/xj9bhWUcyi/RuMbRtC3I0eW8MH0jhRELSvpKYkWep3C6YZ2OkvcvJVUeO6gcunABmzptbXBuDoXsjHmfTA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.4.0.tgz", + "integrity": "sha512-gU+lxhlPHu45H3JkEGgYhWhkR9wLHHEXC9FbWFnTlEkbKyZKWgWRLgf61E8zWmBuI6g5xKBph9ltg3NtZMVF8g==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -737,14 +737,14 @@ "dev": true }, "espree": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.1.0.tgz", - "integrity": "sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz", + "integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==", "dev": true, "requires": { - "acorn": "^7.2.0", + "acorn": "^7.3.1", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.2.0" + "eslint-visitor-keys": "^1.3.0" } }, "esprima": { @@ -900,9 +900,9 @@ "dev": true }, "gaxios": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-3.0.3.tgz", - "integrity": "sha512-PkzQludeIFhd535/yucALT/Wxyj/y2zLyrMwPcJmnLHDugmV49NvAi/vb+VUq/eWztATZCNcb8ue+ywPG+oLuw==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-3.0.4.tgz", + "integrity": "sha512-97NmFuMETFQh6gqPUxkqjxRMjmY8aRKRMphIkgO/b90AbCt5wAVuXsp8oWjIXlLN2pIK/fsXD8edcM7ULkFMLg==", "requires": { "abort-controller": "^3.0.0", "extend": "^3.0.2", @@ -912,12 +912,12 @@ } }, "gcp-metadata": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.1.0.tgz", - "integrity": "sha512-r57SV28+olVsflPlKyVig3Muo/VDlcsObMtvDGOEtEJXj+DDE8bEl0coIkXh//hbkSDTvo+f5lbihZOndYXQQQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.1.4.tgz", + "integrity": "sha512-5J/GIH0yWt/56R3dNaNWPGQ/zXsZOddYECfJaqxFWgrZ9HC2Kvc5vl9upOgUUHKzURjAVf2N+f6tEJiojqXUuA==", "requires": { "gaxios": "^3.0.0", - "json-bigint": "^0.3.0" + "json-bigint": "^1.0.0" } }, "gensync": { @@ -971,9 +971,9 @@ } }, "google-auth-library": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.2.tgz", - "integrity": "sha512-o/F/GiOPzDc49v5/6vfrEz3gRXvES49qGP84rrl3SO0efJA/M52hFwv2ozd1EC1TPrLj75Moj3iPgKGuGs6smA==", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.0.5.tgz", + "integrity": "sha512-Wj31lfTm2yR4g3WfOOB1Am1tt478Xq9OvzTPQJi17tn/I9R5IcsxjANBsE93nYmxYxtwDedhOdIb8l3vSPG49Q==", "requires": { "arrify": "^2.0.0", "base64-js": "^1.3.0", @@ -983,13 +983,13 @@ "gcp-metadata": "^4.1.0", "gtoken": "^5.0.0", "jws": "^4.0.0", - "lru-cache": "^5.0.0" + "lru-cache": "^6.0.0" } }, "google-p12-pem": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.0.1.tgz", - "integrity": "sha512-VlQgtozgNVVVcYTXS36eQz4PXPt9gIPqLOhHN0QiV6W6h4qSCNVKPtKC5INtJsaHHF2r7+nOIa26MJeJMTaZEQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.0.2.tgz", + "integrity": "sha512-tbjzndQvSIHGBLzHnhDs3cL4RBjLbLXc2pYvGH+imGVu5b4RMAttUTdnmW2UH0t11QeBTXZ7wlXPS7hrypO/tg==", "requires": { "node-forge": "^0.9.0" } @@ -1006,9 +1006,9 @@ "dev": true }, "gtoken": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.0.1.tgz", - "integrity": "sha512-33w4FNDkUcyIOq/TqyC+drnKdI4PdXmWp9lZzssyEQKuvu9ZFN3KttaSnDKo52U3E51oujVGop93mKxmqO8HHg==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.0.2.tgz", + "integrity": "sha512-lull70rHCTvRTmAt+R/6W5bTtx4MjHku7AwJwK5fGqhOmygcZud0nrZcX+QUNfBJwCzqy7S5i1Bc4NYnr5PMMA==", "requires": { "gaxios": "^3.0.0", "google-p12-pem": "^3.0.0", @@ -1292,9 +1292,9 @@ "dev": true }, "json-bigint": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.1.tgz", - "integrity": "sha512-DGWnSzmusIreWlEupsUelHrhwmPPE+FiQvg+drKfk2p+bdEYa5mp4PJ8JsCWqae0M2jQNb0HPvnwvf1qOTThzQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", "requires": { "bignumber.js": "^9.0.0" } @@ -1371,11 +1371,11 @@ "dev": true }, "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "requires": { - "yallist": "^3.0.2" + "yallist": "^4.0.0" } }, "make-dir": { @@ -1824,9 +1824,9 @@ "dev": true }, "strip-json-comments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", - "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, "supports-color": { @@ -2034,9 +2034,9 @@ "dev": true }, "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yargs": { "version": "15.3.1", diff --git a/sdks/nodejs/package.json b/sdks/nodejs/package.json index 214101da98..d14f0560f4 100644 --- a/sdks/nodejs/package.json +++ b/sdks/nodejs/package.json @@ -4,13 +4,13 @@ "url": "https://github.com/googleforgames/agones/issues" }, "dependencies": { - "@grpc/grpc-js": "1.1.1", - "google-auth-library": "6.0.2", + "@grpc/grpc-js": "1.1.2", + "google-auth-library": "6.0.5", "google-protobuf": "3.12.2" }, "description": "Game Server SDK for Agones, the open source project for hosting dedicated game servers on Kubernetes", "devDependencies": { - "eslint": "^7.3.1", + "eslint": "^7.4.0", "jasmine": "^3.5.0", "nyc": "^15.1.0" }, diff --git a/sdks/nodejs/spec/agonesSDK.spec.js b/sdks/nodejs/spec/agonesSDK.spec.js index 4b446241c3..8c099c10a2 100644 --- a/sdks/nodejs/spec/agonesSDK.spec.js +++ b/sdks/nodejs/spec/agonesSDK.spec.js @@ -17,9 +17,11 @@ const stream = require('stream'); const grpc = require('@grpc/grpc-js'); const messages = require('../lib/sdk_pb'); + const AgonesSDK = require('../src/agonesSDK'); +const Alpha = require('../src/alpha'); -describe('agones', () => { +describe('AgonesSDK', () => { let agonesSDK; beforeEach(() => { @@ -72,51 +74,51 @@ describe('agones', () => { }); }); - describe('allocate', () => { + describe('ready', () => { it('calls the server and handles success', async () => { - spyOn(agonesSDK.client, 'allocate').and.callFake((request, callback) => { + spyOn(agonesSDK.client, 'ready').and.callFake((request, callback) => { let result = new messages.Empty(); callback(undefined, result); }); - let result = await agonesSDK.allocate(); - expect(agonesSDK.client.allocate).toHaveBeenCalled(); + let result = await agonesSDK.ready(); + expect(agonesSDK.client.ready).toHaveBeenCalled(); expect(result).toEqual({}); }); it('calls the server and handles failure', async () => { - spyOn(agonesSDK.client, 'allocate').and.callFake((request, callback) => { + spyOn(agonesSDK.client, 'ready').and.callFake((request, callback) => { callback('error', undefined); }); try { - await agonesSDK.allocate(); + await agonesSDK.ready(); fail(); } catch (error) { - expect(agonesSDK.client.allocate).toHaveBeenCalled(); + expect(agonesSDK.client.ready).toHaveBeenCalled(); expect(error).toEqual('error'); } }); }); - describe('ready', () => { + describe('allocate', () => { it('calls the server and handles success', async () => { - spyOn(agonesSDK.client, 'ready').and.callFake((request, callback) => { + spyOn(agonesSDK.client, 'allocate').and.callFake((request, callback) => { let result = new messages.Empty(); callback(undefined, result); }); - let result = await agonesSDK.ready(); - expect(agonesSDK.client.ready).toHaveBeenCalled(); + let result = await agonesSDK.allocate(); + expect(agonesSDK.client.allocate).toHaveBeenCalled(); expect(result).toEqual({}); }); it('calls the server and handles failure', async () => { - spyOn(agonesSDK.client, 'ready').and.callFake((request, callback) => { + spyOn(agonesSDK.client, 'allocate').and.callFake((request, callback) => { callback('error', undefined); }); try { - await agonesSDK.ready(); + await agonesSDK.allocate(); fail(); } catch (error) { - expect(agonesSDK.client.ready).toHaveBeenCalled(); + expect(agonesSDK.client.allocate).toHaveBeenCalled(); expect(error).toEqual('error'); } }); @@ -417,4 +419,10 @@ describe('agones', () => { } }); }); + + describe('alpha', () => { + it('returns the alpha features class', () => { + expect(agonesSDK.alpha).toBeInstanceOf(Alpha); + }); + }); }); diff --git a/sdks/nodejs/spec/alphaAgonesSDK.spec.js b/sdks/nodejs/spec/alphaAgonesSDK.spec.js new file mode 100644 index 0000000000..269d7b8ddc --- /dev/null +++ b/sdks/nodejs/spec/alphaAgonesSDK.spec.js @@ -0,0 +1,254 @@ +// Copyright 2020 Google LLC All Rights Reserved. +// +// 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. + +const grpc = require('@grpc/grpc-js'); + +const messages = require('../lib/alpha/alpha_pb'); +const Alpha = require('../src/alpha'); + +describe('Alpha', () => { + let alpha; + + beforeEach(() => { + const address = 'localhost:9357'; + const credentials = grpc.credentials.createInsecure(); + alpha = new Alpha(address, credentials); + }); + + describe('playerConnect', () => { + it('calls the server and handles success when the player is not connected', async () => { + spyOn(alpha.client, 'playerConnect').and.callFake((request, callback) => { + let result = new messages.Bool(); + result.setBool(true); + callback(undefined, result); + }); + + let result = await alpha.playerConnect('playerID'); + expect(alpha.client.playerConnect).toHaveBeenCalled(); + expect(result).toEqual(true); + }); + + it('calls the server and handles success when the player is already connected', async () => { + spyOn(alpha.client, 'playerConnect').and.callFake((request, callback) => { + let result = new messages.Bool(); + result.setBool(false); + callback(undefined, result); + }); + + let result = await alpha.playerConnect('playerID'); + expect(alpha.client.playerConnect).toHaveBeenCalled(); + expect(result).toEqual(false); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'playerConnect').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.playerConnect('playerID'); + fail(); + } catch (error) { + expect(alpha.client.playerConnect).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); + + describe('playerDisconnect', () => { + it('calls the server and handles success when the player is connected', async () => { + spyOn(alpha.client, 'playerDisconnect').and.callFake((request, callback) => { + let result = new messages.Bool(); + result.setBool(true); + callback(undefined, result); + }); + + let result = await alpha.playerDisconnect('playerID'); + expect(alpha.client.playerDisconnect).toHaveBeenCalled(); + expect(result).toEqual(true); + }); + + it('calls the server and handles success when the player is not connected', async () => { + spyOn(alpha.client, 'playerDisconnect').and.callFake((request, callback) => { + let result = new messages.Bool(); + result.setBool(false); + callback(undefined, result); + }); + + let result = await alpha.playerDisconnect('playerID'); + expect(alpha.client.playerDisconnect).toHaveBeenCalled(); + expect(result).toEqual(false); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'playerDisconnect').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.playerDisconnect('playerID'); + fail(); + } catch (error) { + expect(alpha.client.playerDisconnect).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); + + describe('setPlayerCapacity', () => { + it('passes arguments to the server and handles success', async () => { + spyOn(alpha.client, 'setPlayerCapacity').and.callFake((request, callback) => { + let result = new messages.Empty(); + callback(undefined, result); + }); + + let result = await alpha.setPlayerCapacity(64); + expect(result).toEqual({}); + expect(alpha.client.setPlayerCapacity).toHaveBeenCalled(); + let request = alpha.client.setPlayerCapacity.calls.argsFor(0)[0]; + expect(request.getCount()).toEqual(64); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'setPlayerCapacity').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.setPlayerCapacity(64); + fail(); + } catch (error) { + expect(alpha.client.setPlayerCapacity).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); + + describe('getPlayerCapacity', () => { + it('calls the server and handles the response', async () => { + spyOn(alpha.client, 'getPlayerCapacity').and.callFake((request, callback) => { + let capacity = new messages.Count(); + capacity.setCount(64); + callback(undefined, capacity); + }); + + let capacity = await alpha.getPlayerCapacity(); + expect(alpha.client.getPlayerCapacity).toHaveBeenCalled(); + expect(capacity).toEqual(64); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'getPlayerCapacity').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.getPlayerCapacity(); + fail(); + } catch (error) { + expect(alpha.client.getPlayerCapacity).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); + + describe('getPlayerCount', () => { + it('calls the server and handles the response', async () => { + spyOn(alpha.client, 'getPlayerCount').and.callFake((request, callback) => { + let capacity = new messages.Count(); + capacity.setCount(16); + callback(undefined, capacity); + }); + + let capacity = await alpha.getPlayerCount(); + expect(alpha.client.getPlayerCount).toHaveBeenCalled(); + expect(capacity).toEqual(16); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'getPlayerCount').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.getPlayerCount(); + fail(); + } catch (error) { + expect(alpha.client.getPlayerCount).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); + + describe('isPlayerConnected', () => { + it('calls the server and handles success when the player is connected', async () => { + spyOn(alpha.client, 'isPlayerConnected').and.callFake((request, callback) => { + let result = new messages.Bool(); + result.setBool(true); + callback(undefined, result); + }); + + let result = await alpha.isPlayerConnected('playerID'); + expect(alpha.client.isPlayerConnected).toHaveBeenCalled(); + expect(result).toEqual(true); + }); + + it('calls the server and handles success when the player is not connected', async () => { + spyOn(alpha.client, 'isPlayerConnected').and.callFake((request, callback) => { + let result = new messages.Bool(); + result.setBool(false); + callback(undefined, result); + }); + + let result = await alpha.isPlayerConnected('playerID'); + expect(alpha.client.isPlayerConnected).toHaveBeenCalled(); + expect(result).toEqual(false); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'isPlayerConnected').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.isPlayerConnected('playerID'); + fail(); + } catch (error) { + expect(alpha.client.isPlayerConnected).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); + + describe('getConnectedPlayers', () => { + it('calls the server and handles the response', async () => { + spyOn(alpha.client, 'getConnectedPlayers').and.callFake((request, callback) => { + let connectedPlayers = new messages.PlayerIDList(); + connectedPlayers.setListList(['firstPlayerID', 'secondPlayerID']); + callback(undefined, connectedPlayers); + }); + + let connectedPlayers = await alpha.getConnectedPlayers(); + expect(alpha.client.getConnectedPlayers).toHaveBeenCalled(); + expect(connectedPlayers).toEqual(['firstPlayerID', 'secondPlayerID']); + }); + + it('calls the server and handles failure', async () => { + spyOn(alpha.client, 'getConnectedPlayers').and.callFake((request, callback) => { + callback('error', undefined); + }); + try { + await alpha.getConnectedPlayers(); + fail(); + } catch (error) { + expect(alpha.client.getConnectedPlayers).toHaveBeenCalled(); + expect(error).toEqual('error'); + } + }); + }); +}); diff --git a/sdks/nodejs/src/agonesSDK.js b/sdks/nodejs/src/agonesSDK.js index 9cda85b1fa..db14ac918e 100644 --- a/sdks/nodejs/src/agonesSDK.js +++ b/sdks/nodejs/src/agonesSDK.js @@ -14,15 +14,20 @@ const grpc = require('@grpc/grpc-js'); +const Alpha = require('./alpha'); + const messages = require('../lib/sdk_pb'); const servicesPackageDefinition = require('../lib/sdk_grpc_pb'); class AgonesSDK { constructor() { const services = grpc.loadPackageDefinition(servicesPackageDefinition); - this.client = new services.agones.dev.sdk.SDK(`localhost:${this.port}`, grpc.credentials.createInsecure()); + const address = `localhost:${this.port}`; + const credentials = grpc.credentials.createInsecure(); + this.client = new services.agones.dev.sdk.SDK(address, credentials); this.healthStream = undefined; this.streams = []; + this.alpha = new Alpha(address, credentials); } get port() { @@ -49,10 +54,10 @@ class AgonesSDK { this.client.close(); } - async allocate() { + async ready() { const request = new messages.Empty(); return new Promise((resolve, reject) => { - this.client.allocate(request, (error, response) => { + this.client.ready(request, (error, response) => { if (error) { reject(error); } else { @@ -61,11 +66,11 @@ class AgonesSDK { }); }); } - - async ready() { + + async allocate() { const request = new messages.Empty(); return new Promise((resolve, reject) => { - this.client.ready(request, (error, response) => { + this.client.allocate(request, (error, response) => { if (error) { reject(error); } else { diff --git a/sdks/nodejs/src/alpha.js b/sdks/nodejs/src/alpha.js new file mode 100644 index 0000000000..17ba96aa38 --- /dev/null +++ b/sdks/nodejs/src/alpha.js @@ -0,0 +1,130 @@ +// Copyright 2020 Google LLC All Rights Reserved. + +// +// 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. + +const grpc = require('@grpc/grpc-js'); + +const messages = require('../lib/alpha/alpha_pb'); +const servicesPackageDefinition = require('../lib/alpha/alpha_grpc_pb'); + +class Alpha { + constructor(address, credentials) { + const services = grpc.loadPackageDefinition(servicesPackageDefinition); + this.client = new services.agones.dev.sdk.alpha.SDK(address, credentials); + } + + async playerConnect(playerID) { + const request = new messages.PlayerID(); + request.setPlayerid(playerID); + + return new Promise((resolve, reject) => { + this.client.playerConnect(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.getBool()); + } + }); + }); + } + + async playerDisconnect(playerID) { + const request = new messages.PlayerID(); + request.setPlayerid(playerID); + + return new Promise((resolve, reject) => { + this.client.playerDisconnect(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.getBool()); + } + }); + }); + } + + async setPlayerCapacity(capacity) { + const request = new messages.Count(); + request.setCount(capacity); + + return new Promise((resolve, reject) => { + this.client.setPlayerCapacity(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.toObject()); + } + }); + }); + } + + async getPlayerCapacity() { + const request = new messages.Empty(); + + return new Promise((resolve, reject) => { + this.client.getPlayerCapacity(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.getCount()); + } + }); + }); + } + + getPlayerCount() { + const request = new messages.Empty(); + + return new Promise((resolve, reject) => { + this.client.getPlayerCount(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.getCount()); + } + }); + }); + } + + isPlayerConnected(playerID) { + const request = new messages.PlayerID(); + request.setPlayerid(playerID); + + return new Promise((resolve, reject) => { + this.client.isPlayerConnected(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.getBool()); + } + }); + }); + } + + getConnectedPlayers() { + const request = new messages.Empty(); + + return new Promise((resolve, reject) => { + this.client.getConnectedPlayers(request, (error, response) => { + if (error) { + reject(error); + } else { + resolve(response.getListList()); + } + }); + }); + } +} + +module.exports = Alpha; diff --git a/sdks/nodejs/src/index.js b/sdks/nodejs/src/index.js index cd1bf3dd3d..a13a8e8af0 100644 --- a/sdks/nodejs/src/index.js +++ b/sdks/nodejs/src/index.js @@ -12,6 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -const AgonesSDK = require('./agonesSDK'); - -module.exports = AgonesSDK; +module.exports = require('./agonesSDK');