From 878cd3f1596526b6e4e2457babd3dc2c2add11ad Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:56:05 +0000 Subject: [PATCH] feat(spanner): add processing_units to Instance resource (#1398) PiperOrigin-RevId: 378758342 Source-Link: https://github.com/googleapis/googleapis/commit/d8698715e4f5b7c45505dadd679255987c260180 Source-Link: https://github.com/googleapis/googleapis-gen/commit/54cfa763144ff2bf631518a6e872055493b583ae --- .../instance/v1/spanner_instance_admin.proto | 5 ++++ protos/protos.d.ts | 6 ++++ protos/protos.js | 22 ++++++++++++++ protos/protos.json | 4 +++ src/v1/database_admin_client.ts | 29 ++++--------------- src/v1/instance_admin_client.ts | 29 ++++--------------- src/v1/spanner_client.ts | 21 +++----------- 7 files changed, 53 insertions(+), 63 deletions(-) diff --git a/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto b/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto index 69043c1b3..5630d6532 100644 --- a/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +++ b/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -368,6 +368,11 @@ message Instance { // for more information about nodes. int32 node_count = 5; + // The number of processing units allocated to this instance. At most one of + // processing_units or node_count should be present in the message. This may + // be zero in API responses for instances that are not yet in state `READY`. + int32 processing_units = 9; + // Output only. The current instance state. For // [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], the state must be // either omitted or set to `CREATING`. For diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 96d15ed99..3d03531d9 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -9669,6 +9669,9 @@ export namespace google { /** Instance nodeCount */ nodeCount?: (number|null); + /** Instance processingUnits */ + processingUnits?: (number|null); + /** Instance state */ state?: (google.spanner.admin.instance.v1.Instance.State|keyof typeof google.spanner.admin.instance.v1.Instance.State|null); @@ -9700,6 +9703,9 @@ export namespace google { /** Instance nodeCount. */ public nodeCount: number; + /** Instance processingUnits. */ + public processingUnits: number; + /** Instance state. */ public state: (google.spanner.admin.instance.v1.Instance.State|keyof typeof google.spanner.admin.instance.v1.Instance.State); diff --git a/protos/protos.js b/protos/protos.js index 62b7a7105..ff11a24d6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -23772,6 +23772,7 @@ * @property {string|null} [config] Instance config * @property {string|null} [displayName] Instance displayName * @property {number|null} [nodeCount] Instance nodeCount + * @property {number|null} [processingUnits] Instance processingUnits * @property {google.spanner.admin.instance.v1.Instance.State|null} [state] Instance state * @property {Object.|null} [labels] Instance labels * @property {Array.|null} [endpointUris] Instance endpointUris @@ -23826,6 +23827,14 @@ */ Instance.prototype.nodeCount = 0; + /** + * Instance processingUnits. + * @member {number} processingUnits + * @memberof google.spanner.admin.instance.v1.Instance + * @instance + */ + Instance.prototype.processingUnits = 0; + /** * Instance state. * @member {google.spanner.admin.instance.v1.Instance.State} state @@ -23890,6 +23899,8 @@ if (message.endpointUris != null && message.endpointUris.length) for (var i = 0; i < message.endpointUris.length; ++i) writer.uint32(/* id 8, wireType 2 =*/66).string(message.endpointUris[i]); + if (message.processingUnits != null && Object.hasOwnProperty.call(message, "processingUnits")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.processingUnits); return writer; }; @@ -23936,6 +23947,9 @@ case 5: message.nodeCount = reader.int32(); break; + case 9: + message.processingUnits = reader.int32(); + break; case 6: message.state = reader.int32(); break; @@ -24013,6 +24027,9 @@ if (message.nodeCount != null && message.hasOwnProperty("nodeCount")) if (!$util.isInteger(message.nodeCount)) return "nodeCount: integer expected"; + if (message.processingUnits != null && message.hasOwnProperty("processingUnits")) + if (!$util.isInteger(message.processingUnits)) + return "processingUnits: integer expected"; if (message.state != null && message.hasOwnProperty("state")) switch (message.state) { default: @@ -24060,6 +24077,8 @@ message.displayName = String(object.displayName); if (object.nodeCount != null) message.nodeCount = object.nodeCount | 0; + if (object.processingUnits != null) + message.processingUnits = object.processingUnits | 0; switch (object.state) { case "STATE_UNSPECIFIED": case 0: @@ -24114,6 +24133,7 @@ object.displayName = ""; object.nodeCount = 0; object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.processingUnits = 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -24136,6 +24156,8 @@ for (var j = 0; j < message.endpointUris.length; ++j) object.endpointUris[j] = message.endpointUris[j]; } + if (message.processingUnits != null && message.hasOwnProperty("processingUnits")) + object.processingUnits = message.processingUnits; return object; }; diff --git a/protos/protos.json b/protos/protos.json index 47cadcbb9..9a39b8231 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2723,6 +2723,10 @@ "type": "int32", "id": 5 }, + "processingUnits": { + "type": "int32", + "id": 9 + }, "state": { "type": "State", "id": 6, diff --git a/src/v1/database_admin_client.ts b/src/v1/database_admin_client.ts index 38c056603..0f63ac46a 100644 --- a/src/v1/database_admin_client.ts +++ b/src/v1/database_admin_client.ts @@ -27,11 +27,11 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/database_admin_client_config.json`. @@ -147,27 +147,14 @@ export class DatabaseAdminClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. @@ -213,15 +200,11 @@ export class DatabaseAdminClient { ), }; + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. - const protoFilesRoot = opts.fallback - ? this._gaxModule.protobuf.Root.fromJSON( - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - ) - : this._gaxModule.protobuf.loadSync(nodejsProtoPath); this.operationsClient = this._gaxModule .lro({ diff --git a/src/v1/instance_admin_client.ts b/src/v1/instance_admin_client.ts index 440be5fee..d1553afaa 100644 --- a/src/v1/instance_admin_client.ts +++ b/src/v1/instance_admin_client.ts @@ -27,11 +27,11 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/instance_admin_client_config.json`. @@ -162,27 +162,14 @@ export class InstanceAdminClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. @@ -215,15 +202,11 @@ export class InstanceAdminClient { ), }; + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. - const protoFilesRoot = opts.fallback - ? this._gaxModule.protobuf.Root.fromJSON( - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - ) - : this._gaxModule.protobuf.loadSync(nodejsProtoPath); this.operationsClient = this._gaxModule .lro({ diff --git a/src/v1/spanner_client.ts b/src/v1/spanner_client.ts index 75d5a5127..ca7c7fc32 100644 --- a/src/v1/spanner_client.ts +++ b/src/v1/spanner_client.ts @@ -26,11 +26,11 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/spanner_client_config.json`. @@ -143,27 +143,14 @@ export class SpannerClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API.