From a08d426624371c5ea7aee2ef048e7406468dedf3 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 30 Nov 2022 03:55:25 +0000 Subject: [PATCH 1/2] docs: minor updates in comments PiperOrigin-RevId: 491785685 Source-Link: https://github.com/googleapis/googleapis/commit/e8bd0c402d36f49ac34052289dfce4baa1294b51 Source-Link: https://github.com/googleapis/googleapis-gen/commit/9691e0cc991a6e0483492a2fd6d89ddc192e6223 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRwdS8uT3dsQm90LnlhbWwiLCJoIjoiOTY5MWUwY2M5OTFhNmUwNDgzNDkyYTJmZDZkODlkZGMxOTJlNjIyMyJ9 --- .../google-cloud-tpu/v1/.eslintignore | 7 + .../google-cloud-tpu/v1/.eslintrc.json | 3 + .../google-cloud-tpu/v1/.gitignore | 14 + owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js | 55 + .../google-cloud-tpu/v1/.mocharc.js | 33 + .../google-cloud-tpu/v1/.prettierrc.js | 22 + owl-bot-staging/google-cloud-tpu/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../google-cloud-tpu/v1/package.json | 64 + .../google/cloud/tpu/v1/cloud_tpu.proto | 617 ++++ .../snippet_metadata.google.cloud.tpu.v1.json | 507 ++++ .../samples/generated/v1/tpu.create_node.js | 71 + .../samples/generated/v1/tpu.delete_node.js | 62 + .../generated/v1/tpu.get_accelerator_type.js | 61 + .../v1/samples/generated/v1/tpu.get_node.js | 61 + .../v1/tpu.get_tensor_flow_version.js | 61 + .../v1/tpu.list_accelerator_types.js | 79 + .../v1/samples/generated/v1/tpu.list_nodes.js | 71 + .../v1/tpu.list_tensor_flow_versions.js | 79 + .../samples/generated/v1/tpu.reimage_node.js | 65 + .../v1/samples/generated/v1/tpu.start_node.js | 61 + .../v1/samples/generated/v1/tpu.stop_node.js | 61 + .../google-cloud-tpu/v1/src/index.ts | 25 + .../v1/src/v1/gapic_metadata.json | 145 + .../google-cloud-tpu/v1/src/v1/index.ts | 19 + .../google-cloud-tpu/v1/src/v1/tpu_client.ts | 2091 +++++++++++++ .../v1/src/v1/tpu_client_config.json | 81 + .../v1/src/v1/tpu_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../google-cloud-tpu/v1/test/gapic_tpu_v1.ts | 2672 +++++++++++++++++ .../google-cloud-tpu/v1/tsconfig.json | 19 + .../google-cloud-tpu/v1/webpack.config.js | 64 + .../google-cloud-tpu/v2alpha1/.eslintignore | 7 + .../google-cloud-tpu/v2alpha1/.eslintrc.json | 3 + .../google-cloud-tpu/v2alpha1/.gitignore | 14 + .../google-cloud-tpu/v2alpha1/.jsdoc.js | 55 + .../google-cloud-tpu/v2alpha1/.mocharc.js | 33 + .../google-cloud-tpu/v2alpha1/.prettierrc.js | 22 + .../google-cloud-tpu/v2alpha1/README.md | 1 + .../v2alpha1/linkinator.config.json | 16 + .../google-cloud-tpu/v2alpha1/package.json | 64 + .../google/cloud/tpu/v2alpha1/cloud_tpu.proto | 791 +++++ ...et_metadata.google.cloud.tpu.v2alpha1.json | 595 ++++ .../generated/v2alpha1/tpu.create_node.js | 71 + .../generated/v2alpha1/tpu.delete_node.js | 62 + .../v2alpha1/tpu.generate_service_identity.js | 61 + .../v2alpha1/tpu.get_accelerator_type.js | 61 + .../v2alpha1/tpu.get_guest_attributes.js | 70 + .../generated/v2alpha1/tpu.get_node.js | 61 + .../v2alpha1/tpu.get_runtime_version.js | 61 + .../v2alpha1/tpu.list_accelerator_types.js | 79 + .../generated/v2alpha1/tpu.list_nodes.js | 71 + .../v2alpha1/tpu.list_runtime_versions.js | 79 + .../generated/v2alpha1/tpu.start_node.js | 61 + .../generated/v2alpha1/tpu.stop_node.js | 61 + .../generated/v2alpha1/tpu.update_node.js | 68 + .../google-cloud-tpu/v2alpha1/src/index.ts | 25 + .../v2alpha1/src/v2alpha1/gapic_metadata.json | 165 + .../v2alpha1/src/v2alpha1/index.ts | 19 + .../v2alpha1/src/v2alpha1/tpu_client.ts | 1955 ++++++++++++ .../src/v2alpha1/tpu_client_config.json | 91 + .../v2alpha1/src/v2alpha1/tpu_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v2alpha1/system-test/install.ts | 49 + .../v2alpha1/test/gapic_tpu_v2alpha1.ts | 2441 +++++++++++++++ .../google-cloud-tpu/v2alpha1/tsconfig.json | 19 + .../v2alpha1/webpack.config.js | 64 + 70 files changed, 14655 insertions(+) create mode 100644 owl-bot-staging/google-cloud-tpu/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/README.md create mode 100644 owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/package.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-tpu/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/README.md create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/package.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-tpu/v1/.eslintignore b/owl-bot-staging/google-cloud-tpu/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json b/owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/.gitignore b/owl-bot-staging/google-cloud-tpu/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js b/owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js new file mode 100644 index 00000000000..5b3c57ae725 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/tpu', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-tpu/v1/.mocharc.js b/owl-bot-staging/google-cloud-tpu/v1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js b/owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/README.md b/owl-bot-staging/google-cloud-tpu/v1/README.md new file mode 100644 index 00000000000..b04db0dc280 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/README.md @@ -0,0 +1 @@ +Tpu: Nodejs Client diff --git a/owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json b/owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/package.json b/owl-bot-staging/google-cloud-tpu/v1/package.json new file mode 100644 index 00000000000..911441f5cee --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/tpu", + "version": "0.1.0", + "description": "Tpu client for Node.js", + "repository": "googleapis/nodejs-tpu", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google tpu", + "tpu", + "tpu" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto b/owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto new file mode 100644 index 00000000000..c2acf92f439 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto @@ -0,0 +1,617 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.tpu.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/tpu/v1;tpu"; +option java_multiple_files = true; +option java_outer_classname = "CloudTpuProto"; +option java_package = "com.google.cloud.tpu.v1"; + +// Manages TPU nodes and other resources +// +// TPU API v1 +service Tpu { + option (google.api.default_host) = "tpu.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists nodes. + rpc ListNodes(ListNodesRequest) returns (ListNodesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/nodes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the details of a node. + rpc GetNode(GetNodeRequest) returns (Node) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/nodes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a node. + rpc CreateNode(CreateNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/nodes" + body: "node" + }; + option (google.api.method_signature) = "parent,node,node_id"; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a node. + rpc DeleteNode(DeleteNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/nodes/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Reimages a node's OS. + rpc ReimageNode(ReimageNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/nodes/*}:reimage" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Stops a node, this operation is only available with single TPU nodes. + rpc StopNode(StopNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/nodes/*}:stop" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Starts a node. + rpc StartNode(StartNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/nodes/*}:start" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // List TensorFlow versions supported by this API. + rpc ListTensorFlowVersions(ListTensorFlowVersionsRequest) returns (ListTensorFlowVersionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/tensorflowVersions" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets TensorFlow Version. + rpc GetTensorFlowVersion(GetTensorFlowVersionRequest) returns (TensorFlowVersion) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/tensorflowVersions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists accelerator types supported by this API. + rpc ListAcceleratorTypes(ListAcceleratorTypesRequest) returns (ListAcceleratorTypesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/acceleratorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets AcceleratorType. + rpc GetAcceleratorType(GetAcceleratorTypeRequest) returns (AcceleratorType) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/acceleratorTypes/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Sets the scheduling options for this node. +message SchedulingConfig { + // Defines whether the node is preemptible. + bool preemptible = 1; + + // Whether the node is created under a reservation. + bool reserved = 2; +} + +// A network endpoint over which a TPU worker can be reached. +message NetworkEndpoint { + // The IP address of this network endpoint. + string ip_address = 1; + + // The port of this network endpoint. + int32 port = 2; +} + +// A TPU instance. +message Node { + option (google.api.resource) = { + type: "tpu.googleapis.com/Node" + pattern: "projects/{project}/locations/{location}/nodes/{node}" + }; + + // Represents the different states of a TPU node during its lifecycle. + enum State { + // TPU node state is not known/set. + STATE_UNSPECIFIED = 0; + + // TPU node is being created. + CREATING = 1; + + // TPU node has been created. + READY = 2; + + // TPU node is restarting. + RESTARTING = 3; + + // TPU node is undergoing reimaging. + REIMAGING = 4; + + // TPU node is being deleted. + DELETING = 5; + + // TPU node is being repaired and may be unusable. Details can be + // found in the `help_description` field. + REPAIRING = 6; + + // TPU node is stopped. + STOPPED = 8; + + // TPU node is currently stopping. + STOPPING = 9; + + // TPU node is currently starting. + STARTING = 10; + + // TPU node has been preempted. Only applies to Preemptible TPU Nodes. + PREEMPTED = 11; + + // TPU node has been terminated due to maintenance or has reached the end of + // its life cycle (for preemptible nodes). + TERMINATED = 12; + + // TPU node is currently hiding. + HIDING = 13; + + // TPU node has been hidden. + HIDDEN = 14; + + // TPU node is currently unhiding. + UNHIDING = 15; + } + + // Health defines the status of a TPU node as reported by + // Health Monitor. + enum Health { + // Health status is unknown: not initialized or failed to retrieve. + HEALTH_UNSPECIFIED = 0; + + // The resource is healthy. + HEALTHY = 1; + + // The resource is unhealthy. + DEPRECATED_UNHEALTHY = 2; + + // The resource is unresponsive. + TIMEOUT = 3; + + // The in-guest ML stack is unhealthy. + UNHEALTHY_TENSORFLOW = 4; + + // The node is under maintenance/priority boost caused rescheduling and + // will resume running once rescheduled. + UNHEALTHY_MAINTENANCE = 5; + } + + // TPU API Version. + enum ApiVersion { + // API version is unknown. + API_VERSION_UNSPECIFIED = 0; + + // TPU API V1Alpha1 version. + V1_ALPHA1 = 1; + + // TPU API V1 version. + V1 = 2; + + // TPU API V2Alpha1 version. + V2_ALPHA1 = 3; + } + + // Output only. Immutable. The name of the TPU + string name = 1 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // The user-supplied description of the TPU. Maximum of 512 characters. + string description = 3; + + // Required. The type of hardware accelerators associated with this node. + string accelerator_type = 5 [(google.api.field_behavior) = REQUIRED]; + + // Output only. DEPRECATED! Use network_endpoints instead. + // The network address for the TPU Node as visible to Compute Engine + // instances. + string ip_address = 8 [deprecated = true]; + + // Output only. DEPRECATED! Use network_endpoints instead. + // The network port for the TPU Node as visible to Compute Engine instances. + string port = 14 [deprecated = true]; + + // Output only. The current state for the TPU Node. + State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If this field is populated, it contains a description of why the TPU Node + // is unhealthy. + string health_description = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The version of Tensorflow running in the Node. + string tensorflow_version = 11 [(google.api.field_behavior) = REQUIRED]; + + // The name of a network they wish to peer the TPU node to. It must be a + // preexisting Compute Engine network inside of the project on which this API + // has been activated. If none is provided, "default" will be used. + string network = 12; + + // The CIDR block that the TPU node will use when selecting an IP address. + // This CIDR block must be a /29 block; the Compute Engine networks API + // forbids a smaller block, and using a larger block would be wasteful (a + // node can only consume one IP address). Errors will occur if the CIDR block + // has already been used for a currently existing TPU node, the CIDR block + // conflicts with any subnetworks in the user's provided network, or the + // provided network is peered with another network that is using that CIDR + // block. + string cidr_block = 13; + + // Output only. The service account used to run the tensor flow services within the node. + // To share resources, including Google Cloud Storage data, with the + // Tensorflow job running in the Node, this account must have permissions to + // that data. + string service_account = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the node was created. + google.protobuf.Timestamp create_time = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The scheduling options for this node. + SchedulingConfig scheduling_config = 17; + + // Output only. The network endpoints where TPU workers can be accessed and + // sent work. It is recommended that Tensorflow clients of the node reach out + // to the 0th entry in this map first. + repeated NetworkEndpoint network_endpoints = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The health status of the TPU node. + Health health = 22; + + // Resource labels to represent user-provided metadata. + map labels = 24; + + // Whether the VPC peering for the node is set up through Service Networking + // API. The VPC Peering should be set up before provisioning the node. + // If this field is set, cidr_block field should not be specified. If the + // network, that you want to peer the TPU Node to, is Shared VPC networks, + // the node must be created with this this field enabled. + bool use_service_networking = 27; + + // Output only. The API version that created this Node. + ApiVersion api_version = 38 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Symptoms that have occurred to the TPU Node. + repeated Symptom symptoms = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Request for [ListNodes][google.cloud.tpu.v1.Tpu.ListNodes]. +message ListNodesRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "tpu.googleapis.com/Node" + } + ]; + + // The maximum number of items to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; +} + +// Response for [ListNodes][google.cloud.tpu.v1.Tpu.ListNodes]. +message ListNodesResponse { + // The listed nodes. + repeated Node nodes = 1; + + // The next page token or empty if none. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for [GetNode][google.cloud.tpu.v1.Tpu.GetNode]. +message GetNodeRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/Node" + } + ]; +} + +// Request for [CreateNode][google.cloud.tpu.v1.Tpu.CreateNode]. +message CreateNodeRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "tpu.googleapis.com/Node" + } + ]; + + // The unqualified resource name. + string node_id = 2; + + // Required. The node. + Node node = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [DeleteNode][google.cloud.tpu.v1.Tpu.DeleteNode]. +message DeleteNodeRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/Node" + } + ]; +} + +// Request for [ReimageNode][google.cloud.tpu.v1.Tpu.ReimageNode]. +message ReimageNodeRequest { + // The resource name. + string name = 1; + + // The version for reimage to create. + string tensorflow_version = 2; +} + +// Request for [StopNode][google.cloud.tpu.v1.Tpu.StopNode]. +message StopNodeRequest { + // The resource name. + string name = 1; +} + +// Request for [StartNode][google.cloud.tpu.v1.Tpu.StartNode]. +message StartNodeRequest { + // The resource name. + string name = 1; +} + +// A tensorflow version that a Node can be configured with. +message TensorFlowVersion { + option (google.api.resource) = { + type: "tpu.googleapis.com/TensorFlowVersion" + pattern: "projects/{project}/locations/{location}/tensorFlowVersions/{tensor_flow_version}" + }; + + // The resource name. + string name = 1; + + // the tensorflow version. + string version = 2; +} + +// Request for [GetTensorFlowVersion][google.cloud.tpu.v1.Tpu.GetTensorFlowVersion]. +message GetTensorFlowVersionRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/TensorFlowVersion" + } + ]; +} + +// Request for [ListTensorFlowVersions][google.cloud.tpu.v1.Tpu.ListTensorFlowVersions]. +message ListTensorFlowVersionsRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/TensorFlowVersion" + } + ]; + + // The maximum number of items to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; + + // List filter. + string filter = 5; + + // Sort results. + string order_by = 6; +} + +// Response for [ListTensorFlowVersions][google.cloud.tpu.v1.Tpu.ListTensorFlowVersions]. +message ListTensorFlowVersionsResponse { + // The listed nodes. + repeated TensorFlowVersion tensorflow_versions = 1; + + // The next page token or empty if none. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// A accelerator type that a Node can be configured with. +message AcceleratorType { + option (google.api.resource) = { + type: "tpu.googleapis.com/AcceleratorType" + pattern: "projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}" + }; + + // The resource name. + string name = 1; + + // the accelerator type. + string type = 2; +} + +// Request for [GetAcceleratorType][google.cloud.tpu.v1.Tpu.GetAcceleratorType]. +message GetAcceleratorTypeRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/AcceleratorType" + } + ]; +} + +// Request for [ListAcceleratorTypes][google.cloud.tpu.v1.Tpu.ListAcceleratorTypes]. +message ListAcceleratorTypesRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/AcceleratorType" + } + ]; + + // The maximum number of items to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; + + // List filter. + string filter = 5; + + // Sort results. + string order_by = 6; +} + +// Response for [ListAcceleratorTypes][google.cloud.tpu.v1.Tpu.ListAcceleratorTypes]. +message ListAcceleratorTypesResponse { + // The listed nodes. + repeated AcceleratorType accelerator_types = 1; + + // The next page token or empty if none. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Metadata describing an [Operation][google.longrunning.Operation] +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Target of the operation - for example + // projects/project-1/connectivityTests/test-1 + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // Human-readable status of the operation, if any. + string status_detail = 5; + + // Specifies if cancellation was requested for the operation. + bool cancel_requested = 6; + + // API version. + string api_version = 7; +} + +// A Symptom instance. +message Symptom { + // SymptomType represents the different types of Symptoms that a TPU can be + // at. + enum SymptomType { + // Unspecified symptom. + SYMPTOM_TYPE_UNSPECIFIED = 0; + + // TPU VM memory is low. + LOW_MEMORY = 1; + + // TPU runtime is out of memory. + OUT_OF_MEMORY = 2; + + // TPU runtime execution has timed out. + EXECUTE_TIMED_OUT = 3; + + // TPU runtime fails to construct a mesh that recognizes each TPU device's + // neighbors. + MESH_BUILD_FAIL = 4; + + // TPU HBM is out of memory. + HBM_OUT_OF_MEMORY = 5; + + // Abusive behaviors have been identified on the current project. + PROJECT_ABUSE = 6; + } + + // Timestamp when the Symptom is created. + google.protobuf.Timestamp create_time = 1; + + // Type of the Symptom. + SymptomType symptom_type = 2; + + // Detailed information of the current Symptom. + string details = 3; + + // A string used to uniquely distinguish a worker within a TPU node. + string worker_id = 4; +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json new file mode 100644 index 00000000000..749983cd917 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json @@ -0,0 +1,507 @@ +{ + "clientLibrary": { + "name": "nodejs-tpu", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.tpu.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "tpu_v1_generated_Tpu_ListNodes_async", + "title": "Tpu listNodes Sample", + "origin": "API_DEFINITION", + "description": " Lists nodes.", + "canonical": true, + "file": "tpu.list_nodes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListNodes", + "fullName": "google.cloud.tpu.v1.Tpu.ListNodes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v1.ListNodesResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "ListNodes", + "fullName": "google.cloud.tpu.v1.Tpu.ListNodes", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_GetNode_async", + "title": "Tpu getNode Sample", + "origin": "API_DEFINITION", + "description": " Gets the details of a node.", + "canonical": true, + "file": "tpu.get_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetNode", + "fullName": "google.cloud.tpu.v1.Tpu.GetNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v1.Node", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "GetNode", + "fullName": "google.cloud.tpu.v1.Tpu.GetNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_CreateNode_async", + "title": "Tpu createNode Sample", + "origin": "API_DEFINITION", + "description": " Creates a node.", + "canonical": true, + "file": "tpu.create_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateNode", + "fullName": "google.cloud.tpu.v1.Tpu.CreateNode", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "node_id", + "type": "TYPE_STRING" + }, + { + "name": "node", + "type": ".google.cloud.tpu.v1.Node" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "CreateNode", + "fullName": "google.cloud.tpu.v1.Tpu.CreateNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_DeleteNode_async", + "title": "Tpu deleteNode Sample", + "origin": "API_DEFINITION", + "description": " Deletes a node.", + "canonical": true, + "file": "tpu.delete_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteNode", + "fullName": "google.cloud.tpu.v1.Tpu.DeleteNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "DeleteNode", + "fullName": "google.cloud.tpu.v1.Tpu.DeleteNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_ReimageNode_async", + "title": "Tpu reimageNode Sample", + "origin": "API_DEFINITION", + "description": " Reimages a node's OS.", + "canonical": true, + "file": "tpu.reimage_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReimageNode", + "fullName": "google.cloud.tpu.v1.Tpu.ReimageNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "tensorflow_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "ReimageNode", + "fullName": "google.cloud.tpu.v1.Tpu.ReimageNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_StopNode_async", + "title": "Tpu stopNode Sample", + "origin": "API_DEFINITION", + "description": " Stops a node, this operation is only available with single TPU nodes.", + "canonical": true, + "file": "tpu.stop_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopNode", + "fullName": "google.cloud.tpu.v1.Tpu.StopNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "StopNode", + "fullName": "google.cloud.tpu.v1.Tpu.StopNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_StartNode_async", + "title": "Tpu startNode Sample", + "origin": "API_DEFINITION", + "description": " Starts a node.", + "canonical": true, + "file": "tpu.start_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartNode", + "fullName": "google.cloud.tpu.v1.Tpu.StartNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "StartNode", + "fullName": "google.cloud.tpu.v1.Tpu.StartNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_ListTensorFlowVersions_async", + "title": "Tpu listTensorFlowVersions Sample", + "origin": "API_DEFINITION", + "description": " List TensorFlow versions supported by this API.", + "canonical": true, + "file": "tpu.list_tensor_flow_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTensorFlowVersions", + "fullName": "google.cloud.tpu.v1.Tpu.ListTensorFlowVersions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v1.ListTensorFlowVersionsResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "ListTensorFlowVersions", + "fullName": "google.cloud.tpu.v1.Tpu.ListTensorFlowVersions", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_GetTensorFlowVersion_async", + "title": "Tpu getTensorFlowVersion Sample", + "origin": "API_DEFINITION", + "description": " Gets TensorFlow Version.", + "canonical": true, + "file": "tpu.get_tensor_flow_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTensorFlowVersion", + "fullName": "google.cloud.tpu.v1.Tpu.GetTensorFlowVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v1.TensorFlowVersion", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "GetTensorFlowVersion", + "fullName": "google.cloud.tpu.v1.Tpu.GetTensorFlowVersion", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_ListAcceleratorTypes_async", + "title": "Tpu listAcceleratorTypes Sample", + "origin": "API_DEFINITION", + "description": " Lists accelerator types supported by this API.", + "canonical": true, + "file": "tpu.list_accelerator_types.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAcceleratorTypes", + "fullName": "google.cloud.tpu.v1.Tpu.ListAcceleratorTypes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v1.ListAcceleratorTypesResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "ListAcceleratorTypes", + "fullName": "google.cloud.tpu.v1.Tpu.ListAcceleratorTypes", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v1_generated_Tpu_GetAcceleratorType_async", + "title": "Tpu getAcceleratorType Sample", + "origin": "API_DEFINITION", + "description": " Gets AcceleratorType.", + "canonical": true, + "file": "tpu.get_accelerator_type.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAcceleratorType", + "fullName": "google.cloud.tpu.v1.Tpu.GetAcceleratorType", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v1.AcceleratorType", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v1.TpuClient" + }, + "method": { + "shortName": "GetAcceleratorType", + "fullName": "google.cloud.tpu.v1.Tpu.GetAcceleratorType", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v1.Tpu" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js new file mode 100644 index 00000000000..35fcf2bec3a --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, node) { + // [START tpu_v1_generated_Tpu_CreateNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The unqualified resource name. + */ + // const nodeId = 'abc123' + /** + * Required. The node. + */ + // const node = {} + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callCreateNode() { + // Construct request + const request = { + parent, + node, + }; + + // Run request + const [operation] = await tpuClient.createNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateNode(); + // [END tpu_v1_generated_Tpu_CreateNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js new file mode 100644 index 00000000000..ad364cdbb8a --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v1_generated_Tpu_DeleteNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callDeleteNode() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await tpuClient.deleteNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteNode(); + // [END tpu_v1_generated_Tpu_DeleteNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js new file mode 100644 index 00000000000..b2e8afbdd48 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v1_generated_Tpu_GetAcceleratorType_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetAcceleratorType() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getAcceleratorType(request); + console.log(response); + } + + callGetAcceleratorType(); + // [END tpu_v1_generated_Tpu_GetAcceleratorType_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js new file mode 100644 index 00000000000..70b0c8ff589 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v1_generated_Tpu_GetNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetNode() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getNode(request); + console.log(response); + } + + callGetNode(); + // [END tpu_v1_generated_Tpu_GetNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js new file mode 100644 index 00000000000..479389099cd --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v1_generated_Tpu_GetTensorFlowVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetTensorFlowVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getTensorFlowVersion(request); + console.log(response); + } + + callGetTensorFlowVersion(); + // [END tpu_v1_generated_Tpu_GetTensorFlowVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js new file mode 100644 index 00000000000..9458a1aef12 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v1_generated_Tpu_ListAcceleratorTypes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * List filter. + */ + // const filter = 'abc123' + /** + * Sort results. + */ + // const orderBy = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callListAcceleratorTypes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await tpuClient.listAcceleratorTypesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListAcceleratorTypes(); + // [END tpu_v1_generated_Tpu_ListAcceleratorTypes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js new file mode 100644 index 00000000000..c7165073b90 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v1_generated_Tpu_ListNodes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callListNodes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await tpuClient.listNodesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListNodes(); + // [END tpu_v1_generated_Tpu_ListNodes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js new file mode 100644 index 00000000000..6884855a885 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v1_generated_Tpu_ListTensorFlowVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * List filter. + */ + // const filter = 'abc123' + /** + * Sort results. + */ + // const orderBy = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callListTensorFlowVersions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await tpuClient.listTensorFlowVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTensorFlowVersions(); + // [END tpu_v1_generated_Tpu_ListTensorFlowVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js new file mode 100644 index 00000000000..5963a05144d --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js @@ -0,0 +1,65 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START tpu_v1_generated_Tpu_ReimageNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The resource name. + */ + // const name = 'abc123' + /** + * The version for reimage to create. + */ + // const tensorflowVersion = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callReimageNode() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await tpuClient.reimageNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callReimageNode(); + // [END tpu_v1_generated_Tpu_ReimageNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js new file mode 100644 index 00000000000..61d31d20b5a --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START tpu_v1_generated_Tpu_StartNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callStartNode() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await tpuClient.startNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartNode(); + // [END tpu_v1_generated_Tpu_StartNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js new file mode 100644 index 00000000000..e3b7891529f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START tpu_v1_generated_Tpu_StopNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callStopNode() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await tpuClient.stopNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopNode(); + // [END tpu_v1_generated_Tpu_StopNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/index.ts b/owl-bot-staging/google-cloud-tpu/v1/src/index.ts new file mode 100644 index 00000000000..5dedc6879ab --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const TpuClient = v1.TpuClient; +type TpuClient = v1.TpuClient; +export {v1, TpuClient}; +export default {v1, TpuClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..b15f377b942 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json @@ -0,0 +1,145 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.tpu.v1", + "libraryPackage": "@google-cloud/tpu", + "services": { + "Tpu": { + "clients": { + "grpc": { + "libraryClient": "TpuClient", + "rpcs": { + "GetNode": { + "methods": [ + "getNode" + ] + }, + "GetTensorFlowVersion": { + "methods": [ + "getTensorFlowVersion" + ] + }, + "GetAcceleratorType": { + "methods": [ + "getAcceleratorType" + ] + }, + "CreateNode": { + "methods": [ + "createNode" + ] + }, + "DeleteNode": { + "methods": [ + "deleteNode" + ] + }, + "ReimageNode": { + "methods": [ + "reimageNode" + ] + }, + "StopNode": { + "methods": [ + "stopNode" + ] + }, + "StartNode": { + "methods": [ + "startNode" + ] + }, + "ListNodes": { + "methods": [ + "listNodes", + "listNodesStream", + "listNodesAsync" + ] + }, + "ListTensorFlowVersions": { + "methods": [ + "listTensorFlowVersions", + "listTensorFlowVersionsStream", + "listTensorFlowVersionsAsync" + ] + }, + "ListAcceleratorTypes": { + "methods": [ + "listAcceleratorTypes", + "listAcceleratorTypesStream", + "listAcceleratorTypesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TpuClient", + "rpcs": { + "GetNode": { + "methods": [ + "getNode" + ] + }, + "GetTensorFlowVersion": { + "methods": [ + "getTensorFlowVersion" + ] + }, + "GetAcceleratorType": { + "methods": [ + "getAcceleratorType" + ] + }, + "CreateNode": { + "methods": [ + "createNode" + ] + }, + "DeleteNode": { + "methods": [ + "deleteNode" + ] + }, + "ReimageNode": { + "methods": [ + "reimageNode" + ] + }, + "StopNode": { + "methods": [ + "stopNode" + ] + }, + "StartNode": { + "methods": [ + "startNode" + ] + }, + "ListNodes": { + "methods": [ + "listNodes", + "listNodesStream", + "listNodesAsync" + ] + }, + "ListTensorFlowVersions": { + "methods": [ + "listTensorFlowVersions", + "listTensorFlowVersionsStream", + "listTensorFlowVersionsAsync" + ] + }, + "ListAcceleratorTypes": { + "methods": [ + "listAcceleratorTypes", + "listAcceleratorTypesStream", + "listAcceleratorTypesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts new file mode 100644 index 00000000000..27c81814923 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {TpuClient} from './tpu_client'; diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts new file mode 100644 index 00000000000..9bd1d3dc3bd --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts @@ -0,0 +1,2091 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/tpu_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tpu_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages TPU nodes and other resources + * + * TPU API v1 + * @class + * @memberof v1 + */ +export class TpuClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tpuStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TpuClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TpuClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TpuClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + acceleratorTypePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + nodePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/nodes/{node}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tensorFlowVersionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/tensorFlowVersions/{tensor_flow_version}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listNodes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'nodes'), + listTensorFlowVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tensorflowVersions'), + listAcceleratorTypes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'acceleratorTypes') + }; + + 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 lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; + const createNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; + const deleteNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; + const deleteNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; + const reimageNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; + const reimageNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; + const stopNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; + const stopNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; + const startNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; + const startNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createNodeResponse.decode.bind(createNodeResponse), + createNodeMetadata.decode.bind(createNodeMetadata)), + deleteNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteNodeResponse.decode.bind(deleteNodeResponse), + deleteNodeMetadata.decode.bind(deleteNodeMetadata)), + reimageNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reimageNodeResponse.decode.bind(reimageNodeResponse), + reimageNodeMetadata.decode.bind(reimageNodeMetadata)), + stopNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopNodeResponse.decode.bind(stopNodeResponse), + stopNodeMetadata.decode.bind(stopNodeMetadata)), + startNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startNodeResponse.decode.bind(startNodeResponse), + startNodeMetadata.decode.bind(startNodeMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.tpu.v1.Tpu', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.tpuStub) { + return this.tpuStub; + } + + // Put together the "service stub" for + // google.cloud.tpu.v1.Tpu. + this.tpuStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.tpu.v1.Tpu') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.tpu.v1.Tpu, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const tpuStubMethods = + ['listNodes', 'getNode', 'createNode', 'deleteNode', 'reimageNode', 'stopNode', 'startNode', 'listTensorFlowVersions', 'getTensorFlowVersion', 'listAcceleratorTypes', 'getAcceleratorType']; + for (const methodName of tpuStubMethods) { + const callPromise = this.tpuStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.tpuStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'tpu.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'tpu.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets the details of a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Node]{@link google.cloud.tpu.v1.Node}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/tpu.get_node.js + * region_tag:tpu_v1_generated_Tpu_GetNode_async + */ + getNode( + request?: protos.google.cloud.tpu.v1.IGetNodeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v1.INode, + protos.google.cloud.tpu.v1.IGetNodeRequest|undefined, {}|undefined + ]>; + getNode( + request: protos.google.cloud.tpu.v1.IGetNodeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v1.INode, + protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, + {}|null|undefined>): void; + getNode( + request: protos.google.cloud.tpu.v1.IGetNodeRequest, + callback: Callback< + protos.google.cloud.tpu.v1.INode, + protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, + {}|null|undefined>): void; + getNode( + request?: protos.google.cloud.tpu.v1.IGetNodeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v1.INode, + protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v1.INode, + protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v1.INode, + protos.google.cloud.tpu.v1.IGetNodeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getNode(request, options, callback); + } +/** + * Gets TensorFlow Version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/tpu.get_tensor_flow_version.js + * region_tag:tpu_v1_generated_Tpu_GetTensorFlowVersion_async + */ + getTensorFlowVersion( + request?: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v1.ITensorFlowVersion, + protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|undefined, {}|undefined + ]>; + getTensorFlowVersion( + request: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v1.ITensorFlowVersion, + protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, + {}|null|undefined>): void; + getTensorFlowVersion( + request: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, + callback: Callback< + protos.google.cloud.tpu.v1.ITensorFlowVersion, + protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, + {}|null|undefined>): void; + getTensorFlowVersion( + request?: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v1.ITensorFlowVersion, + protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v1.ITensorFlowVersion, + protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v1.ITensorFlowVersion, + protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getTensorFlowVersion(request, options, callback); + } +/** + * Gets AcceleratorType. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/tpu.get_accelerator_type.js + * region_tag:tpu_v1_generated_Tpu_GetAcceleratorType_async + */ + getAcceleratorType( + request?: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v1.IAcceleratorType, + protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|undefined, {}|undefined + ]>; + getAcceleratorType( + request: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v1.IAcceleratorType, + protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): void; + getAcceleratorType( + request: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, + callback: Callback< + protos.google.cloud.tpu.v1.IAcceleratorType, + protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): void; + getAcceleratorType( + request?: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v1.IAcceleratorType, + protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v1.IAcceleratorType, + protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v1.IAcceleratorType, + protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAcceleratorType(request, options, callback); + } + +/** + * Creates a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {string} request.nodeId + * The unqualified resource name. + * @param {google.cloud.tpu.v1.Node} request.node + * Required. The node. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.create_node.js + * region_tag:tpu_v1_generated_Tpu_CreateNode_async + */ + createNode( + request?: protos.google.cloud.tpu.v1.ICreateNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createNode( + request: protos.google.cloud.tpu.v1.ICreateNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createNode( + request: protos.google.cloud.tpu.v1.ICreateNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createNode( + request?: protos.google.cloud.tpu.v1.ICreateNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.create_node.js + * region_tag:tpu_v1_generated_Tpu_CreateNode_async + */ + async checkCreateNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.delete_node.js + * region_tag:tpu_v1_generated_Tpu_DeleteNode_async + */ + deleteNode( + request?: protos.google.cloud.tpu.v1.IDeleteNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteNode( + request: protos.google.cloud.tpu.v1.IDeleteNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteNode( + request: protos.google.cloud.tpu.v1.IDeleteNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteNode( + request?: protos.google.cloud.tpu.v1.IDeleteNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.delete_node.js + * region_tag:tpu_v1_generated_Tpu_DeleteNode_async + */ + async checkDeleteNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Reimages a node's OS. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name. + * @param {string} request.tensorflowVersion + * The version for reimage to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.reimage_node.js + * region_tag:tpu_v1_generated_Tpu_ReimageNode_async + */ + reimageNode( + request?: protos.google.cloud.tpu.v1.IReimageNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + reimageNode( + request: protos.google.cloud.tpu.v1.IReimageNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reimageNode( + request: protos.google.cloud.tpu.v1.IReimageNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reimageNode( + request?: protos.google.cloud.tpu.v1.IReimageNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.reimageNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `reimageNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.reimage_node.js + * region_tag:tpu_v1_generated_Tpu_ReimageNode_async + */ + async checkReimageNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reimageNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops a node, this operation is only available with single TPU nodes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.stop_node.js + * region_tag:tpu_v1_generated_Tpu_StopNode_async + */ + stopNode( + request?: protos.google.cloud.tpu.v1.IStopNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopNode( + request: protos.google.cloud.tpu.v1.IStopNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopNode( + request: protos.google.cloud.tpu.v1.IStopNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopNode( + request?: protos.google.cloud.tpu.v1.IStopNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `stopNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.stop_node.js + * region_tag:tpu_v1_generated_Tpu_StopNode_async + */ + async checkStopNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.stopNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.start_node.js + * region_tag:tpu_v1_generated_Tpu_StartNode_async + */ + startNode( + request?: protos.google.cloud.tpu.v1.IStartNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startNode( + request: protos.google.cloud.tpu.v1.IStartNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startNode( + request: protos.google.cloud.tpu.v1.IStartNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startNode( + request?: protos.google.cloud.tpu.v1.IStartNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.startNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `startNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/tpu.start_node.js + * region_tag:tpu_v1_generated_Tpu_StartNode_async + */ + async checkStartNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.startNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists nodes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Node]{@link google.cloud.tpu.v1.Node}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNodes( + request?: protos.google.cloud.tpu.v1.IListNodesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v1.INode[], + protos.google.cloud.tpu.v1.IListNodesRequest|null, + protos.google.cloud.tpu.v1.IListNodesResponse + ]>; + listNodes( + request: protos.google.cloud.tpu.v1.IListNodesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tpu.v1.IListNodesRequest, + protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v1.INode>): void; + listNodes( + request: protos.google.cloud.tpu.v1.IListNodesRequest, + callback: PaginationCallback< + protos.google.cloud.tpu.v1.IListNodesRequest, + protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v1.INode>): void; + listNodes( + request?: protos.google.cloud.tpu.v1.IListNodesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.tpu.v1.IListNodesRequest, + protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v1.INode>, + callback?: PaginationCallback< + protos.google.cloud.tpu.v1.IListNodesRequest, + protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v1.INode>): + Promise<[ + protos.google.cloud.tpu.v1.INode[], + protos.google.cloud.tpu.v1.IListNodesRequest|null, + protos.google.cloud.tpu.v1.IListNodesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listNodes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Node]{@link google.cloud.tpu.v1.Node} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNodesStream( + request?: protos.google.cloud.tpu.v1.IListNodesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listNodes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNodes.createStream( + this.innerApiCalls.listNodes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNodes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Node]{@link google.cloud.tpu.v1.Node}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/tpu.list_nodes.js + * region_tag:tpu_v1_generated_Tpu_ListNodes_async + */ + listNodesAsync( + request?: protos.google.cloud.tpu.v1.IListNodesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listNodes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNodes.asyncIterate( + this.innerApiCalls['listNodes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List TensorFlow versions supported by this API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTensorFlowVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listTensorFlowVersions( + request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v1.ITensorFlowVersion[], + protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest|null, + protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse + ]>; + listTensorFlowVersions( + request: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, + protos.google.cloud.tpu.v1.ITensorFlowVersion>): void; + listTensorFlowVersions( + request: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, + protos.google.cloud.tpu.v1.ITensorFlowVersion>): void; + listTensorFlowVersions( + request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, + protos.google.cloud.tpu.v1.ITensorFlowVersion>, + callback?: PaginationCallback< + protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, + protos.google.cloud.tpu.v1.ITensorFlowVersion>): + Promise<[ + protos.google.cloud.tpu.v1.ITensorFlowVersion[], + protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest|null, + protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listTensorFlowVersions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTensorFlowVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listTensorFlowVersionsStream( + request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listTensorFlowVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTensorFlowVersions.createStream( + this.innerApiCalls.listTensorFlowVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTensorFlowVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/tpu.list_tensor_flow_versions.js + * region_tag:tpu_v1_generated_Tpu_ListTensorFlowVersions_async + */ + listTensorFlowVersionsAsync( + request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listTensorFlowVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTensorFlowVersions.asyncIterate( + this.innerApiCalls['listTensorFlowVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists accelerator types supported by this API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAcceleratorTypesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listAcceleratorTypes( + request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v1.IAcceleratorType[], + protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest|null, + protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse + ]>; + listAcceleratorTypes( + request: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v1.IAcceleratorType>): void; + listAcceleratorTypes( + request: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + callback: PaginationCallback< + protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v1.IAcceleratorType>): void; + listAcceleratorTypes( + request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v1.IAcceleratorType>, + callback?: PaginationCallback< + protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v1.IAcceleratorType>): + Promise<[ + protos.google.cloud.tpu.v1.IAcceleratorType[], + protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest|null, + protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listAcceleratorTypes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAcceleratorTypesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listAcceleratorTypesStream( + request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listAcceleratorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAcceleratorTypes.createStream( + this.innerApiCalls.listAcceleratorTypes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listAcceleratorTypes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/tpu.list_accelerator_types.js + * region_tag:tpu_v1_generated_Tpu_ListAcceleratorTypes_async + */ + listAcceleratorTypesAsync( + request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listAcceleratorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAcceleratorTypes.asyncIterate( + this.innerApiCalls['listAcceleratorTypes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified acceleratorType resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} accelerator_type + * @returns {string} Resource name string. + */ + acceleratorTypePath(project:string,location:string,acceleratorType:string) { + return this.pathTemplates.acceleratorTypePathTemplate.render({ + project: project, + location: location, + accelerator_type: acceleratorType, + }); + } + + /** + * Parse the project from AcceleratorType resource. + * + * @param {string} acceleratorTypeName + * A fully-qualified path representing AcceleratorType resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAcceleratorTypeName(acceleratorTypeName: string) { + return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).project; + } + + /** + * Parse the location from AcceleratorType resource. + * + * @param {string} acceleratorTypeName + * A fully-qualified path representing AcceleratorType resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAcceleratorTypeName(acceleratorTypeName: string) { + return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).location; + } + + /** + * Parse the accelerator_type from AcceleratorType resource. + * + * @param {string} acceleratorTypeName + * A fully-qualified path representing AcceleratorType resource. + * @returns {string} A string representing the accelerator_type. + */ + matchAcceleratorTypeFromAcceleratorTypeName(acceleratorTypeName: string) { + return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).accelerator_type; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified node resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} node + * @returns {string} Resource name string. + */ + nodePath(project:string,location:string,node:string) { + return this.pathTemplates.nodePathTemplate.render({ + project: project, + location: location, + node: node, + }); + } + + /** + * Parse the project from Node resource. + * + * @param {string} nodeName + * A fully-qualified path representing Node resource. + * @returns {string} A string representing the project. + */ + matchProjectFromNodeName(nodeName: string) { + return this.pathTemplates.nodePathTemplate.match(nodeName).project; + } + + /** + * Parse the location from Node resource. + * + * @param {string} nodeName + * A fully-qualified path representing Node resource. + * @returns {string} A string representing the location. + */ + matchLocationFromNodeName(nodeName: string) { + return this.pathTemplates.nodePathTemplate.match(nodeName).location; + } + + /** + * Parse the node from Node resource. + * + * @param {string} nodeName + * A fully-qualified path representing Node resource. + * @returns {string} A string representing the node. + */ + matchNodeFromNodeName(nodeName: string) { + return this.pathTemplates.nodePathTemplate.match(nodeName).node; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tensorFlowVersion resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} tensor_flow_version + * @returns {string} Resource name string. + */ + tensorFlowVersionPath(project:string,location:string,tensorFlowVersion:string) { + return this.pathTemplates.tensorFlowVersionPathTemplate.render({ + project: project, + location: location, + tensor_flow_version: tensorFlowVersion, + }); + } + + /** + * Parse the project from TensorFlowVersion resource. + * + * @param {string} tensorFlowVersionName + * A fully-qualified path representing TensorFlowVersion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTensorFlowVersionName(tensorFlowVersionName: string) { + return this.pathTemplates.tensorFlowVersionPathTemplate.match(tensorFlowVersionName).project; + } + + /** + * Parse the location from TensorFlowVersion resource. + * + * @param {string} tensorFlowVersionName + * A fully-qualified path representing TensorFlowVersion resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTensorFlowVersionName(tensorFlowVersionName: string) { + return this.pathTemplates.tensorFlowVersionPathTemplate.match(tensorFlowVersionName).location; + } + + /** + * Parse the tensor_flow_version from TensorFlowVersion resource. + * + * @param {string} tensorFlowVersionName + * A fully-qualified path representing TensorFlowVersion resource. + * @returns {string} A string representing the tensor_flow_version. + */ + matchTensorFlowVersionFromTensorFlowVersionName(tensorFlowVersionName: string) { + return this.pathTemplates.tensorFlowVersionPathTemplate.match(tensorFlowVersionName).tensor_flow_version; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.tpuStub && !this._terminated) { + return this.tpuStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json new file mode 100644 index 00000000000..77bd991e873 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json @@ -0,0 +1,81 @@ +{ + "interfaces": { + "google.cloud.tpu.v1.Tpu": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListNodes": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReimageNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListTensorFlowVersions": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetTensorFlowVersion": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListAcceleratorTypes": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAcceleratorType": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json new file mode 100644 index 00000000000..c79018be060 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/tpu/v1/cloud_tpu.proto" +] diff --git a/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..9cb87c17e68 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const tpu = require('@google-cloud/tpu'); + +function main() { + const tpuClient = new tpu.TpuClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..50ac473b84f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {TpuClient} from '@google-cloud/tpu'; + +// check that the client class type name can be used +function doStuffWithTpuClient(client: TpuClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const tpuClient = new TpuClient(); + doStuffWithTpuClient(tpuClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts b/owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts b/owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts new file mode 100644 index 00000000000..b3743be7903 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts @@ -0,0 +1,2672 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as tpuModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.TpuClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tpuModule.v1.TpuClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tpuModule.v1.TpuClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tpuModule.v1.TpuClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tpuModule.v1.TpuClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tpuModule.v1.TpuClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tpuStub, undefined); + await client.initialize(); + assert(client.tpuStub); + }); + + it('has close method for the initialized client', done => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tpuStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tpuStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getNode', () => { + it('invokes getNode without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v1.Node() + ); + client.innerApiCalls.getNode = stubSimpleCall(expectedResponse); + const [response] = await client.getNode(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNode without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v1.Node() + ); + client.innerApiCalls.getNode = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNode( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v1.INode|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNode with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getNode = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNode(request), expectedError); + const actualRequest = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNode with closed client', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getNode(request), expectedError); + }); + }); + + describe('getTensorFlowVersion', () => { + it('invokes getTensorFlowVersion without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v1.TensorFlowVersion() + ); + client.innerApiCalls.getTensorFlowVersion = stubSimpleCall(expectedResponse); + const [response] = await client.getTensorFlowVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTensorFlowVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTensorFlowVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTensorFlowVersion without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v1.TensorFlowVersion() + ); + client.innerApiCalls.getTensorFlowVersion = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTensorFlowVersion( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v1.ITensorFlowVersion|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTensorFlowVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTensorFlowVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTensorFlowVersion with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTensorFlowVersion = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTensorFlowVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.getTensorFlowVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTensorFlowVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTensorFlowVersion with closed client', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTensorFlowVersion(request), expectedError); + }); + }); + + describe('getAcceleratorType', () => { + it('invokes getAcceleratorType without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v1.AcceleratorType() + ); + client.innerApiCalls.getAcceleratorType = stubSimpleCall(expectedResponse); + const [response] = await client.getAcceleratorType(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAcceleratorType without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v1.AcceleratorType() + ); + client.innerApiCalls.getAcceleratorType = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAcceleratorType( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v1.IAcceleratorType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAcceleratorType with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAcceleratorType = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAcceleratorType(request), expectedError); + const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAcceleratorType with closed client', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAcceleratorType(request), expectedError); + }); + }); + + describe('createNode', () => { + it('invokes createNode without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.createNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNode without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNode with call error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createNode(request), expectedError); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNode with LRO error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateNodeProgress without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateNodeProgress with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteNode', () => { + it('invokes deleteNode without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNode without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNode with call error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteNode(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNode with LRO error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteNodeProgress without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteNodeProgress with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('reimageNode', () => { + it('invokes reimageNode without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ReimageNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reimageNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.reimageNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reimageNode without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ReimageNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.reimageNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reimageNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reimageNode with call error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ReimageNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reimageNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reimageNode(request), expectedError); + const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reimageNode with LRO error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ReimageNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reimageNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reimageNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkReimageNodeProgress without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkReimageNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkReimageNodeProgress with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkReimageNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopNode', () => { + it('invokes stopNode without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopNode without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopNode with call error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopNode(request), expectedError); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopNode with LRO error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopNodeProgress without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStopNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopNodeProgress with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startNode', () => { + it('invokes startNode without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.startNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startNode without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startNode with call error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startNode(request), expectedError); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startNode with LRO error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartNodeProgress without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartNodeProgress with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listNodes', () => { + it('invokes listNodes without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + ]; + client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); + const [response] = await client.listNodes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodes without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + ]; + client.innerApiCalls.listNodes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNodes( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v1.INode[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodes with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNodes(request), expectedError); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodesStream without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + ]; + client.descriptors.page.listNodes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v1.Node[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v1.Node) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listNodesStream with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v1.Node[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v1.Node) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNodes without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), + ]; + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tpu.v1.INode[] = []; + const iterable = client.listNodesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNodes with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNodesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tpu.v1.INode[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listTensorFlowVersions', () => { + it('invokes listTensorFlowVersions without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + ]; + client.innerApiCalls.listTensorFlowVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listTensorFlowVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTensorFlowVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTensorFlowVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTensorFlowVersions without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + ]; + client.innerApiCalls.listTensorFlowVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTensorFlowVersions( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v1.ITensorFlowVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTensorFlowVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTensorFlowVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTensorFlowVersions with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTensorFlowVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTensorFlowVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.listTensorFlowVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTensorFlowVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTensorFlowVersionsStream without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + ]; + client.descriptors.page.listTensorFlowVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTensorFlowVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v1.TensorFlowVersion[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v1.TensorFlowVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTensorFlowVersions, request)); + assert( + (client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listTensorFlowVersionsStream with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTensorFlowVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTensorFlowVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v1.TensorFlowVersion[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v1.TensorFlowVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTensorFlowVersions, request)); + assert( + (client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTensorFlowVersions without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), + ]; + client.descriptors.page.listTensorFlowVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tpu.v1.ITensorFlowVersion[] = []; + const iterable = client.listTensorFlowVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTensorFlowVersions with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTensorFlowVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTensorFlowVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tpu.v1.ITensorFlowVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listAcceleratorTypes', () => { + it('invokes listAcceleratorTypes without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + ]; + client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(expectedResponse); + const [response] = await client.listAcceleratorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAcceleratorTypes without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + ]; + client.innerApiCalls.listAcceleratorTypes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAcceleratorTypes( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v1.IAcceleratorType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAcceleratorTypes with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAcceleratorTypes(request), expectedError); + const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAcceleratorTypesStream without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + ]; + client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listAcceleratorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v1.AcceleratorType[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v1.AcceleratorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); + assert( + (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listAcceleratorTypesStream with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listAcceleratorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v1.AcceleratorType[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v1.AcceleratorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); + assert( + (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAcceleratorTypes without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), + ]; + client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tpu.v1.IAcceleratorType[] = []; + const iterable = client.listAcceleratorTypesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAcceleratorTypes with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAcceleratorTypesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tpu.v1.IAcceleratorType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('acceleratorType', () => { + const fakePath = "/rendered/path/acceleratorType"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + accelerator_type: "acceleratorTypeValue", + }; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.acceleratorTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.acceleratorTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('acceleratorTypePath', () => { + const result = client.acceleratorTypePath("projectValue", "locationValue", "acceleratorTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.acceleratorTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAcceleratorTypeName', () => { + const result = client.matchProjectFromAcceleratorTypeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAcceleratorTypeName', () => { + const result = client.matchLocationFromAcceleratorTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAcceleratorTypeFromAcceleratorTypeName', () => { + const result = client.matchAcceleratorTypeFromAcceleratorTypeName(fakePath); + assert.strictEqual(result, "acceleratorTypeValue"); + assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('node', () => { + const fakePath = "/rendered/path/node"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + node: "nodeValue", + }; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.nodePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.nodePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('nodePath', () => { + const result = client.nodePath("projectValue", "locationValue", "nodeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.nodePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromNodeName', () => { + const result = client.matchProjectFromNodeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromNodeName', () => { + const result = client.matchLocationFromNodeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchNodeFromNodeName', () => { + const result = client.matchNodeFromNodeName(fakePath); + assert.strictEqual(result, "nodeValue"); + assert((client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tensorFlowVersion', () => { + const fakePath = "/rendered/path/tensorFlowVersion"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + tensor_flow_version: "tensorFlowVersionValue", + }; + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tensorFlowVersionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tensorFlowVersionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tensorFlowVersionPath', () => { + const result = client.tensorFlowVersionPath("projectValue", "locationValue", "tensorFlowVersionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tensorFlowVersionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTensorFlowVersionName', () => { + const result = client.matchProjectFromTensorFlowVersionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.tensorFlowVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTensorFlowVersionName', () => { + const result = client.matchLocationFromTensorFlowVersionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.tensorFlowVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTensorFlowVersionFromTensorFlowVersionName', () => { + const result = client.matchTensorFlowVersionFromTensorFlowVersionName(fakePath); + assert.strictEqual(result, "tensorFlowVersionValue"); + assert((client.pathTemplates.tensorFlowVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-tpu/v1/tsconfig.json b/owl-bot-staging/google-cloud-tpu/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-tpu/v1/webpack.config.js b/owl-bot-staging/google-cloud-tpu/v1/webpack.config.js new file mode 100644 index 00000000000..8ee514d072f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Tpu', + filename: './tpu.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore b/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore b/owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js new file mode 100644 index 00000000000..5b3c57ae725 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/tpu', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/README.md b/owl-bot-staging/google-cloud-tpu/v2alpha1/README.md new file mode 100644 index 00000000000..b04db0dc280 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/README.md @@ -0,0 +1 @@ +Tpu: Nodejs Client diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/package.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/package.json new file mode 100644 index 00000000000..911441f5cee --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/tpu", + "version": "0.1.0", + "description": "Tpu client for Node.js", + "repository": "googleapis/nodejs-tpu", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google tpu", + "tpu", + "tpu" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto b/owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto new file mode 100644 index 00000000000..612e1c4f5dd --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto @@ -0,0 +1,791 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.tpu.v2alpha1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/tpu/v2alpha1;tpu"; +option java_multiple_files = true; +option java_outer_classname = "CloudTpuProto"; +option java_package = "com.google.cloud.tpu.v2alpha1"; + +// Manages TPU nodes and other resources +// +// TPU API v2alpha1 +service Tpu { + option (google.api.default_host) = "tpu.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists nodes. + rpc ListNodes(ListNodesRequest) returns (ListNodesResponse) { + option (google.api.http) = { + get: "/v2alpha1/{parent=projects/*/locations/*}/nodes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the details of a node. + rpc GetNode(GetNodeRequest) returns (Node) { + option (google.api.http) = { + get: "/v2alpha1/{name=projects/*/locations/*/nodes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a node. + rpc CreateNode(CreateNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha1/{parent=projects/*/locations/*}/nodes" + body: "node" + }; + option (google.api.method_signature) = "parent,node,node_id"; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Deletes a node. + rpc DeleteNode(DeleteNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v2alpha1/{name=projects/*/locations/*/nodes/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Stops a node. This operation is only available with single TPU nodes. + rpc StopNode(StopNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha1/{name=projects/*/locations/*/nodes/*}:stop" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Starts a node. + rpc StartNode(StartNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha1/{name=projects/*/locations/*/nodes/*}:start" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Updates the configurations of a node. + rpc UpdateNode(UpdateNodeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v2alpha1/{node.name=projects/*/locations/*/nodes/*}" + body: "node" + }; + option (google.api.method_signature) = "node,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Node" + metadata_type: "OperationMetadata" + }; + } + + // Generates the Cloud TPU service identity for the project. + rpc GenerateServiceIdentity(GenerateServiceIdentityRequest) + returns (GenerateServiceIdentityResponse) { + option (google.api.http) = { + post: "/v2alpha1/{parent=projects/*/locations/*}:generateServiceIdentity" + body: "*" + }; + } + + // Lists accelerator types supported by this API. + rpc ListAcceleratorTypes(ListAcceleratorTypesRequest) + returns (ListAcceleratorTypesResponse) { + option (google.api.http) = { + get: "/v2alpha1/{parent=projects/*/locations/*}/acceleratorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets AcceleratorType. + rpc GetAcceleratorType(GetAcceleratorTypeRequest) returns (AcceleratorType) { + option (google.api.http) = { + get: "/v2alpha1/{name=projects/*/locations/*/acceleratorTypes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists runtime versions supported by this API. + rpc ListRuntimeVersions(ListRuntimeVersionsRequest) + returns (ListRuntimeVersionsResponse) { + option (google.api.http) = { + get: "/v2alpha1/{parent=projects/*/locations/*}/runtimeVersions" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a runtime version. + rpc GetRuntimeVersion(GetRuntimeVersionRequest) returns (RuntimeVersion) { + option (google.api.http) = { + get: "/v2alpha1/{name=projects/*/locations/*/runtimeVersions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves the guest attributes for the node. + rpc GetGuestAttributes(GetGuestAttributesRequest) + returns (GetGuestAttributesResponse) { + option (google.api.http) = { + post: "/v2alpha1/{name=projects/*/locations/*/nodes/*}:getGuestAttributes" + body: "*" + }; + } +} + +// A guest attributes. +message GuestAttributes { + // The path to be queried. This can be the default namespace ('/') or a + // nested namespace ('/\/') or a specified key + // ('/\/\') + string query_path = 1; + + // The value of the requested queried path. + GuestAttributesValue query_value = 2; +} + +// Array of guest attribute namespace/key/value tuples. +message GuestAttributesValue { + // The list of guest attributes entries. + repeated GuestAttributesEntry items = 1; +} + +// A guest attributes namespace/key/value entry. +message GuestAttributesEntry { + // Namespace for the guest attribute entry. + string namespace = 1; + + // Key for the guest attribute entry. + string key = 2; + + // Value for the guest attribute entry. + string value = 3; +} + +// A node-attached disk resource. +// Next ID: 8; +message AttachedDisk { + // The different mode of the attached disk. + enum DiskMode { + // The disk mode is not known/set. + DISK_MODE_UNSPECIFIED = 0; + + // Attaches the disk in read-write mode. Only one TPU node can attach a disk + // in read-write mode at a time. + READ_WRITE = 1; + + // Attaches the disk in read-only mode. Multiple TPU nodes can attach + // a disk in read-only mode at a time. + READ_ONLY = 2; + } + + // Specifies the full path to an existing disk. + // For example: "projects/my-project/zones/us-central1-c/disks/my-disk". + string source_disk = 3; + + // The mode in which to attach this disk. + // If not specified, the default is READ_WRITE mode. + // Only applicable to data_disks. + DiskMode mode = 4; +} + +// Sets the scheduling options for this node. +message SchedulingConfig { + // Defines whether the node is preemptible. + bool preemptible = 1; + + // Whether the node is created under a reservation. + bool reserved = 2; +} + +// A network endpoint over which a TPU worker can be reached. +message NetworkEndpoint { + // The internal IP address of this network endpoint. + string ip_address = 1; + + // The port of this network endpoint. + int32 port = 2; + + // The access config for the TPU worker. + AccessConfig access_config = 5; +} + +// An access config attached to the TPU worker. +message AccessConfig { + // Output only. An external IP address associated with the TPU worker. + string external_ip = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Network related configurations. +message NetworkConfig { + // The name of the network for the TPU node. It must be a preexisting Google + // Compute Engine network. If none is provided, "default" will be used. + string network = 1; + + // The name of the subnetwork for the TPU node. It must be a preexisting + // Google Compute Engine subnetwork. If none is provided, "default" will be + // used. + string subnetwork = 2; + + // Indicates that external IP addresses would be associated with the TPU + // workers. If set to false, the specified subnetwork or network should have + // Private Google Access enabled. + bool enable_external_ips = 3; +} + +// A service account. +message ServiceAccount { + // Email address of the service account. If empty, default Compute service + // account will be used. + string email = 1; + + // The list of scopes to be made available for this service account. If empty, + // access to all Cloud APIs will be allowed. + repeated string scope = 2; +} + +// A TPU instance. +message Node { + option (google.api.resource) = { + type: "tpu.googleapis.com/Node" + pattern: "projects/{project}/locations/{location}/nodes/{node}" + }; + + // Represents the different states of a TPU node during its lifecycle. + enum State { + // TPU node state is not known/set. + STATE_UNSPECIFIED = 0; + + // TPU node is being created. + CREATING = 1; + + // TPU node has been created. + READY = 2; + + // TPU node is restarting. + RESTARTING = 3; + + // TPU node is undergoing reimaging. + REIMAGING = 4; + + // TPU node is being deleted. + DELETING = 5; + + // TPU node is being repaired and may be unusable. Details can be + // found in the `help_description` field. + REPAIRING = 6; + + // TPU node is stopped. + STOPPED = 8; + + // TPU node is currently stopping. + STOPPING = 9; + + // TPU node is currently starting. + STARTING = 10; + + // TPU node has been preempted. Only applies to Preemptible TPU Nodes. + PREEMPTED = 11; + + // TPU node has been terminated due to maintenance or has reached the end of + // its life cycle (for preemptible nodes). + TERMINATED = 12; + + // TPU node is currently hiding. + HIDING = 13; + + // TPU node has been hidden. + HIDDEN = 14; + + // TPU node is currently unhiding. + UNHIDING = 15; + } + + // Health defines the status of a TPU node as reported by + // Health Monitor. + enum Health { + // Health status is unknown: not initialized or failed to retrieve. + HEALTH_UNSPECIFIED = 0; + + // The resource is healthy. + HEALTHY = 1; + + // The resource is unresponsive. + TIMEOUT = 3; + + // The in-guest ML stack is unhealthy. + UNHEALTHY_TENSORFLOW = 4; + + // The node is under maintenance/priority boost caused rescheduling and + // will resume running once rescheduled. + UNHEALTHY_MAINTENANCE = 5; + } + + // TPU API Version. + enum ApiVersion { + // API version is unknown. + API_VERSION_UNSPECIFIED = 0; + + // TPU API V1Alpha1 version. + V1_ALPHA1 = 1; + + // TPU API V1 version. + V1 = 2; + + // TPU API V2Alpha1 version. + V2_ALPHA1 = 3; + } + + // Output only. Immutable. The name of the TPU. + string name = 1 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE + ]; + + // The user-supplied description of the TPU. Maximum of 512 characters. + string description = 3; + + // Required. The type of hardware accelerators associated with this node. + string accelerator_type = 5 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The current state for the TPU Node. + State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. If this field is populated, it contains a description of why + // the TPU Node is unhealthy. + string health_description = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The runtime version running in the Node. + string runtime_version = 11 [(google.api.field_behavior) = REQUIRED]; + + // Network configurations for the TPU node. + NetworkConfig network_config = 36; + + // The CIDR block that the TPU node will use when selecting an IP address. + // This CIDR block must be a /29 block; the Compute Engine networks API + // forbids a smaller block, and using a larger block would be wasteful (a + // node can only consume one IP address). Errors will occur if the CIDR block + // has already been used for a currently existing TPU node, the CIDR block + // conflicts with any subnetworks in the user's provided network, or the + // provided network is peered with another network that is using that CIDR + // block. + string cidr_block = 13; + + // The Google Cloud Platform Service Account to be used by the TPU node VMs. + // If None is specified, the default compute service account will be used. + ServiceAccount service_account = 37; + + // Output only. The time when the node was created. + google.protobuf.Timestamp create_time = 16 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The scheduling options for this node. + SchedulingConfig scheduling_config = 17; + + // Output only. The network endpoints where TPU workers can be accessed and + // sent work. It is recommended that runtime clients of the node reach out + // to the 0th entry in this map first. + repeated NetworkEndpoint network_endpoints = 21 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The health status of the TPU node. + Health health = 22; + + // Resource labels to represent user-provided metadata. + map labels = 24; + + // Custom metadata to apply to the TPU Node. + // Can set startup-script and shutdown-script + map metadata = 34; + + // Tags to apply to the TPU Node. Tags are used to identify valid sources or + // targets for network firewalls. + repeated string tags = 40; + + // Output only. The unique identifier for the TPU Node. + int64 id = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The additional data disks for the Node. + repeated AttachedDisk data_disks = 41; + + // Output only. The API version that created this Node. + ApiVersion api_version = 38 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The Symptoms that have occurred to the TPU Node. + repeated Symptom symptoms = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Shielded Instance options. + ShieldedInstanceConfig shielded_instance_config = 45; +} + +// Request for [ListNodes][google.cloud.tpu.v2alpha1.Tpu.ListNodes]. +message ListNodesRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } + ]; + + // The maximum number of items to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; +} + +// Response for [ListNodes][google.cloud.tpu.v2alpha1.Tpu.ListNodes]. +message ListNodesResponse { + // The listed nodes. + repeated Node nodes = 1; + + // The next page token or empty if none. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for [GetNode][google.cloud.tpu.v2alpha1.Tpu.GetNode]. +message GetNodeRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } + ]; +} + +// Request for [CreateNode][google.cloud.tpu.v2alpha1.Tpu.CreateNode]. +message CreateNodeRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The unqualified resource name. + string node_id = 2; + + // Required. The node. + Node node = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for [DeleteNode][google.cloud.tpu.v2alpha1.Tpu.DeleteNode]. +message DeleteNodeRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } + ]; +} + +// Request for [StopNode][google.cloud.tpu.v2alpha1.Tpu.StopNode]. +message StopNodeRequest { + // The resource name. + string name = 1; +} + +// Request for [StartNode][google.cloud.tpu.v2alpha1.Tpu.StartNode]. +message StartNodeRequest { + // The resource name. + string name = 1; +} + +// Request for [UpdateNode][google.cloud.tpu.v2alpha1.Tpu.UpdateNode]. +message UpdateNodeRequest { + // Required. Mask of fields from [Node][Tpu.Node] to update. + // Supported fields: None. + google.protobuf.FieldMask update_mask = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The node. Only fields specified in update_mask are updated. + Node node = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The per-product per-project service identity for Cloud TPU service. +message ServiceIdentity { + // The email address of the service identity. + string email = 1; +} + +// Request for +// [GenerateServiceIdentity][google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity]. +message GenerateServiceIdentityRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; +} + +// Response for +// [GenerateServiceIdentity][google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity]. +message GenerateServiceIdentityResponse { + // ServiceIdentity that was created or retrieved. + ServiceIdentity identity = 1; +} + +// A accelerator type that a Node can be configured with. +message AcceleratorType { + option (google.api.resource) = { + type: "tpu.googleapis.com/AcceleratorType" + pattern: "projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}" + }; + + // The resource name. + string name = 1; + + // the accelerator type. + string type = 2; +} + +// Request for +// [GetAcceleratorType][google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType]. +message GetAcceleratorTypeRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/AcceleratorType" + } + ]; +} + +// Request for +// [ListAcceleratorTypes][google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes]. +message ListAcceleratorTypesRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/AcceleratorType" + } + ]; + + // The maximum number of items to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; + + // List filter. + string filter = 5; + + // Sort results. + string order_by = 6; +} + +// Response for +// [ListAcceleratorTypes][google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes]. +message ListAcceleratorTypesResponse { + // The listed nodes. + repeated AcceleratorType accelerator_types = 1; + + // The next page token or empty if none. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Note: the following OperationMetadata message was added manually. +// This is caused by a conflict with some other message and will +// be resolved separately. Please make sure to add this message back +// if it's removed during public proto regeneration. + +// Metadata describing an [Operation][google.longrunning.Operation] +message OperationMetadata { + // The time the operation was created. + google.protobuf.Timestamp create_time = 1; + + // The time the operation finished running. + google.protobuf.Timestamp end_time = 2; + + // Target of the operation - for example + // projects/project-1/connectivityTests/test-1 + string target = 3; + + // Name of the verb executed by the operation. + string verb = 4; + + // Human-readable status of the operation, if any. + string status_detail = 5; + + // Specifies if cancellation was requested for the operation. + bool cancel_requested = 6; + + // API version. + string api_version = 7; +} + +// A runtime version that a Node can be configured with. +message RuntimeVersion { + option (google.api.resource) = { + type: "tpu.googleapis.com/RuntimeVersion" + pattern: "projects/{project}/locations/{location}/runtimeVersions/{runtime_version}" + }; + + // The resource name. + string name = 1; + + // The runtime version. + string version = 2; +} + +// Request for +// [GetRuntimeVersion][google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion]. +message GetRuntimeVersionRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/RuntimeVersion" + } + ]; +} + +// Request for +// [ListRuntimeVersions][google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions]. +message ListRuntimeVersionsRequest { + // Required. The parent resource name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "tpu.googleapis.com/RuntimeVersion" + } + ]; + + // The maximum number of items to return. + int32 page_size = 2; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 3; + + // List filter. + string filter = 5; + + // Sort results. + string order_by = 6; +} + +// Response for +// [ListRuntimeVersions][google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions]. +message ListRuntimeVersionsResponse { + // The listed nodes. + repeated RuntimeVersion runtime_versions = 1; + + // The next page token or empty if none. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// A Symptom instance. +message Symptom { + // SymptomType represents the different types of Symptoms that a TPU can be + // at. + enum SymptomType { + // Unspecified symptom. + SYMPTOM_TYPE_UNSPECIFIED = 0; + + // TPU VM memory is low. + LOW_MEMORY = 1; + + // TPU runtime is out of memory. + OUT_OF_MEMORY = 2; + + // TPU runtime execution has timed out. + EXECUTE_TIMED_OUT = 3; + + // TPU runtime fails to construct a mesh that recognizes each TPU device's + // neighbors. + MESH_BUILD_FAIL = 4; + + // TPU HBM is out of memory. + HBM_OUT_OF_MEMORY = 5; + + // Abusive behaviors have been identified on the current project. + PROJECT_ABUSE = 6; + } + + // Timestamp when the Symptom is created. + google.protobuf.Timestamp create_time = 1; + + // Type of the Symptom. + SymptomType symptom_type = 2; + + // Detailed information of the current Symptom. + string details = 3; + + // A string used to uniquely distinguish a worker within a TPU node. + string worker_id = 4; +} + +// Request for +// [GetGuestAttributes][google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes]. +message GetGuestAttributesRequest { + // Required. The resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } + ]; + + // The guest attributes path to be queried. + string query_path = 2; + + // The 0-based worker ID. If it is empty, all workers' GuestAttributes will be + // returned. + repeated string worker_ids = 3; +} + +// Response for +// [GetGuestAttributes][google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes]. +message GetGuestAttributesResponse { + // The guest attributes for the TPU workers. + repeated GuestAttributes guest_attributes = 1; +} + +// A set of Shielded Instance options. +message ShieldedInstanceConfig { + // Defines whether the instance has Secure Boot enabled. + bool enable_secure_boot = 1; +} \ No newline at end of file diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json new file mode 100644 index 00000000000..251f9461801 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json @@ -0,0 +1,595 @@ +{ + "clientLibrary": { + "name": "nodejs-tpu", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.tpu.v2alpha1", + "version": "v2alpha1" + } + ] + }, + "snippets": [ + { + "regionTag": "tpu_v2alpha1_generated_Tpu_ListNodes_async", + "title": "Tpu listNodes Sample", + "origin": "API_DEFINITION", + "description": " Lists nodes.", + "canonical": true, + "file": "tpu.list_nodes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListNodes", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListNodes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.ListNodesResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "ListNodes", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListNodes", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_GetNode_async", + "title": "Tpu getNode Sample", + "origin": "API_DEFINITION", + "description": " Gets the details of a node.", + "canonical": true, + "file": "tpu.get_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.Node", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "GetNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_CreateNode_async", + "title": "Tpu createNode Sample", + "origin": "API_DEFINITION", + "description": " Creates a node.", + "canonical": true, + "file": "tpu.create_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.CreateNode", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "node_id", + "type": "TYPE_STRING" + }, + { + "name": "node", + "type": ".google.cloud.tpu.v2alpha1.Node" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "CreateNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.CreateNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_DeleteNode_async", + "title": "Tpu deleteNode Sample", + "origin": "API_DEFINITION", + "description": " Deletes a node.", + "canonical": true, + "file": "tpu.delete_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.DeleteNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "DeleteNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.DeleteNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_StopNode_async", + "title": "Tpu stopNode Sample", + "origin": "API_DEFINITION", + "description": " Stops a node. This operation is only available with single TPU nodes.", + "canonical": true, + "file": "tpu.stop_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StopNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.StopNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "StopNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.StopNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_StartNode_async", + "title": "Tpu startNode Sample", + "origin": "API_DEFINITION", + "description": " Starts a node.", + "canonical": true, + "file": "tpu.start_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StartNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.StartNode", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "StartNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.StartNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_UpdateNode_async", + "title": "Tpu updateNode Sample", + "origin": "API_DEFINITION", + "description": " Updates the configurations of a node.", + "canonical": true, + "file": "tpu.update_node.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.UpdateNode", + "async": true, + "parameters": [ + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "node", + "type": ".google.cloud.tpu.v2alpha1.Node" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "UpdateNode", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.UpdateNode", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async", + "title": "Tpu generateServiceIdentity Sample", + "origin": "API_DEFINITION", + "description": " Generates the Cloud TPU service identity for the project.", + "canonical": true, + "file": "tpu.generate_service_identity.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GenerateServiceIdentity", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "GenerateServiceIdentity", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async", + "title": "Tpu listAcceleratorTypes Sample", + "origin": "API_DEFINITION", + "description": " Lists accelerator types supported by this API.", + "canonical": true, + "file": "tpu.list_accelerator_types.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListAcceleratorTypes", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.ListAcceleratorTypesResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "ListAcceleratorTypes", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async", + "title": "Tpu getAcceleratorType Sample", + "origin": "API_DEFINITION", + "description": " Gets AcceleratorType.", + "canonical": true, + "file": "tpu.get_accelerator_type.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAcceleratorType", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.AcceleratorType", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "GetAcceleratorType", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async", + "title": "Tpu listRuntimeVersions Sample", + "origin": "API_DEFINITION", + "description": " Lists runtime versions supported by this API.", + "canonical": true, + "file": "tpu.list_runtime_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRuntimeVersions", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.ListRuntimeVersionsResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "ListRuntimeVersions", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async", + "title": "Tpu getRuntimeVersion Sample", + "origin": "API_DEFINITION", + "description": " Gets a runtime version.", + "canonical": true, + "file": "tpu.get_runtime_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRuntimeVersion", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.RuntimeVersion", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "GetRuntimeVersion", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + }, + { + "regionTag": "tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async", + "title": "Tpu getGuestAttributes Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the guest attributes for the node.", + "canonical": true, + "file": "tpu.get_guest_attributes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetGuestAttributes", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "query_path", + "type": "TYPE_STRING" + }, + { + "name": "worker_ids", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.cloud.tpu.v2alpha1.GetGuestAttributesResponse", + "client": { + "shortName": "TpuClient", + "fullName": "google.cloud.tpu.v2alpha1.TpuClient" + }, + "method": { + "shortName": "GetGuestAttributes", + "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes", + "service": { + "shortName": "Tpu", + "fullName": "google.cloud.tpu.v2alpha1.Tpu" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js new file mode 100644 index 00000000000..e99cae62be7 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, node) { + // [START tpu_v2alpha1_generated_Tpu_CreateNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The unqualified resource name. + */ + // const nodeId = 'abc123' + /** + * Required. The node. + */ + // const node = {} + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callCreateNode() { + // Construct request + const request = { + parent, + node, + }; + + // Run request + const [operation] = await tpuClient.createNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateNode(); + // [END tpu_v2alpha1_generated_Tpu_CreateNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js new file mode 100644 index 00000000000..c61789134fb --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v2alpha1_generated_Tpu_DeleteNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callDeleteNode() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await tpuClient.deleteNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteNode(); + // [END tpu_v2alpha1_generated_Tpu_DeleteNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js new file mode 100644 index 00000000000..6120c836015 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGenerateServiceIdentity() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await tpuClient.generateServiceIdentity(request); + console.log(response); + } + + callGenerateServiceIdentity(); + // [END tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js new file mode 100644 index 00000000000..c09ba898d76 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetAcceleratorType() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getAcceleratorType(request); + console.log(response); + } + + callGetAcceleratorType(); + // [END tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js new file mode 100644 index 00000000000..e6b83bcafac --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + /** + * The guest attributes path to be queried. + */ + // const queryPath = 'abc123' + /** + * The 0-based worker ID. If it is empty, all workers' GuestAttributes will be + * returned. + */ + // const workerIds = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetGuestAttributes() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getGuestAttributes(request); + console.log(response); + } + + callGetGuestAttributes(); + // [END tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js new file mode 100644 index 00000000000..ad9a1a2c833 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v2alpha1_generated_Tpu_GetNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetNode() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getNode(request); + console.log(response); + } + + callGetNode(); + // [END tpu_v2alpha1_generated_Tpu_GetNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js new file mode 100644 index 00000000000..8b9a3ee8556 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callGetRuntimeVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await tpuClient.getRuntimeVersion(request); + console.log(response); + } + + callGetRuntimeVersion(); + // [END tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js new file mode 100644 index 00000000000..bbaeacf2d0d --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * List filter. + */ + // const filter = 'abc123' + /** + * Sort results. + */ + // const orderBy = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callListAcceleratorTypes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await tpuClient.listAcceleratorTypesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListAcceleratorTypes(); + // [END tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js new file mode 100644 index 00000000000..4a43bdcc192 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v2alpha1_generated_Tpu_ListNodes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callListNodes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await tpuClient.listNodesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListNodes(); + // [END tpu_v2alpha1_generated_Tpu_ListNodes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js new file mode 100644 index 00000000000..ba51c03858c --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. + */ + // const parent = 'abc123' + /** + * The maximum number of items to return. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * List filter. + */ + // const filter = 'abc123' + /** + * Sort results. + */ + // const orderBy = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callListRuntimeVersions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await tpuClient.listRuntimeVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRuntimeVersions(); + // [END tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js new file mode 100644 index 00000000000..047f5124c7b --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START tpu_v2alpha1_generated_Tpu_StartNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callStartNode() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await tpuClient.startNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStartNode(); + // [END tpu_v2alpha1_generated_Tpu_StartNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js new file mode 100644 index 00000000000..21ceb97b54b --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START tpu_v2alpha1_generated_Tpu_StopNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The resource name. + */ + // const name = 'abc123' + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callStopNode() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await tpuClient.stopNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callStopNode(); + // [END tpu_v2alpha1_generated_Tpu_StopNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js new file mode 100644 index 00000000000..80769d98505 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(updateMask, node) { + // [START tpu_v2alpha1_generated_Tpu_UpdateNode_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Mask of fields from Node Tpu.Node to update. + * Supported fields: None. + */ + // const updateMask = {} + /** + * Required. The node. Only fields specified in update_mask are updated. + */ + // const node = {} + + // Imports the Tpu library + const {TpuClient} = require('@google-cloud/tpu').v2alpha1; + + // Instantiates a client + const tpuClient = new TpuClient(); + + async function callUpdateNode() { + // Construct request + const request = { + updateMask, + node, + }; + + // Run request + const [operation] = await tpuClient.updateNode(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateNode(); + // [END tpu_v2alpha1_generated_Tpu_UpdateNode_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts new file mode 100644 index 00000000000..e00ff687292 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v2alpha1 from './v2alpha1'; +const TpuClient = v2alpha1.TpuClient; +type TpuClient = v2alpha1.TpuClient; +export {v2alpha1, TpuClient}; +export default {v2alpha1, TpuClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json new file mode 100644 index 00000000000..d4f743c1646 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json @@ -0,0 +1,165 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.tpu.v2alpha1", + "libraryPackage": "@google-cloud/tpu", + "services": { + "Tpu": { + "clients": { + "grpc": { + "libraryClient": "TpuClient", + "rpcs": { + "GetNode": { + "methods": [ + "getNode" + ] + }, + "GenerateServiceIdentity": { + "methods": [ + "generateServiceIdentity" + ] + }, + "GetAcceleratorType": { + "methods": [ + "getAcceleratorType" + ] + }, + "GetRuntimeVersion": { + "methods": [ + "getRuntimeVersion" + ] + }, + "GetGuestAttributes": { + "methods": [ + "getGuestAttributes" + ] + }, + "CreateNode": { + "methods": [ + "createNode" + ] + }, + "DeleteNode": { + "methods": [ + "deleteNode" + ] + }, + "StopNode": { + "methods": [ + "stopNode" + ] + }, + "StartNode": { + "methods": [ + "startNode" + ] + }, + "UpdateNode": { + "methods": [ + "updateNode" + ] + }, + "ListNodes": { + "methods": [ + "listNodes", + "listNodesStream", + "listNodesAsync" + ] + }, + "ListAcceleratorTypes": { + "methods": [ + "listAcceleratorTypes", + "listAcceleratorTypesStream", + "listAcceleratorTypesAsync" + ] + }, + "ListRuntimeVersions": { + "methods": [ + "listRuntimeVersions", + "listRuntimeVersionsStream", + "listRuntimeVersionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TpuClient", + "rpcs": { + "GetNode": { + "methods": [ + "getNode" + ] + }, + "GenerateServiceIdentity": { + "methods": [ + "generateServiceIdentity" + ] + }, + "GetAcceleratorType": { + "methods": [ + "getAcceleratorType" + ] + }, + "GetRuntimeVersion": { + "methods": [ + "getRuntimeVersion" + ] + }, + "GetGuestAttributes": { + "methods": [ + "getGuestAttributes" + ] + }, + "CreateNode": { + "methods": [ + "createNode" + ] + }, + "DeleteNode": { + "methods": [ + "deleteNode" + ] + }, + "StopNode": { + "methods": [ + "stopNode" + ] + }, + "StartNode": { + "methods": [ + "startNode" + ] + }, + "UpdateNode": { + "methods": [ + "updateNode" + ] + }, + "ListNodes": { + "methods": [ + "listNodes", + "listNodesStream", + "listNodesAsync" + ] + }, + "ListAcceleratorTypes": { + "methods": [ + "listAcceleratorTypes", + "listAcceleratorTypesStream", + "listAcceleratorTypesAsync" + ] + }, + "ListRuntimeVersions": { + "methods": [ + "listRuntimeVersions", + "listRuntimeVersionsStream", + "listRuntimeVersionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts new file mode 100644 index 00000000000..27c81814923 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {TpuClient} from './tpu_client'; diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts new file mode 100644 index 00000000000..2a1a8bfbe34 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts @@ -0,0 +1,1955 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha1/tpu_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tpu_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Manages TPU nodes and other resources + * + * TPU API v2alpha1 + * @class + * @memberof v2alpha1 + */ +export class TpuClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tpuStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TpuClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new TpuClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof TpuClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + 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. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + acceleratorTypePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + nodePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/nodes/{node}' + ), + runtimeVersionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/runtimeVersions/{runtime_version}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listNodes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'nodes'), + listAcceleratorTypes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'acceleratorTypes'), + listRuntimeVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'runtimeVersions') + }; + + 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 lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*}',},{get: '/v2alpha1/{name=projects/*/locations/*}',}], + },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha1/{name=projects/*}/locations',additional_bindings: [{get: '/v1/{name=projects/*}/locations',},{get: '/v2alpha1/{name=projects/*}/locations',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha1/{name=projects/*/locations/*/operations/*}:cancel',additional_bindings: [{post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{post: '/v2alpha1/{name=projects/*/locations/*/operations/*}:cancel',}], + },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha1/{name=projects/*/locations/*/operations/*}',additional_bindings: [{delete: '/v1/{name=projects/*/locations/*/operations/*}',},{delete: '/v2alpha1/{name=projects/*/locations/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha1/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha1/{name=projects/*/locations/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha1/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v2alpha1/{name=projects/*/locations/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; + const createNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; + const deleteNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; + const deleteNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; + const stopNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; + const stopNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; + const startNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; + const startNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; + const updateNodeResponse = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; + const updateNodeMetadata = protoFilesRoot.lookup( + '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createNodeResponse.decode.bind(createNodeResponse), + createNodeMetadata.decode.bind(createNodeMetadata)), + deleteNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteNodeResponse.decode.bind(deleteNodeResponse), + deleteNodeMetadata.decode.bind(deleteNodeMetadata)), + stopNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + stopNodeResponse.decode.bind(stopNodeResponse), + stopNodeMetadata.decode.bind(stopNodeMetadata)), + startNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + startNodeResponse.decode.bind(startNodeResponse), + startNodeMetadata.decode.bind(startNodeMetadata)), + updateNode: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateNodeResponse.decode.bind(updateNodeResponse), + updateNodeMetadata.decode.bind(updateNodeMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.tpu.v2alpha1.Tpu', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.tpuStub) { + return this.tpuStub; + } + + // Put together the "service stub" for + // google.cloud.tpu.v2alpha1.Tpu. + this.tpuStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.tpu.v2alpha1.Tpu') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.tpu.v2alpha1.Tpu, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const tpuStubMethods = + ['listNodes', 'getNode', 'createNode', 'deleteNode', 'stopNode', 'startNode', 'updateNode', 'generateServiceIdentity', 'listAcceleratorTypes', 'getAcceleratorType', 'listRuntimeVersions', 'getRuntimeVersion', 'getGuestAttributes']; + for (const methodName of tpuStubMethods) { + const callPromise = this.tpuStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.tpuStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'tpu.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'tpu.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets the details of a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Node]{@link google.cloud.tpu.v2alpha1.Node}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.get_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_GetNode_async + */ + getNode( + request?: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.INode, + protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|undefined, {}|undefined + ]>; + getNode( + request: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.INode, + protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, + {}|null|undefined>): void; + getNode( + request: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.INode, + protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, + {}|null|undefined>): void; + getNode( + request?: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v2alpha1.INode, + protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v2alpha1.INode, + protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.INode, + protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getNode(request, options, callback); + } +/** + * Generates the Cloud TPU service identity for the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GenerateServiceIdentityResponse]{@link google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.generate_service_identity.js + * region_tag:tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async + */ + generateServiceIdentity( + request?: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|undefined, {}|undefined + ]>; + generateServiceIdentity( + request: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, + {}|null|undefined>): void; + generateServiceIdentity( + request: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, + {}|null|undefined>): void; + generateServiceIdentity( + request?: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, + protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.generateServiceIdentity(request, options, callback); + } +/** + * Gets AcceleratorType. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.get_accelerator_type.js + * region_tag:tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async + */ + getAcceleratorType( + request?: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IAcceleratorType, + protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|undefined, {}|undefined + ]>; + getAcceleratorType( + request: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IAcceleratorType, + protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): void; + getAcceleratorType( + request: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IAcceleratorType, + protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): void; + getAcceleratorType( + request?: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v2alpha1.IAcceleratorType, + protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v2alpha1.IAcceleratorType, + protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IAcceleratorType, + protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAcceleratorType(request, options, callback); + } +/** + * Gets a runtime version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.get_runtime_version.js + * region_tag:tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async + */ + getRuntimeVersion( + request?: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, + protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|undefined, {}|undefined + ]>; + getRuntimeVersion( + request: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, + protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, + {}|null|undefined>): void; + getRuntimeVersion( + request: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, + protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, + {}|null|undefined>): void; + getRuntimeVersion( + request?: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, + protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, + protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, + protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getRuntimeVersion(request, options, callback); + } +/** + * Retrieves the guest attributes for the node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {string} request.queryPath + * The guest attributes path to be queried. + * @param {string[]} request.workerIds + * The 0-based worker ID. If it is empty, all workers' GuestAttributes will be + * returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GetGuestAttributesResponse]{@link google.cloud.tpu.v2alpha1.GetGuestAttributesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.get_guest_attributes.js + * region_tag:tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async + */ + getGuestAttributes( + request?: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|undefined, {}|undefined + ]>; + getGuestAttributes( + request: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, + {}|null|undefined>): void; + getGuestAttributes( + request: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, + callback: Callback< + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, + {}|null|undefined>): void; + getGuestAttributes( + request?: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, + protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getGuestAttributes(request, options, callback); + } + +/** + * Creates a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {string} request.nodeId + * The unqualified resource name. + * @param {google.cloud.tpu.v2alpha1.Node} request.node + * Required. The node. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.create_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_CreateNode_async + */ + createNode( + request?: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createNode( + request: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createNode( + request: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createNode( + request?: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.create_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_CreateNode_async + */ + async checkCreateNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.delete_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_DeleteNode_async + */ + deleteNode( + request?: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteNode( + request: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteNode( + request: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteNode( + request?: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.delete_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_DeleteNode_async + */ + async checkDeleteNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Stops a node. This operation is only available with single TPU nodes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.stop_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_StopNode_async + */ + stopNode( + request?: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + stopNode( + request: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopNode( + request: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + stopNode( + request?: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.stopNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `stopNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.stop_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_StopNode_async + */ + async checkStopNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.stopNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.start_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_StartNode_async + */ + startNode( + request?: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + startNode( + request: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startNode( + request: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + startNode( + request?: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.startNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `startNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.start_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_StartNode_async + */ + async checkStartNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.startNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the configurations of a node. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields from {@link Tpu.Node|Node} to update. + * Supported fields: None. + * @param {google.cloud.tpu.v2alpha1.Node} request.node + * Required. The node. Only fields specified in update_mask are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.update_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_UpdateNode_async + */ + updateNode( + request?: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateNode( + request: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateNode( + request: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateNode( + request?: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'node.name': request.node!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateNode(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateNode()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.update_node.js + * region_tag:tpu_v2alpha1_generated_Tpu_UpdateNode_async + */ + async checkUpdateNodeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateNode, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists nodes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Node]{@link google.cloud.tpu.v2alpha1.Node}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNodes( + request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.INode[], + protos.google.cloud.tpu.v2alpha1.IListNodesRequest|null, + protos.google.cloud.tpu.v2alpha1.IListNodesResponse + ]>; + listNodes( + request: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.INode>): void; + listNodes( + request: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + callback: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.INode>): void; + listNodes( + request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.INode>, + callback?: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.INode>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.INode[], + protos.google.cloud.tpu.v2alpha1.IListNodesRequest|null, + protos.google.cloud.tpu.v2alpha1.IListNodesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listNodes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Node]{@link google.cloud.tpu.v2alpha1.Node} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listNodesStream( + request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listNodes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNodes.createStream( + this.innerApiCalls.listNodes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listNodes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Node]{@link google.cloud.tpu.v2alpha1.Node}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.list_nodes.js + * region_tag:tpu_v2alpha1_generated_Tpu_ListNodes_async + */ + listNodesAsync( + request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listNodes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listNodes.asyncIterate( + this.innerApiCalls['listNodes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists accelerator types supported by this API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAcceleratorTypesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listAcceleratorTypes( + request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IAcceleratorType[], + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest|null, + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse + ]>; + listAcceleratorTypes( + request: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IAcceleratorType>): void; + listAcceleratorTypes( + request: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + callback: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IAcceleratorType>): void; + listAcceleratorTypes( + request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IAcceleratorType>, + callback?: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IAcceleratorType>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IAcceleratorType[], + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest|null, + protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listAcceleratorTypes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAcceleratorTypesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listAcceleratorTypesStream( + request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listAcceleratorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAcceleratorTypes.createStream( + this.innerApiCalls.listAcceleratorTypes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listAcceleratorTypes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.list_accelerator_types.js + * region_tag:tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async + */ + listAcceleratorTypesAsync( + request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listAcceleratorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listAcceleratorTypes.asyncIterate( + this.innerApiCalls['listAcceleratorTypes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists runtime versions supported by this API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRuntimeVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listRuntimeVersions( + request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[], + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest|null, + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse + ]>; + listRuntimeVersions( + request: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>): void; + listRuntimeVersions( + request: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>): void; + listRuntimeVersions( + request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>, + callback?: PaginationCallback< + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>): + Promise<[ + protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[], + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest|null, + protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listRuntimeVersions(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRuntimeVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listRuntimeVersionsStream( + request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listRuntimeVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRuntimeVersions.createStream( + this.innerApiCalls.listRuntimeVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRuntimeVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. + * @param {number} request.pageSize + * The maximum number of items to return. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {string} request.filter + * List filter. + * @param {string} request.orderBy + * Sort results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha1/tpu.list_runtime_versions.js + * region_tag:tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async + */ + listRuntimeVersionsAsync( + request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listRuntimeVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRuntimeVersions.asyncIterate( + this.innerApiCalls['listRuntimeVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified acceleratorType resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} accelerator_type + * @returns {string} Resource name string. + */ + acceleratorTypePath(project:string,location:string,acceleratorType:string) { + return this.pathTemplates.acceleratorTypePathTemplate.render({ + project: project, + location: location, + accelerator_type: acceleratorType, + }); + } + + /** + * Parse the project from AcceleratorType resource. + * + * @param {string} acceleratorTypeName + * A fully-qualified path representing AcceleratorType resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAcceleratorTypeName(acceleratorTypeName: string) { + return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).project; + } + + /** + * Parse the location from AcceleratorType resource. + * + * @param {string} acceleratorTypeName + * A fully-qualified path representing AcceleratorType resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAcceleratorTypeName(acceleratorTypeName: string) { + return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).location; + } + + /** + * Parse the accelerator_type from AcceleratorType resource. + * + * @param {string} acceleratorTypeName + * A fully-qualified path representing AcceleratorType resource. + * @returns {string} A string representing the accelerator_type. + */ + matchAcceleratorTypeFromAcceleratorTypeName(acceleratorTypeName: string) { + return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).accelerator_type; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified node resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} node + * @returns {string} Resource name string. + */ + nodePath(project:string,location:string,node:string) { + return this.pathTemplates.nodePathTemplate.render({ + project: project, + location: location, + node: node, + }); + } + + /** + * Parse the project from Node resource. + * + * @param {string} nodeName + * A fully-qualified path representing Node resource. + * @returns {string} A string representing the project. + */ + matchProjectFromNodeName(nodeName: string) { + return this.pathTemplates.nodePathTemplate.match(nodeName).project; + } + + /** + * Parse the location from Node resource. + * + * @param {string} nodeName + * A fully-qualified path representing Node resource. + * @returns {string} A string representing the location. + */ + matchLocationFromNodeName(nodeName: string) { + return this.pathTemplates.nodePathTemplate.match(nodeName).location; + } + + /** + * Parse the node from Node resource. + * + * @param {string} nodeName + * A fully-qualified path representing Node resource. + * @returns {string} A string representing the node. + */ + matchNodeFromNodeName(nodeName: string) { + return this.pathTemplates.nodePathTemplate.match(nodeName).node; + } + + /** + * Return a fully-qualified runtimeVersion resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} runtime_version + * @returns {string} Resource name string. + */ + runtimeVersionPath(project:string,location:string,runtimeVersion:string) { + return this.pathTemplates.runtimeVersionPathTemplate.render({ + project: project, + location: location, + runtime_version: runtimeVersion, + }); + } + + /** + * Parse the project from RuntimeVersion resource. + * + * @param {string} runtimeVersionName + * A fully-qualified path representing RuntimeVersion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuntimeVersionName(runtimeVersionName: string) { + return this.pathTemplates.runtimeVersionPathTemplate.match(runtimeVersionName).project; + } + + /** + * Parse the location from RuntimeVersion resource. + * + * @param {string} runtimeVersionName + * A fully-qualified path representing RuntimeVersion resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuntimeVersionName(runtimeVersionName: string) { + return this.pathTemplates.runtimeVersionPathTemplate.match(runtimeVersionName).location; + } + + /** + * Parse the runtime_version from RuntimeVersion resource. + * + * @param {string} runtimeVersionName + * A fully-qualified path representing RuntimeVersion resource. + * @returns {string} A string representing the runtime_version. + */ + matchRuntimeVersionFromRuntimeVersionName(runtimeVersionName: string) { + return this.pathTemplates.runtimeVersionPathTemplate.match(runtimeVersionName).runtime_version; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.tpuStub && !this._terminated) { + return this.tpuStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json new file mode 100644 index 00000000000..d268f63d19d --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json @@ -0,0 +1,91 @@ +{ + "interfaces": { + "google.cloud.tpu.v2alpha1.Tpu": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListNodes": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StopNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StartNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateNode": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GenerateServiceIdentity": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListAcceleratorTypes": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetAcceleratorType": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRuntimeVersions": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRuntimeVersion": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetGuestAttributes": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json new file mode 100644 index 00000000000..17217f28408 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto" +] diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..9cb87c17e68 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const tpu = require('@google-cloud/tpu'); + +function main() { + const tpuClient = new tpu.TpuClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..50ac473b84f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {TpuClient} from '@google-cloud/tpu'; + +// check that the client class type name can be used +function doStuffWithTpuClient(client: TpuClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const tpuClient = new TpuClient(); + doStuffWithTpuClient(tpuClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts new file mode 100644 index 00000000000..66fde4f2869 --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts @@ -0,0 +1,2441 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as tpuModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha1.TpuClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = tpuModule.v2alpha1.TpuClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tpuModule.v2alpha1.TpuClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tpuModule.v2alpha1.TpuClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tpuModule.v2alpha1.TpuClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tpuModule.v2alpha1.TpuClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tpuStub, undefined); + await client.initialize(); + assert(client.tpuStub); + }); + + it('has close method for the initialized client', done => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tpuStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tpuStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getNode', () => { + it('invokes getNode without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.Node() + ); + client.innerApiCalls.getNode = stubSimpleCall(expectedResponse); + const [response] = await client.getNode(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNode without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.Node() + ); + client.innerApiCalls.getNode = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNode( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.INode|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNode with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getNode = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNode(request), expectedError); + const actualRequest = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNode with closed client', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getNode(request), expectedError); + }); + }); + + describe('generateServiceIdentity', () => { + it('invokes generateServiceIdentity without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse() + ); + client.innerApiCalls.generateServiceIdentity = stubSimpleCall(expectedResponse); + const [response] = await client.generateServiceIdentity(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.generateServiceIdentity as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.generateServiceIdentity as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateServiceIdentity without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse() + ); + client.innerApiCalls.generateServiceIdentity = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateServiceIdentity( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.generateServiceIdentity as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.generateServiceIdentity as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateServiceIdentity with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateServiceIdentity = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.generateServiceIdentity(request), expectedError); + const actualRequest = (client.innerApiCalls.generateServiceIdentity as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.generateServiceIdentity as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes generateServiceIdentity with closed client', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.generateServiceIdentity(request), expectedError); + }); + }); + + describe('getAcceleratorType', () => { + it('invokes getAcceleratorType without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.AcceleratorType() + ); + client.innerApiCalls.getAcceleratorType = stubSimpleCall(expectedResponse); + const [response] = await client.getAcceleratorType(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAcceleratorType without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.AcceleratorType() + ); + client.innerApiCalls.getAcceleratorType = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAcceleratorType( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IAcceleratorType|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAcceleratorType with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAcceleratorType = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAcceleratorType(request), expectedError); + const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAcceleratorType with closed client', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAcceleratorType(request), expectedError); + }); + }); + + describe('getRuntimeVersion', () => { + it('invokes getRuntimeVersion without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.RuntimeVersion() + ); + client.innerApiCalls.getRuntimeVersion = stubSimpleCall(expectedResponse); + const [response] = await client.getRuntimeVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRuntimeVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuntimeVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuntimeVersion without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.RuntimeVersion() + ); + client.innerApiCalls.getRuntimeVersion = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRuntimeVersion( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRuntimeVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuntimeVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuntimeVersion with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRuntimeVersion = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRuntimeVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.getRuntimeVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuntimeVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuntimeVersion with closed client', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRuntimeVersion(request), expectedError); + }); + }); + + describe('getGuestAttributes', () => { + it('invokes getGuestAttributes without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesResponse() + ); + client.innerApiCalls.getGuestAttributes = stubSimpleCall(expectedResponse); + const [response] = await client.getGuestAttributes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestAttributes without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesResponse() + ); + client.innerApiCalls.getGuestAttributes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getGuestAttributes( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestAttributes with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getGuestAttributes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getGuestAttributes(request), expectedError); + const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getGuestAttributes with closed client', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getGuestAttributes(request), expectedError); + }); + }); + + describe('createNode', () => { + it('invokes createNode without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.createNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNode without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNode with call error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createNode(request), expectedError); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNode with LRO error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateNodeProgress without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateNodeProgress with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteNode', () => { + it('invokes deleteNode without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNode without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNode with call error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteNode(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNode with LRO error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteNodeProgress without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteNodeProgress with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('stopNode', () => { + it('invokes stopNode without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.stopNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopNode without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.stopNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopNode with call error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.stopNode(request), expectedError); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopNode with LRO error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.stopNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStopNodeProgress without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStopNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStopNodeProgress with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStopNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('startNode', () => { + it('invokes startNode without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.startNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startNode without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.startNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startNode with call error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.startNode(request), expectedError); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startNode with LRO error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.startNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkStartNodeProgress without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkStartNodeProgress with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkStartNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateNode', () => { + it('invokes updateNode without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() + ); + request.node ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); + request.node.name = defaultValue1; + const expectedHeaderRequestParams = `node.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateNode = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateNode(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNode without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() + ); + request.node ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); + request.node.name = defaultValue1; + const expectedHeaderRequestParams = `node.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateNode = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateNode( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNode with call error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() + ); + request.node ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); + request.node.name = defaultValue1; + const expectedHeaderRequestParams = `node.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNode = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateNode(request), expectedError); + const actualRequest = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNode with LRO error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() + ); + request.node ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); + request.node.name = defaultValue1; + const expectedHeaderRequestParams = `node.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNode = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateNode(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateNodeProgress without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateNodeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateNodeProgress with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateNodeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listNodes', () => { + it('invokes listNodes without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + ]; + client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); + const [response] = await client.listNodes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodes without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + ]; + client.innerApiCalls.listNodes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNodes( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.INode[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodes with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNodes(request), expectedError); + const actualRequest = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNodesStream without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + ]; + client.descriptors.page.listNodes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v2alpha1.Node[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.Node) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listNodesStream with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v2alpha1.Node[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.Node) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNodes without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), + ]; + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tpu.v2alpha1.INode[] = []; + const iterable = client.listNodesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listNodes with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNodesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tpu.v2alpha1.INode[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listAcceleratorTypes', () => { + it('invokes listAcceleratorTypes without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + ]; + client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(expectedResponse); + const [response] = await client.listAcceleratorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAcceleratorTypes without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + ]; + client.innerApiCalls.listAcceleratorTypes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAcceleratorTypes( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IAcceleratorType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAcceleratorTypes with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listAcceleratorTypes(request), expectedError); + const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listAcceleratorTypesStream without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + ]; + client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listAcceleratorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v2alpha1.AcceleratorType[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.AcceleratorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); + assert( + (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listAcceleratorTypesStream with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listAcceleratorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v2alpha1.AcceleratorType[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.AcceleratorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); + assert( + (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAcceleratorTypes without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), + ]; + client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tpu.v2alpha1.IAcceleratorType[] = []; + const iterable = client.listAcceleratorTypesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listAcceleratorTypes with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAcceleratorTypesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tpu.v2alpha1.IAcceleratorType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listRuntimeVersions', () => { + it('invokes listRuntimeVersions without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + ]; + client.innerApiCalls.listRuntimeVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listRuntimeVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRuntimeVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuntimeVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimeVersions without error using callback', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + ]; + client.innerApiCalls.listRuntimeVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRuntimeVersions( + request, + (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRuntimeVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuntimeVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimeVersions with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRuntimeVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRuntimeVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.listRuntimeVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuntimeVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuntimeVersionsStream without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + ]; + client.descriptors.page.listRuntimeVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRuntimeVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v2alpha1.RuntimeVersion[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.RuntimeVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listRuntimeVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRuntimeVersions, request)); + assert( + (client.descriptors.page.listRuntimeVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRuntimeVersionsStream with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuntimeVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRuntimeVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tpu.v2alpha1.RuntimeVersion[] = []; + stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.RuntimeVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRuntimeVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRuntimeVersions, request)); + assert( + (client.descriptors.page.listRuntimeVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRuntimeVersions without error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), + ]; + client.descriptors.page.listRuntimeVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[] = []; + const iterable = client.listRuntimeVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRuntimeVersions with error', async () => { + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuntimeVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRuntimeVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('acceleratorType', () => { + const fakePath = "/rendered/path/acceleratorType"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + accelerator_type: "acceleratorTypeValue", + }; + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.acceleratorTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.acceleratorTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('acceleratorTypePath', () => { + const result = client.acceleratorTypePath("projectValue", "locationValue", "acceleratorTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.acceleratorTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromAcceleratorTypeName', () => { + const result = client.matchProjectFromAcceleratorTypeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromAcceleratorTypeName', () => { + const result = client.matchLocationFromAcceleratorTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchAcceleratorTypeFromAcceleratorTypeName', () => { + const result = client.matchAcceleratorTypeFromAcceleratorTypeName(fakePath); + assert.strictEqual(result, "acceleratorTypeValue"); + assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('node', () => { + const fakePath = "/rendered/path/node"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + node: "nodeValue", + }; + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.nodePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.nodePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('nodePath', () => { + const result = client.nodePath("projectValue", "locationValue", "nodeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.nodePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromNodeName', () => { + const result = client.matchProjectFromNodeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromNodeName', () => { + const result = client.matchLocationFromNodeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchNodeFromNodeName', () => { + const result = client.matchNodeFromNodeName(fakePath); + assert.strictEqual(result, "nodeValue"); + assert((client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('runtimeVersion', () => { + const fakePath = "/rendered/path/runtimeVersion"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + runtime_version: "runtimeVersionValue", + }; + const client = new tpuModule.v2alpha1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.runtimeVersionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.runtimeVersionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('runtimeVersionPath', () => { + const result = client.runtimeVersionPath("projectValue", "locationValue", "runtimeVersionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.runtimeVersionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuntimeVersionName', () => { + const result = client.matchProjectFromRuntimeVersionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.runtimeVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuntimeVersionName', () => { + const result = client.matchLocationFromRuntimeVersionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.runtimeVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuntimeVersionFromRuntimeVersionName', () => { + const result = client.matchRuntimeVersionFromRuntimeVersionName(fakePath); + assert.strictEqual(result, "runtimeVersionValue"); + assert((client.pathTemplates.runtimeVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js new file mode 100644 index 00000000000..8ee514d072f --- /dev/null +++ b/owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Tpu', + filename: './tpu.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From 50bae03b83aaa9ebfc70c41e4ace5684ffcf0a8c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 30 Nov 2022 03:58:56 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google-cloud-tpu/v1/.eslintignore | 7 - .../google-cloud-tpu/v1/.eslintrc.json | 3 - .../google-cloud-tpu/v1/.gitignore | 14 - owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js | 55 - .../google-cloud-tpu/v1/.mocharc.js | 33 - .../google-cloud-tpu/v1/.prettierrc.js | 22 - owl-bot-staging/google-cloud-tpu/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../google-cloud-tpu/v1/package.json | 64 - .../google/cloud/tpu/v1/cloud_tpu.proto | 617 ---- .../snippet_metadata.google.cloud.tpu.v1.json | 507 ---- .../samples/generated/v1/tpu.create_node.js | 71 - .../samples/generated/v1/tpu.delete_node.js | 62 - .../generated/v1/tpu.get_accelerator_type.js | 61 - .../v1/samples/generated/v1/tpu.get_node.js | 61 - .../v1/tpu.get_tensor_flow_version.js | 61 - .../v1/tpu.list_accelerator_types.js | 79 - .../v1/samples/generated/v1/tpu.list_nodes.js | 71 - .../v1/tpu.list_tensor_flow_versions.js | 79 - .../samples/generated/v1/tpu.reimage_node.js | 65 - .../v1/samples/generated/v1/tpu.start_node.js | 61 - .../v1/samples/generated/v1/tpu.stop_node.js | 61 - .../google-cloud-tpu/v1/src/index.ts | 25 - .../v1/src/v1/gapic_metadata.json | 145 - .../google-cloud-tpu/v1/src/v1/index.ts | 19 - .../google-cloud-tpu/v1/src/v1/tpu_client.ts | 2091 ------------- .../v1/src/v1/tpu_client_config.json | 81 - .../v1/src/v1/tpu_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../google-cloud-tpu/v1/test/gapic_tpu_v1.ts | 2672 ----------------- .../google-cloud-tpu/v1/tsconfig.json | 19 - .../google-cloud-tpu/v1/webpack.config.js | 64 - .../google-cloud-tpu/v2alpha1/.eslintignore | 7 - .../google-cloud-tpu/v2alpha1/.eslintrc.json | 3 - .../google-cloud-tpu/v2alpha1/.gitignore | 14 - .../google-cloud-tpu/v2alpha1/.jsdoc.js | 55 - .../google-cloud-tpu/v2alpha1/.mocharc.js | 33 - .../google-cloud-tpu/v2alpha1/.prettierrc.js | 22 - .../google-cloud-tpu/v2alpha1/README.md | 1 - .../v2alpha1/linkinator.config.json | 16 - .../google-cloud-tpu/v2alpha1/package.json | 64 - .../google/cloud/tpu/v2alpha1/cloud_tpu.proto | 791 ----- ...et_metadata.google.cloud.tpu.v2alpha1.json | 595 ---- .../generated/v2alpha1/tpu.create_node.js | 71 - .../generated/v2alpha1/tpu.delete_node.js | 62 - .../v2alpha1/tpu.generate_service_identity.js | 61 - .../v2alpha1/tpu.get_accelerator_type.js | 61 - .../v2alpha1/tpu.get_guest_attributes.js | 70 - .../generated/v2alpha1/tpu.get_node.js | 61 - .../v2alpha1/tpu.get_runtime_version.js | 61 - .../v2alpha1/tpu.list_accelerator_types.js | 79 - .../generated/v2alpha1/tpu.list_nodes.js | 71 - .../v2alpha1/tpu.list_runtime_versions.js | 79 - .../generated/v2alpha1/tpu.start_node.js | 61 - .../generated/v2alpha1/tpu.stop_node.js | 61 - .../generated/v2alpha1/tpu.update_node.js | 68 - .../google-cloud-tpu/v2alpha1/src/index.ts | 25 - .../v2alpha1/src/v2alpha1/gapic_metadata.json | 165 - .../v2alpha1/src/v2alpha1/index.ts | 19 - .../v2alpha1/src/v2alpha1/tpu_client.ts | 1955 ------------ .../src/v2alpha1/tpu_client_config.json | 91 - .../v2alpha1/src/v2alpha1/tpu_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v2alpha1/system-test/install.ts | 49 - .../v2alpha1/test/gapic_tpu_v2alpha1.ts | 2441 --------------- .../google-cloud-tpu/v2alpha1/tsconfig.json | 19 - .../v2alpha1/webpack.config.js | 64 - .../google/cloud/tpu/v1/cloud_tpu.proto | 11 +- .../snippet_metadata.google.cloud.tpu.v1.json | 2 +- .../google-cloud-tpu/src/v1/tpu_client.ts | 267 +- .../google-cloud-tpu/test/gapic_tpu_v1.ts | 510 +++- 74 files changed, 779 insertions(+), 14666 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/README.md delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/package.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-tpu/v1/.eslintignore b/owl-bot-staging/google-cloud-tpu/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json b/owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/.gitignore b/owl-bot-staging/google-cloud-tpu/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js b/owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js deleted file mode 100644 index 5b3c57ae725..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/tpu', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-tpu/v1/.mocharc.js b/owl-bot-staging/google-cloud-tpu/v1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js b/owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/README.md b/owl-bot-staging/google-cloud-tpu/v1/README.md deleted file mode 100644 index b04db0dc280..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Tpu: Nodejs Client diff --git a/owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json b/owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/package.json b/owl-bot-staging/google-cloud-tpu/v1/package.json deleted file mode 100644 index 911441f5cee..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/tpu", - "version": "0.1.0", - "description": "Tpu client for Node.js", - "repository": "googleapis/nodejs-tpu", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google tpu", - "tpu", - "tpu" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto b/owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto deleted file mode 100644 index c2acf92f439..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/protos/google/cloud/tpu/v1/cloud_tpu.proto +++ /dev/null @@ -1,617 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.tpu.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/tpu/v1;tpu"; -option java_multiple_files = true; -option java_outer_classname = "CloudTpuProto"; -option java_package = "com.google.cloud.tpu.v1"; - -// Manages TPU nodes and other resources -// -// TPU API v1 -service Tpu { - option (google.api.default_host) = "tpu.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists nodes. - rpc ListNodes(ListNodesRequest) returns (ListNodesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/nodes" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the details of a node. - rpc GetNode(GetNodeRequest) returns (Node) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/nodes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a node. - rpc CreateNode(CreateNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/nodes" - body: "node" - }; - option (google.api.method_signature) = "parent,node,node_id"; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a node. - rpc DeleteNode(DeleteNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/nodes/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Reimages a node's OS. - rpc ReimageNode(ReimageNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/nodes/*}:reimage" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Stops a node, this operation is only available with single TPU nodes. - rpc StopNode(StopNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/nodes/*}:stop" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Starts a node. - rpc StartNode(StartNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/nodes/*}:start" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // List TensorFlow versions supported by this API. - rpc ListTensorFlowVersions(ListTensorFlowVersionsRequest) returns (ListTensorFlowVersionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/tensorflowVersions" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets TensorFlow Version. - rpc GetTensorFlowVersion(GetTensorFlowVersionRequest) returns (TensorFlowVersion) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/tensorflowVersions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists accelerator types supported by this API. - rpc ListAcceleratorTypes(ListAcceleratorTypesRequest) returns (ListAcceleratorTypesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/acceleratorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets AcceleratorType. - rpc GetAcceleratorType(GetAcceleratorTypeRequest) returns (AcceleratorType) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/acceleratorTypes/*}" - }; - option (google.api.method_signature) = "name"; - } -} - -// Sets the scheduling options for this node. -message SchedulingConfig { - // Defines whether the node is preemptible. - bool preemptible = 1; - - // Whether the node is created under a reservation. - bool reserved = 2; -} - -// A network endpoint over which a TPU worker can be reached. -message NetworkEndpoint { - // The IP address of this network endpoint. - string ip_address = 1; - - // The port of this network endpoint. - int32 port = 2; -} - -// A TPU instance. -message Node { - option (google.api.resource) = { - type: "tpu.googleapis.com/Node" - pattern: "projects/{project}/locations/{location}/nodes/{node}" - }; - - // Represents the different states of a TPU node during its lifecycle. - enum State { - // TPU node state is not known/set. - STATE_UNSPECIFIED = 0; - - // TPU node is being created. - CREATING = 1; - - // TPU node has been created. - READY = 2; - - // TPU node is restarting. - RESTARTING = 3; - - // TPU node is undergoing reimaging. - REIMAGING = 4; - - // TPU node is being deleted. - DELETING = 5; - - // TPU node is being repaired and may be unusable. Details can be - // found in the `help_description` field. - REPAIRING = 6; - - // TPU node is stopped. - STOPPED = 8; - - // TPU node is currently stopping. - STOPPING = 9; - - // TPU node is currently starting. - STARTING = 10; - - // TPU node has been preempted. Only applies to Preemptible TPU Nodes. - PREEMPTED = 11; - - // TPU node has been terminated due to maintenance or has reached the end of - // its life cycle (for preemptible nodes). - TERMINATED = 12; - - // TPU node is currently hiding. - HIDING = 13; - - // TPU node has been hidden. - HIDDEN = 14; - - // TPU node is currently unhiding. - UNHIDING = 15; - } - - // Health defines the status of a TPU node as reported by - // Health Monitor. - enum Health { - // Health status is unknown: not initialized or failed to retrieve. - HEALTH_UNSPECIFIED = 0; - - // The resource is healthy. - HEALTHY = 1; - - // The resource is unhealthy. - DEPRECATED_UNHEALTHY = 2; - - // The resource is unresponsive. - TIMEOUT = 3; - - // The in-guest ML stack is unhealthy. - UNHEALTHY_TENSORFLOW = 4; - - // The node is under maintenance/priority boost caused rescheduling and - // will resume running once rescheduled. - UNHEALTHY_MAINTENANCE = 5; - } - - // TPU API Version. - enum ApiVersion { - // API version is unknown. - API_VERSION_UNSPECIFIED = 0; - - // TPU API V1Alpha1 version. - V1_ALPHA1 = 1; - - // TPU API V1 version. - V1 = 2; - - // TPU API V2Alpha1 version. - V2_ALPHA1 = 3; - } - - // Output only. Immutable. The name of the TPU - string name = 1 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // The user-supplied description of the TPU. Maximum of 512 characters. - string description = 3; - - // Required. The type of hardware accelerators associated with this node. - string accelerator_type = 5 [(google.api.field_behavior) = REQUIRED]; - - // Output only. DEPRECATED! Use network_endpoints instead. - // The network address for the TPU Node as visible to Compute Engine - // instances. - string ip_address = 8 [deprecated = true]; - - // Output only. DEPRECATED! Use network_endpoints instead. - // The network port for the TPU Node as visible to Compute Engine instances. - string port = 14 [deprecated = true]; - - // Output only. The current state for the TPU Node. - State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If this field is populated, it contains a description of why the TPU Node - // is unhealthy. - string health_description = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The version of Tensorflow running in the Node. - string tensorflow_version = 11 [(google.api.field_behavior) = REQUIRED]; - - // The name of a network they wish to peer the TPU node to. It must be a - // preexisting Compute Engine network inside of the project on which this API - // has been activated. If none is provided, "default" will be used. - string network = 12; - - // The CIDR block that the TPU node will use when selecting an IP address. - // This CIDR block must be a /29 block; the Compute Engine networks API - // forbids a smaller block, and using a larger block would be wasteful (a - // node can only consume one IP address). Errors will occur if the CIDR block - // has already been used for a currently existing TPU node, the CIDR block - // conflicts with any subnetworks in the user's provided network, or the - // provided network is peered with another network that is using that CIDR - // block. - string cidr_block = 13; - - // Output only. The service account used to run the tensor flow services within the node. - // To share resources, including Google Cloud Storage data, with the - // Tensorflow job running in the Node, this account must have permissions to - // that data. - string service_account = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the node was created. - google.protobuf.Timestamp create_time = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The scheduling options for this node. - SchedulingConfig scheduling_config = 17; - - // Output only. The network endpoints where TPU workers can be accessed and - // sent work. It is recommended that Tensorflow clients of the node reach out - // to the 0th entry in this map first. - repeated NetworkEndpoint network_endpoints = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The health status of the TPU node. - Health health = 22; - - // Resource labels to represent user-provided metadata. - map labels = 24; - - // Whether the VPC peering for the node is set up through Service Networking - // API. The VPC Peering should be set up before provisioning the node. - // If this field is set, cidr_block field should not be specified. If the - // network, that you want to peer the TPU Node to, is Shared VPC networks, - // the node must be created with this this field enabled. - bool use_service_networking = 27; - - // Output only. The API version that created this Node. - ApiVersion api_version = 38 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Symptoms that have occurred to the TPU Node. - repeated Symptom symptoms = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Request for [ListNodes][google.cloud.tpu.v1.Tpu.ListNodes]. -message ListNodesRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "tpu.googleapis.com/Node" - } - ]; - - // The maximum number of items to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; -} - -// Response for [ListNodes][google.cloud.tpu.v1.Tpu.ListNodes]. -message ListNodesResponse { - // The listed nodes. - repeated Node nodes = 1; - - // The next page token or empty if none. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for [GetNode][google.cloud.tpu.v1.Tpu.GetNode]. -message GetNodeRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/Node" - } - ]; -} - -// Request for [CreateNode][google.cloud.tpu.v1.Tpu.CreateNode]. -message CreateNodeRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "tpu.googleapis.com/Node" - } - ]; - - // The unqualified resource name. - string node_id = 2; - - // Required. The node. - Node node = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [DeleteNode][google.cloud.tpu.v1.Tpu.DeleteNode]. -message DeleteNodeRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/Node" - } - ]; -} - -// Request for [ReimageNode][google.cloud.tpu.v1.Tpu.ReimageNode]. -message ReimageNodeRequest { - // The resource name. - string name = 1; - - // The version for reimage to create. - string tensorflow_version = 2; -} - -// Request for [StopNode][google.cloud.tpu.v1.Tpu.StopNode]. -message StopNodeRequest { - // The resource name. - string name = 1; -} - -// Request for [StartNode][google.cloud.tpu.v1.Tpu.StartNode]. -message StartNodeRequest { - // The resource name. - string name = 1; -} - -// A tensorflow version that a Node can be configured with. -message TensorFlowVersion { - option (google.api.resource) = { - type: "tpu.googleapis.com/TensorFlowVersion" - pattern: "projects/{project}/locations/{location}/tensorFlowVersions/{tensor_flow_version}" - }; - - // The resource name. - string name = 1; - - // the tensorflow version. - string version = 2; -} - -// Request for [GetTensorFlowVersion][google.cloud.tpu.v1.Tpu.GetTensorFlowVersion]. -message GetTensorFlowVersionRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/TensorFlowVersion" - } - ]; -} - -// Request for [ListTensorFlowVersions][google.cloud.tpu.v1.Tpu.ListTensorFlowVersions]. -message ListTensorFlowVersionsRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/TensorFlowVersion" - } - ]; - - // The maximum number of items to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; - - // List filter. - string filter = 5; - - // Sort results. - string order_by = 6; -} - -// Response for [ListTensorFlowVersions][google.cloud.tpu.v1.Tpu.ListTensorFlowVersions]. -message ListTensorFlowVersionsResponse { - // The listed nodes. - repeated TensorFlowVersion tensorflow_versions = 1; - - // The next page token or empty if none. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// A accelerator type that a Node can be configured with. -message AcceleratorType { - option (google.api.resource) = { - type: "tpu.googleapis.com/AcceleratorType" - pattern: "projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}" - }; - - // The resource name. - string name = 1; - - // the accelerator type. - string type = 2; -} - -// Request for [GetAcceleratorType][google.cloud.tpu.v1.Tpu.GetAcceleratorType]. -message GetAcceleratorTypeRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/AcceleratorType" - } - ]; -} - -// Request for [ListAcceleratorTypes][google.cloud.tpu.v1.Tpu.ListAcceleratorTypes]. -message ListAcceleratorTypesRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/AcceleratorType" - } - ]; - - // The maximum number of items to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; - - // List filter. - string filter = 5; - - // Sort results. - string order_by = 6; -} - -// Response for [ListAcceleratorTypes][google.cloud.tpu.v1.Tpu.ListAcceleratorTypes]. -message ListAcceleratorTypesResponse { - // The listed nodes. - repeated AcceleratorType accelerator_types = 1; - - // The next page token or empty if none. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Metadata describing an [Operation][google.longrunning.Operation] -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Target of the operation - for example - // projects/project-1/connectivityTests/test-1 - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // Human-readable status of the operation, if any. - string status_detail = 5; - - // Specifies if cancellation was requested for the operation. - bool cancel_requested = 6; - - // API version. - string api_version = 7; -} - -// A Symptom instance. -message Symptom { - // SymptomType represents the different types of Symptoms that a TPU can be - // at. - enum SymptomType { - // Unspecified symptom. - SYMPTOM_TYPE_UNSPECIFIED = 0; - - // TPU VM memory is low. - LOW_MEMORY = 1; - - // TPU runtime is out of memory. - OUT_OF_MEMORY = 2; - - // TPU runtime execution has timed out. - EXECUTE_TIMED_OUT = 3; - - // TPU runtime fails to construct a mesh that recognizes each TPU device's - // neighbors. - MESH_BUILD_FAIL = 4; - - // TPU HBM is out of memory. - HBM_OUT_OF_MEMORY = 5; - - // Abusive behaviors have been identified on the current project. - PROJECT_ABUSE = 6; - } - - // Timestamp when the Symptom is created. - google.protobuf.Timestamp create_time = 1; - - // Type of the Symptom. - SymptomType symptom_type = 2; - - // Detailed information of the current Symptom. - string details = 3; - - // A string used to uniquely distinguish a worker within a TPU node. - string worker_id = 4; -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json deleted file mode 100644 index 749983cd917..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json +++ /dev/null @@ -1,507 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-tpu", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.tpu.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "tpu_v1_generated_Tpu_ListNodes_async", - "title": "Tpu listNodes Sample", - "origin": "API_DEFINITION", - "description": " Lists nodes.", - "canonical": true, - "file": "tpu.list_nodes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListNodes", - "fullName": "google.cloud.tpu.v1.Tpu.ListNodes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v1.ListNodesResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "ListNodes", - "fullName": "google.cloud.tpu.v1.Tpu.ListNodes", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_GetNode_async", - "title": "Tpu getNode Sample", - "origin": "API_DEFINITION", - "description": " Gets the details of a node.", - "canonical": true, - "file": "tpu.get_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetNode", - "fullName": "google.cloud.tpu.v1.Tpu.GetNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v1.Node", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "GetNode", - "fullName": "google.cloud.tpu.v1.Tpu.GetNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_CreateNode_async", - "title": "Tpu createNode Sample", - "origin": "API_DEFINITION", - "description": " Creates a node.", - "canonical": true, - "file": "tpu.create_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateNode", - "fullName": "google.cloud.tpu.v1.Tpu.CreateNode", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "node_id", - "type": "TYPE_STRING" - }, - { - "name": "node", - "type": ".google.cloud.tpu.v1.Node" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "CreateNode", - "fullName": "google.cloud.tpu.v1.Tpu.CreateNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_DeleteNode_async", - "title": "Tpu deleteNode Sample", - "origin": "API_DEFINITION", - "description": " Deletes a node.", - "canonical": true, - "file": "tpu.delete_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteNode", - "fullName": "google.cloud.tpu.v1.Tpu.DeleteNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "DeleteNode", - "fullName": "google.cloud.tpu.v1.Tpu.DeleteNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_ReimageNode_async", - "title": "Tpu reimageNode Sample", - "origin": "API_DEFINITION", - "description": " Reimages a node's OS.", - "canonical": true, - "file": "tpu.reimage_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReimageNode", - "fullName": "google.cloud.tpu.v1.Tpu.ReimageNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "tensorflow_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "ReimageNode", - "fullName": "google.cloud.tpu.v1.Tpu.ReimageNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_StopNode_async", - "title": "Tpu stopNode Sample", - "origin": "API_DEFINITION", - "description": " Stops a node, this operation is only available with single TPU nodes.", - "canonical": true, - "file": "tpu.stop_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopNode", - "fullName": "google.cloud.tpu.v1.Tpu.StopNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "StopNode", - "fullName": "google.cloud.tpu.v1.Tpu.StopNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_StartNode_async", - "title": "Tpu startNode Sample", - "origin": "API_DEFINITION", - "description": " Starts a node.", - "canonical": true, - "file": "tpu.start_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StartNode", - "fullName": "google.cloud.tpu.v1.Tpu.StartNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "StartNode", - "fullName": "google.cloud.tpu.v1.Tpu.StartNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_ListTensorFlowVersions_async", - "title": "Tpu listTensorFlowVersions Sample", - "origin": "API_DEFINITION", - "description": " List TensorFlow versions supported by this API.", - "canonical": true, - "file": "tpu.list_tensor_flow_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTensorFlowVersions", - "fullName": "google.cloud.tpu.v1.Tpu.ListTensorFlowVersions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v1.ListTensorFlowVersionsResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "ListTensorFlowVersions", - "fullName": "google.cloud.tpu.v1.Tpu.ListTensorFlowVersions", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_GetTensorFlowVersion_async", - "title": "Tpu getTensorFlowVersion Sample", - "origin": "API_DEFINITION", - "description": " Gets TensorFlow Version.", - "canonical": true, - "file": "tpu.get_tensor_flow_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTensorFlowVersion", - "fullName": "google.cloud.tpu.v1.Tpu.GetTensorFlowVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v1.TensorFlowVersion", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "GetTensorFlowVersion", - "fullName": "google.cloud.tpu.v1.Tpu.GetTensorFlowVersion", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_ListAcceleratorTypes_async", - "title": "Tpu listAcceleratorTypes Sample", - "origin": "API_DEFINITION", - "description": " Lists accelerator types supported by this API.", - "canonical": true, - "file": "tpu.list_accelerator_types.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListAcceleratorTypes", - "fullName": "google.cloud.tpu.v1.Tpu.ListAcceleratorTypes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v1.ListAcceleratorTypesResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "ListAcceleratorTypes", - "fullName": "google.cloud.tpu.v1.Tpu.ListAcceleratorTypes", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v1_generated_Tpu_GetAcceleratorType_async", - "title": "Tpu getAcceleratorType Sample", - "origin": "API_DEFINITION", - "description": " Gets AcceleratorType.", - "canonical": true, - "file": "tpu.get_accelerator_type.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAcceleratorType", - "fullName": "google.cloud.tpu.v1.Tpu.GetAcceleratorType", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v1.AcceleratorType", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v1.TpuClient" - }, - "method": { - "shortName": "GetAcceleratorType", - "fullName": "google.cloud.tpu.v1.Tpu.GetAcceleratorType", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v1.Tpu" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js deleted file mode 100644 index 35fcf2bec3a..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.create_node.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, node) { - // [START tpu_v1_generated_Tpu_CreateNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The unqualified resource name. - */ - // const nodeId = 'abc123' - /** - * Required. The node. - */ - // const node = {} - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callCreateNode() { - // Construct request - const request = { - parent, - node, - }; - - // Run request - const [operation] = await tpuClient.createNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateNode(); - // [END tpu_v1_generated_Tpu_CreateNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js deleted file mode 100644 index ad364cdbb8a..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.delete_node.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v1_generated_Tpu_DeleteNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callDeleteNode() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await tpuClient.deleteNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteNode(); - // [END tpu_v1_generated_Tpu_DeleteNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js deleted file mode 100644 index b2e8afbdd48..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_accelerator_type.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v1_generated_Tpu_GetAcceleratorType_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetAcceleratorType() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getAcceleratorType(request); - console.log(response); - } - - callGetAcceleratorType(); - // [END tpu_v1_generated_Tpu_GetAcceleratorType_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js deleted file mode 100644 index 70b0c8ff589..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_node.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v1_generated_Tpu_GetNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetNode() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getNode(request); - console.log(response); - } - - callGetNode(); - // [END tpu_v1_generated_Tpu_GetNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js deleted file mode 100644 index 479389099cd..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.get_tensor_flow_version.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v1_generated_Tpu_GetTensorFlowVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetTensorFlowVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getTensorFlowVersion(request); - console.log(response); - } - - callGetTensorFlowVersion(); - // [END tpu_v1_generated_Tpu_GetTensorFlowVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js deleted file mode 100644 index 9458a1aef12..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_accelerator_types.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v1_generated_Tpu_ListAcceleratorTypes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * List filter. - */ - // const filter = 'abc123' - /** - * Sort results. - */ - // const orderBy = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callListAcceleratorTypes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await tpuClient.listAcceleratorTypesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListAcceleratorTypes(); - // [END tpu_v1_generated_Tpu_ListAcceleratorTypes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js deleted file mode 100644 index c7165073b90..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_nodes.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v1_generated_Tpu_ListNodes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callListNodes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await tpuClient.listNodesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListNodes(); - // [END tpu_v1_generated_Tpu_ListNodes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js deleted file mode 100644 index 6884855a885..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.list_tensor_flow_versions.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v1_generated_Tpu_ListTensorFlowVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * List filter. - */ - // const filter = 'abc123' - /** - * Sort results. - */ - // const orderBy = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callListTensorFlowVersions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await tpuClient.listTensorFlowVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTensorFlowVersions(); - // [END tpu_v1_generated_Tpu_ListTensorFlowVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js deleted file mode 100644 index 5963a05144d..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.reimage_node.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START tpu_v1_generated_Tpu_ReimageNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The resource name. - */ - // const name = 'abc123' - /** - * The version for reimage to create. - */ - // const tensorflowVersion = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callReimageNode() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await tpuClient.reimageNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callReimageNode(); - // [END tpu_v1_generated_Tpu_ReimageNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js deleted file mode 100644 index 61d31d20b5a..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.start_node.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START tpu_v1_generated_Tpu_StartNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callStartNode() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await tpuClient.startNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStartNode(); - // [END tpu_v1_generated_Tpu_StartNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js b/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js deleted file mode 100644 index e3b7891529f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/samples/generated/v1/tpu.stop_node.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START tpu_v1_generated_Tpu_StopNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callStopNode() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await tpuClient.stopNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStopNode(); - // [END tpu_v1_generated_Tpu_StopNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/index.ts b/owl-bot-staging/google-cloud-tpu/v1/src/index.ts deleted file mode 100644 index 5dedc6879ab..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const TpuClient = v1.TpuClient; -type TpuClient = v1.TpuClient; -export {v1, TpuClient}; -export default {v1, TpuClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json deleted file mode 100644 index b15f377b942..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.tpu.v1", - "libraryPackage": "@google-cloud/tpu", - "services": { - "Tpu": { - "clients": { - "grpc": { - "libraryClient": "TpuClient", - "rpcs": { - "GetNode": { - "methods": [ - "getNode" - ] - }, - "GetTensorFlowVersion": { - "methods": [ - "getTensorFlowVersion" - ] - }, - "GetAcceleratorType": { - "methods": [ - "getAcceleratorType" - ] - }, - "CreateNode": { - "methods": [ - "createNode" - ] - }, - "DeleteNode": { - "methods": [ - "deleteNode" - ] - }, - "ReimageNode": { - "methods": [ - "reimageNode" - ] - }, - "StopNode": { - "methods": [ - "stopNode" - ] - }, - "StartNode": { - "methods": [ - "startNode" - ] - }, - "ListNodes": { - "methods": [ - "listNodes", - "listNodesStream", - "listNodesAsync" - ] - }, - "ListTensorFlowVersions": { - "methods": [ - "listTensorFlowVersions", - "listTensorFlowVersionsStream", - "listTensorFlowVersionsAsync" - ] - }, - "ListAcceleratorTypes": { - "methods": [ - "listAcceleratorTypes", - "listAcceleratorTypesStream", - "listAcceleratorTypesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TpuClient", - "rpcs": { - "GetNode": { - "methods": [ - "getNode" - ] - }, - "GetTensorFlowVersion": { - "methods": [ - "getTensorFlowVersion" - ] - }, - "GetAcceleratorType": { - "methods": [ - "getAcceleratorType" - ] - }, - "CreateNode": { - "methods": [ - "createNode" - ] - }, - "DeleteNode": { - "methods": [ - "deleteNode" - ] - }, - "ReimageNode": { - "methods": [ - "reimageNode" - ] - }, - "StopNode": { - "methods": [ - "stopNode" - ] - }, - "StartNode": { - "methods": [ - "startNode" - ] - }, - "ListNodes": { - "methods": [ - "listNodes", - "listNodesStream", - "listNodesAsync" - ] - }, - "ListTensorFlowVersions": { - "methods": [ - "listTensorFlowVersions", - "listTensorFlowVersionsStream", - "listTensorFlowVersionsAsync" - ] - }, - "ListAcceleratorTypes": { - "methods": [ - "listAcceleratorTypes", - "listAcceleratorTypesStream", - "listAcceleratorTypesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts deleted file mode 100644 index 27c81814923..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {TpuClient} from './tpu_client'; diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts deleted file mode 100644 index 9bd1d3dc3bd..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client.ts +++ /dev/null @@ -1,2091 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/tpu_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tpu_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages TPU nodes and other resources - * - * TPU API v1 - * @class - * @memberof v1 - */ -export class TpuClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tpuStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TpuClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new TpuClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TpuClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - 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. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - acceleratorTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - nodePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/nodes/{node}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tensorFlowVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/tensorFlowVersions/{tensor_flow_version}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listNodes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'nodes'), - listTensorFlowVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tensorflowVersions'), - listAcceleratorTypes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'acceleratorTypes') - }; - - 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 lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; - const createNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; - const deleteNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; - const deleteNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; - const reimageNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; - const reimageNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; - const stopNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; - const stopNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; - const startNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.Node') as gax.protobuf.Type; - const startNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createNodeResponse.decode.bind(createNodeResponse), - createNodeMetadata.decode.bind(createNodeMetadata)), - deleteNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteNodeResponse.decode.bind(deleteNodeResponse), - deleteNodeMetadata.decode.bind(deleteNodeMetadata)), - reimageNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reimageNodeResponse.decode.bind(reimageNodeResponse), - reimageNodeMetadata.decode.bind(reimageNodeMetadata)), - stopNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - stopNodeResponse.decode.bind(stopNodeResponse), - stopNodeMetadata.decode.bind(stopNodeMetadata)), - startNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - startNodeResponse.decode.bind(startNodeResponse), - startNodeMetadata.decode.bind(startNodeMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.tpu.v1.Tpu', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.tpuStub) { - return this.tpuStub; - } - - // Put together the "service stub" for - // google.cloud.tpu.v1.Tpu. - this.tpuStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.tpu.v1.Tpu') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.tpu.v1.Tpu, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const tpuStubMethods = - ['listNodes', 'getNode', 'createNode', 'deleteNode', 'reimageNode', 'stopNode', 'startNode', 'listTensorFlowVersions', 'getTensorFlowVersion', 'listAcceleratorTypes', 'getAcceleratorType']; - for (const methodName of tpuStubMethods) { - const callPromise = this.tpuStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.tpuStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'tpu.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'tpu.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets the details of a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Node]{@link google.cloud.tpu.v1.Node}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/tpu.get_node.js - * region_tag:tpu_v1_generated_Tpu_GetNode_async - */ - getNode( - request?: protos.google.cloud.tpu.v1.IGetNodeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v1.INode, - protos.google.cloud.tpu.v1.IGetNodeRequest|undefined, {}|undefined - ]>; - getNode( - request: protos.google.cloud.tpu.v1.IGetNodeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v1.INode, - protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, - {}|null|undefined>): void; - getNode( - request: protos.google.cloud.tpu.v1.IGetNodeRequest, - callback: Callback< - protos.google.cloud.tpu.v1.INode, - protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, - {}|null|undefined>): void; - getNode( - request?: protos.google.cloud.tpu.v1.IGetNodeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v1.INode, - protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v1.INode, - protos.google.cloud.tpu.v1.IGetNodeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v1.INode, - protos.google.cloud.tpu.v1.IGetNodeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getNode(request, options, callback); - } -/** - * Gets TensorFlow Version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/tpu.get_tensor_flow_version.js - * region_tag:tpu_v1_generated_Tpu_GetTensorFlowVersion_async - */ - getTensorFlowVersion( - request?: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v1.ITensorFlowVersion, - protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|undefined, {}|undefined - ]>; - getTensorFlowVersion( - request: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v1.ITensorFlowVersion, - protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, - {}|null|undefined>): void; - getTensorFlowVersion( - request: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, - callback: Callback< - protos.google.cloud.tpu.v1.ITensorFlowVersion, - protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, - {}|null|undefined>): void; - getTensorFlowVersion( - request?: protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v1.ITensorFlowVersion, - protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v1.ITensorFlowVersion, - protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v1.ITensorFlowVersion, - protos.google.cloud.tpu.v1.IGetTensorFlowVersionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getTensorFlowVersion(request, options, callback); - } -/** - * Gets AcceleratorType. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/tpu.get_accelerator_type.js - * region_tag:tpu_v1_generated_Tpu_GetAcceleratorType_async - */ - getAcceleratorType( - request?: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v1.IAcceleratorType, - protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|undefined, {}|undefined - ]>; - getAcceleratorType( - request: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v1.IAcceleratorType, - protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>): void; - getAcceleratorType( - request: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, - callback: Callback< - protos.google.cloud.tpu.v1.IAcceleratorType, - protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>): void; - getAcceleratorType( - request?: protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v1.IAcceleratorType, - protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v1.IAcceleratorType, - protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v1.IAcceleratorType, - protos.google.cloud.tpu.v1.IGetAcceleratorTypeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getAcceleratorType(request, options, callback); - } - -/** - * Creates a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {string} request.nodeId - * The unqualified resource name. - * @param {google.cloud.tpu.v1.Node} request.node - * Required. The node. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.create_node.js - * region_tag:tpu_v1_generated_Tpu_CreateNode_async - */ - createNode( - request?: protos.google.cloud.tpu.v1.ICreateNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createNode( - request: protos.google.cloud.tpu.v1.ICreateNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createNode( - request: protos.google.cloud.tpu.v1.ICreateNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createNode( - request?: protos.google.cloud.tpu.v1.ICreateNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.create_node.js - * region_tag:tpu_v1_generated_Tpu_CreateNode_async - */ - async checkCreateNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.delete_node.js - * region_tag:tpu_v1_generated_Tpu_DeleteNode_async - */ - deleteNode( - request?: protos.google.cloud.tpu.v1.IDeleteNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteNode( - request: protos.google.cloud.tpu.v1.IDeleteNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteNode( - request: protos.google.cloud.tpu.v1.IDeleteNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteNode( - request?: protos.google.cloud.tpu.v1.IDeleteNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.delete_node.js - * region_tag:tpu_v1_generated_Tpu_DeleteNode_async - */ - async checkDeleteNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Reimages a node's OS. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name. - * @param {string} request.tensorflowVersion - * The version for reimage to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.reimage_node.js - * region_tag:tpu_v1_generated_Tpu_ReimageNode_async - */ - reimageNode( - request?: protos.google.cloud.tpu.v1.IReimageNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - reimageNode( - request: protos.google.cloud.tpu.v1.IReimageNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reimageNode( - request: protos.google.cloud.tpu.v1.IReimageNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reimageNode( - request?: protos.google.cloud.tpu.v1.IReimageNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.reimageNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `reimageNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.reimage_node.js - * region_tag:tpu_v1_generated_Tpu_ReimageNode_async - */ - async checkReimageNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reimageNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Stops a node, this operation is only available with single TPU nodes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.stop_node.js - * region_tag:tpu_v1_generated_Tpu_StopNode_async - */ - stopNode( - request?: protos.google.cloud.tpu.v1.IStopNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - stopNode( - request: protos.google.cloud.tpu.v1.IStopNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopNode( - request: protos.google.cloud.tpu.v1.IStopNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopNode( - request?: protos.google.cloud.tpu.v1.IStopNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `stopNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.stop_node.js - * region_tag:tpu_v1_generated_Tpu_StopNode_async - */ - async checkStopNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.stopNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.start_node.js - * region_tag:tpu_v1_generated_Tpu_StartNode_async - */ - startNode( - request?: protos.google.cloud.tpu.v1.IStartNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - startNode( - request: protos.google.cloud.tpu.v1.IStartNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startNode( - request: protos.google.cloud.tpu.v1.IStartNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startNode( - request?: protos.google.cloud.tpu.v1.IStartNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.startNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `startNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/tpu.start_node.js - * region_tag:tpu_v1_generated_Tpu_StartNode_async - */ - async checkStartNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.startNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists nodes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Node]{@link google.cloud.tpu.v1.Node}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listNodesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listNodes( - request?: protos.google.cloud.tpu.v1.IListNodesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v1.INode[], - protos.google.cloud.tpu.v1.IListNodesRequest|null, - protos.google.cloud.tpu.v1.IListNodesResponse - ]>; - listNodes( - request: protos.google.cloud.tpu.v1.IListNodesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tpu.v1.IListNodesRequest, - protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v1.INode>): void; - listNodes( - request: protos.google.cloud.tpu.v1.IListNodesRequest, - callback: PaginationCallback< - protos.google.cloud.tpu.v1.IListNodesRequest, - protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v1.INode>): void; - listNodes( - request?: protos.google.cloud.tpu.v1.IListNodesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tpu.v1.IListNodesRequest, - protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v1.INode>, - callback?: PaginationCallback< - protos.google.cloud.tpu.v1.IListNodesRequest, - protos.google.cloud.tpu.v1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v1.INode>): - Promise<[ - protos.google.cloud.tpu.v1.INode[], - protos.google.cloud.tpu.v1.IListNodesRequest|null, - protos.google.cloud.tpu.v1.IListNodesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listNodes(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Node]{@link google.cloud.tpu.v1.Node} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listNodesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listNodesStream( - request?: protos.google.cloud.tpu.v1.IListNodesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listNodes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listNodes.createStream( - this.innerApiCalls.listNodes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listNodes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Node]{@link google.cloud.tpu.v1.Node}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/tpu.list_nodes.js - * region_tag:tpu_v1_generated_Tpu_ListNodes_async - */ - listNodesAsync( - request?: protos.google.cloud.tpu.v1.IListNodesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listNodes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listNodes.asyncIterate( - this.innerApiCalls['listNodes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List TensorFlow versions supported by this API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTensorFlowVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listTensorFlowVersions( - request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v1.ITensorFlowVersion[], - protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest|null, - protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse - ]>; - listTensorFlowVersions( - request: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, - protos.google.cloud.tpu.v1.ITensorFlowVersion>): void; - listTensorFlowVersions( - request: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, - protos.google.cloud.tpu.v1.ITensorFlowVersion>): void; - listTensorFlowVersions( - request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, - protos.google.cloud.tpu.v1.ITensorFlowVersion>, - callback?: PaginationCallback< - protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse|null|undefined, - protos.google.cloud.tpu.v1.ITensorFlowVersion>): - Promise<[ - protos.google.cloud.tpu.v1.ITensorFlowVersion[], - protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest|null, - protos.google.cloud.tpu.v1.IListTensorFlowVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listTensorFlowVersions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTensorFlowVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listTensorFlowVersionsStream( - request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listTensorFlowVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTensorFlowVersions.createStream( - this.innerApiCalls.listTensorFlowVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTensorFlowVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [TensorFlowVersion]{@link google.cloud.tpu.v1.TensorFlowVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/tpu.list_tensor_flow_versions.js - * region_tag:tpu_v1_generated_Tpu_ListTensorFlowVersions_async - */ - listTensorFlowVersionsAsync( - request?: protos.google.cloud.tpu.v1.IListTensorFlowVersionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listTensorFlowVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTensorFlowVersions.asyncIterate( - this.innerApiCalls['listTensorFlowVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists accelerator types supported by this API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAcceleratorTypesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listAcceleratorTypes( - request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v1.IAcceleratorType[], - protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest|null, - protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse - ]>; - listAcceleratorTypes( - request: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v1.IAcceleratorType>): void; - listAcceleratorTypes( - request: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - callback: PaginationCallback< - protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v1.IAcceleratorType>): void; - listAcceleratorTypes( - request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v1.IAcceleratorType>, - callback?: PaginationCallback< - protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v1.IAcceleratorType>): - Promise<[ - protos.google.cloud.tpu.v1.IAcceleratorType[], - protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest|null, - protos.google.cloud.tpu.v1.IListAcceleratorTypesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listAcceleratorTypes(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAcceleratorTypesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listAcceleratorTypesStream( - request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listAcceleratorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAcceleratorTypes.createStream( - this.innerApiCalls.listAcceleratorTypes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listAcceleratorTypes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [AcceleratorType]{@link google.cloud.tpu.v1.AcceleratorType}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/tpu.list_accelerator_types.js - * region_tag:tpu_v1_generated_Tpu_ListAcceleratorTypes_async - */ - listAcceleratorTypesAsync( - request?: protos.google.cloud.tpu.v1.IListAcceleratorTypesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listAcceleratorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAcceleratorTypes.asyncIterate( - this.innerApiCalls['listAcceleratorTypes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. The promise has a method named - * "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified acceleratorType resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} accelerator_type - * @returns {string} Resource name string. - */ - acceleratorTypePath(project:string,location:string,acceleratorType:string) { - return this.pathTemplates.acceleratorTypePathTemplate.render({ - project: project, - location: location, - accelerator_type: acceleratorType, - }); - } - - /** - * Parse the project from AcceleratorType resource. - * - * @param {string} acceleratorTypeName - * A fully-qualified path representing AcceleratorType resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAcceleratorTypeName(acceleratorTypeName: string) { - return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).project; - } - - /** - * Parse the location from AcceleratorType resource. - * - * @param {string} acceleratorTypeName - * A fully-qualified path representing AcceleratorType resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAcceleratorTypeName(acceleratorTypeName: string) { - return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).location; - } - - /** - * Parse the accelerator_type from AcceleratorType resource. - * - * @param {string} acceleratorTypeName - * A fully-qualified path representing AcceleratorType resource. - * @returns {string} A string representing the accelerator_type. - */ - matchAcceleratorTypeFromAcceleratorTypeName(acceleratorTypeName: string) { - return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).accelerator_type; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified node resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} node - * @returns {string} Resource name string. - */ - nodePath(project:string,location:string,node:string) { - return this.pathTemplates.nodePathTemplate.render({ - project: project, - location: location, - node: node, - }); - } - - /** - * Parse the project from Node resource. - * - * @param {string} nodeName - * A fully-qualified path representing Node resource. - * @returns {string} A string representing the project. - */ - matchProjectFromNodeName(nodeName: string) { - return this.pathTemplates.nodePathTemplate.match(nodeName).project; - } - - /** - * Parse the location from Node resource. - * - * @param {string} nodeName - * A fully-qualified path representing Node resource. - * @returns {string} A string representing the location. - */ - matchLocationFromNodeName(nodeName: string) { - return this.pathTemplates.nodePathTemplate.match(nodeName).location; - } - - /** - * Parse the node from Node resource. - * - * @param {string} nodeName - * A fully-qualified path representing Node resource. - * @returns {string} A string representing the node. - */ - matchNodeFromNodeName(nodeName: string) { - return this.pathTemplates.nodePathTemplate.match(nodeName).node; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tensorFlowVersion resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} tensor_flow_version - * @returns {string} Resource name string. - */ - tensorFlowVersionPath(project:string,location:string,tensorFlowVersion:string) { - return this.pathTemplates.tensorFlowVersionPathTemplate.render({ - project: project, - location: location, - tensor_flow_version: tensorFlowVersion, - }); - } - - /** - * Parse the project from TensorFlowVersion resource. - * - * @param {string} tensorFlowVersionName - * A fully-qualified path representing TensorFlowVersion resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTensorFlowVersionName(tensorFlowVersionName: string) { - return this.pathTemplates.tensorFlowVersionPathTemplate.match(tensorFlowVersionName).project; - } - - /** - * Parse the location from TensorFlowVersion resource. - * - * @param {string} tensorFlowVersionName - * A fully-qualified path representing TensorFlowVersion resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTensorFlowVersionName(tensorFlowVersionName: string) { - return this.pathTemplates.tensorFlowVersionPathTemplate.match(tensorFlowVersionName).location; - } - - /** - * Parse the tensor_flow_version from TensorFlowVersion resource. - * - * @param {string} tensorFlowVersionName - * A fully-qualified path representing TensorFlowVersion resource. - * @returns {string} A string representing the tensor_flow_version. - */ - matchTensorFlowVersionFromTensorFlowVersionName(tensorFlowVersionName: string) { - return this.pathTemplates.tensorFlowVersionPathTemplate.match(tensorFlowVersionName).tensor_flow_version; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.tpuStub && !this._terminated) { - return this.tpuStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json deleted file mode 100644 index 77bd991e873..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_client_config.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "interfaces": { - "google.cloud.tpu.v1.Tpu": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListNodes": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ReimageNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StartNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListTensorFlowVersions": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetTensorFlowVersion": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListAcceleratorTypes": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAcceleratorType": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json b/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json deleted file mode 100644 index c79018be060..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/src/v1/tpu_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/tpu/v1/cloud_tpu.proto" -] diff --git a/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 9cb87c17e68..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const tpu = require('@google-cloud/tpu'); - -function main() { - const tpuClient = new tpu.TpuClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 50ac473b84f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {TpuClient} from '@google-cloud/tpu'; - -// check that the client class type name can be used -function doStuffWithTpuClient(client: TpuClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const tpuClient = new TpuClient(); - doStuffWithTpuClient(tpuClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts b/owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts b/owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts deleted file mode 100644 index b3743be7903..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/test/gapic_tpu_v1.ts +++ /dev/null @@ -1,2672 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as tpuModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.TpuClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tpuModule.v1.TpuClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tpuModule.v1.TpuClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tpuModule.v1.TpuClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tpuModule.v1.TpuClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tpuModule.v1.TpuClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tpuStub, undefined); - await client.initialize(); - assert(client.tpuStub); - }); - - it('has close method for the initialized client', done => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tpuStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tpuStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getNode', () => { - it('invokes getNode without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v1.Node() - ); - client.innerApiCalls.getNode = stubSimpleCall(expectedResponse); - const [response] = await client.getNode(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v1.Node() - ); - client.innerApiCalls.getNode = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNode( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v1.INode|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getNode = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNode(request), expectedError); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode with closed client', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getNode(request), expectedError); - }); - }); - - describe('getTensorFlowVersion', () => { - it('invokes getTensorFlowVersion without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v1.TensorFlowVersion() - ); - client.innerApiCalls.getTensorFlowVersion = stubSimpleCall(expectedResponse); - const [response] = await client.getTensorFlowVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTensorFlowVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTensorFlowVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTensorFlowVersion without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v1.TensorFlowVersion() - ); - client.innerApiCalls.getTensorFlowVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTensorFlowVersion( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v1.ITensorFlowVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTensorFlowVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTensorFlowVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTensorFlowVersion with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTensorFlowVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTensorFlowVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.getTensorFlowVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTensorFlowVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTensorFlowVersion with closed client', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetTensorFlowVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetTensorFlowVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTensorFlowVersion(request), expectedError); - }); - }); - - describe('getAcceleratorType', () => { - it('invokes getAcceleratorType without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v1.AcceleratorType() - ); - client.innerApiCalls.getAcceleratorType = stubSimpleCall(expectedResponse); - const [response] = await client.getAcceleratorType(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAcceleratorType without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v1.AcceleratorType() - ); - client.innerApiCalls.getAcceleratorType = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAcceleratorType( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v1.IAcceleratorType|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAcceleratorType with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAcceleratorType = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAcceleratorType(request), expectedError); - const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAcceleratorType with closed client', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAcceleratorType(request), expectedError); - }); - }); - - describe('createNode', () => { - it('invokes createNode without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.createNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNode without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNode with call error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createNode(request), expectedError); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNode with LRO error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateNodeProgress without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateNodeProgress with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteNode', () => { - it('invokes deleteNode without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNode without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNode with call error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteNode(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNode with LRO error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteNodeProgress without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteNodeProgress with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('reimageNode', () => { - it('invokes reimageNode without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ReimageNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reimageNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.reimageNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reimageNode without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ReimageNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reimageNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reimageNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reimageNode with call error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ReimageNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reimageNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reimageNode(request), expectedError); - const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reimageNode with LRO error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ReimageNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ReimageNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reimageNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reimageNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reimageNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkReimageNodeProgress without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReimageNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReimageNodeProgress with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReimageNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('stopNode', () => { - it('invokes stopNode without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopNode without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopNode with call error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopNode(request), expectedError); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopNode with LRO error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopNodeProgress without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStopNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopNodeProgress with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('startNode', () => { - it('invokes startNode without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.startNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startNode without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startNode with call error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startNode(request), expectedError); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startNode with LRO error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartNodeProgress without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartNodeProgress with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listNodes', () => { - it('invokes listNodes without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - ]; - client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); - const [response] = await client.listNodes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodes without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - ]; - client.innerApiCalls.listNodes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNodes( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v1.INode[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodes with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNodes(request), expectedError); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodesStream without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - ]; - client.descriptors.page.listNodes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v1.Node[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v1.Node) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); - assert( - (client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listNodesStream with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listNodes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v1.Node[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v1.Node) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); - assert( - (client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNodes without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v1.Node()), - ]; - client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tpu.v1.INode[] = []; - const iterable = client.listNodesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNodes with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNodesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tpu.v1.INode[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listTensorFlowVersions', () => { - it('invokes listTensorFlowVersions without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - ]; - client.innerApiCalls.listTensorFlowVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listTensorFlowVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTensorFlowVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTensorFlowVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTensorFlowVersions without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - ]; - client.innerApiCalls.listTensorFlowVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTensorFlowVersions( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v1.ITensorFlowVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTensorFlowVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTensorFlowVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTensorFlowVersions with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTensorFlowVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTensorFlowVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listTensorFlowVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTensorFlowVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTensorFlowVersionsStream without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - ]; - client.descriptors.page.listTensorFlowVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTensorFlowVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v1.TensorFlowVersion[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v1.TensorFlowVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTensorFlowVersions, request)); - assert( - (client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listTensorFlowVersionsStream with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTensorFlowVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTensorFlowVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v1.TensorFlowVersion[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v1.TensorFlowVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTensorFlowVersions, request)); - assert( - (client.descriptors.page.listTensorFlowVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTensorFlowVersions without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v1.TensorFlowVersion()), - ]; - client.descriptors.page.listTensorFlowVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tpu.v1.ITensorFlowVersion[] = []; - const iterable = client.listTensorFlowVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTensorFlowVersions with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListTensorFlowVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListTensorFlowVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTensorFlowVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTensorFlowVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tpu.v1.ITensorFlowVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTensorFlowVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listAcceleratorTypes', () => { - it('invokes listAcceleratorTypes without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - ]; - client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(expectedResponse); - const [response] = await client.listAcceleratorTypes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAcceleratorTypes without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - ]; - client.innerApiCalls.listAcceleratorTypes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAcceleratorTypes( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v1.IAcceleratorType[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAcceleratorTypes with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAcceleratorTypes(request), expectedError); - const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAcceleratorTypesStream without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - ]; - client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAcceleratorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v1.AcceleratorType[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v1.AcceleratorType) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); - assert( - (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAcceleratorTypesStream with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAcceleratorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v1.AcceleratorType[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v1.AcceleratorType) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); - assert( - (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAcceleratorTypes without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v1.AcceleratorType()), - ]; - client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tpu.v1.IAcceleratorType[] = []; - const iterable = client.listAcceleratorTypesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAcceleratorTypes with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAcceleratorTypesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tpu.v1.IAcceleratorType[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('acceleratorType', () => { - const fakePath = "/rendered/path/acceleratorType"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - accelerator_type: "acceleratorTypeValue", - }; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.acceleratorTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.acceleratorTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('acceleratorTypePath', () => { - const result = client.acceleratorTypePath("projectValue", "locationValue", "acceleratorTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.acceleratorTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAcceleratorTypeName', () => { - const result = client.matchProjectFromAcceleratorTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAcceleratorTypeName', () => { - const result = client.matchLocationFromAcceleratorTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAcceleratorTypeFromAcceleratorTypeName', () => { - const result = client.matchAcceleratorTypeFromAcceleratorTypeName(fakePath); - assert.strictEqual(result, "acceleratorTypeValue"); - assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('node', () => { - const fakePath = "/rendered/path/node"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - node: "nodeValue", - }; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.nodePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.nodePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('nodePath', () => { - const result = client.nodePath("projectValue", "locationValue", "nodeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.nodePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNodeName', () => { - const result = client.matchProjectFromNodeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromNodeName', () => { - const result = client.matchLocationFromNodeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNodeFromNodeName', () => { - const result = client.matchNodeFromNodeName(fakePath); - assert.strictEqual(result, "nodeValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tensorFlowVersion', () => { - const fakePath = "/rendered/path/tensorFlowVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - tensor_flow_version: "tensorFlowVersionValue", - }; - const client = new tpuModule.v1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tensorFlowVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tensorFlowVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tensorFlowVersionPath', () => { - const result = client.tensorFlowVersionPath("projectValue", "locationValue", "tensorFlowVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tensorFlowVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTensorFlowVersionName', () => { - const result = client.matchProjectFromTensorFlowVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tensorFlowVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTensorFlowVersionName', () => { - const result = client.matchLocationFromTensorFlowVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tensorFlowVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTensorFlowVersionFromTensorFlowVersionName', () => { - const result = client.matchTensorFlowVersionFromTensorFlowVersionName(fakePath); - assert.strictEqual(result, "tensorFlowVersionValue"); - assert((client.pathTemplates.tensorFlowVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-tpu/v1/tsconfig.json b/owl-bot-staging/google-cloud-tpu/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-tpu/v1/webpack.config.js b/owl-bot-staging/google-cloud-tpu/v1/webpack.config.js deleted file mode 100644 index 8ee514d072f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Tpu', - filename: './tpu.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore b/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore b/owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js deleted file mode 100644 index 5b3c57ae725..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/tpu', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/README.md b/owl-bot-staging/google-cloud-tpu/v2alpha1/README.md deleted file mode 100644 index b04db0dc280..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/README.md +++ /dev/null @@ -1 +0,0 @@ -Tpu: Nodejs Client diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/package.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/package.json deleted file mode 100644 index 911441f5cee..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/tpu", - "version": "0.1.0", - "description": "Tpu client for Node.js", - "repository": "googleapis/nodejs-tpu", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google tpu", - "tpu", - "tpu" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto b/owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto deleted file mode 100644 index 612e1c4f5dd..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto +++ /dev/null @@ -1,791 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.tpu.v2alpha1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/tpu/v2alpha1;tpu"; -option java_multiple_files = true; -option java_outer_classname = "CloudTpuProto"; -option java_package = "com.google.cloud.tpu.v2alpha1"; - -// Manages TPU nodes and other resources -// -// TPU API v2alpha1 -service Tpu { - option (google.api.default_host) = "tpu.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists nodes. - rpc ListNodes(ListNodesRequest) returns (ListNodesResponse) { - option (google.api.http) = { - get: "/v2alpha1/{parent=projects/*/locations/*}/nodes" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the details of a node. - rpc GetNode(GetNodeRequest) returns (Node) { - option (google.api.http) = { - get: "/v2alpha1/{name=projects/*/locations/*/nodes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a node. - rpc CreateNode(CreateNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha1/{parent=projects/*/locations/*}/nodes" - body: "node" - }; - option (google.api.method_signature) = "parent,node,node_id"; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Deletes a node. - rpc DeleteNode(DeleteNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v2alpha1/{name=projects/*/locations/*/nodes/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Stops a node. This operation is only available with single TPU nodes. - rpc StopNode(StopNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha1/{name=projects/*/locations/*/nodes/*}:stop" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Starts a node. - rpc StartNode(StartNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha1/{name=projects/*/locations/*/nodes/*}:start" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Updates the configurations of a node. - rpc UpdateNode(UpdateNodeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v2alpha1/{node.name=projects/*/locations/*/nodes/*}" - body: "node" - }; - option (google.api.method_signature) = "node,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Node" - metadata_type: "OperationMetadata" - }; - } - - // Generates the Cloud TPU service identity for the project. - rpc GenerateServiceIdentity(GenerateServiceIdentityRequest) - returns (GenerateServiceIdentityResponse) { - option (google.api.http) = { - post: "/v2alpha1/{parent=projects/*/locations/*}:generateServiceIdentity" - body: "*" - }; - } - - // Lists accelerator types supported by this API. - rpc ListAcceleratorTypes(ListAcceleratorTypesRequest) - returns (ListAcceleratorTypesResponse) { - option (google.api.http) = { - get: "/v2alpha1/{parent=projects/*/locations/*}/acceleratorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets AcceleratorType. - rpc GetAcceleratorType(GetAcceleratorTypeRequest) returns (AcceleratorType) { - option (google.api.http) = { - get: "/v2alpha1/{name=projects/*/locations/*/acceleratorTypes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists runtime versions supported by this API. - rpc ListRuntimeVersions(ListRuntimeVersionsRequest) - returns (ListRuntimeVersionsResponse) { - option (google.api.http) = { - get: "/v2alpha1/{parent=projects/*/locations/*}/runtimeVersions" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a runtime version. - rpc GetRuntimeVersion(GetRuntimeVersionRequest) returns (RuntimeVersion) { - option (google.api.http) = { - get: "/v2alpha1/{name=projects/*/locations/*/runtimeVersions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves the guest attributes for the node. - rpc GetGuestAttributes(GetGuestAttributesRequest) - returns (GetGuestAttributesResponse) { - option (google.api.http) = { - post: "/v2alpha1/{name=projects/*/locations/*/nodes/*}:getGuestAttributes" - body: "*" - }; - } -} - -// A guest attributes. -message GuestAttributes { - // The path to be queried. This can be the default namespace ('/') or a - // nested namespace ('/\/') or a specified key - // ('/\/\') - string query_path = 1; - - // The value of the requested queried path. - GuestAttributesValue query_value = 2; -} - -// Array of guest attribute namespace/key/value tuples. -message GuestAttributesValue { - // The list of guest attributes entries. - repeated GuestAttributesEntry items = 1; -} - -// A guest attributes namespace/key/value entry. -message GuestAttributesEntry { - // Namespace for the guest attribute entry. - string namespace = 1; - - // Key for the guest attribute entry. - string key = 2; - - // Value for the guest attribute entry. - string value = 3; -} - -// A node-attached disk resource. -// Next ID: 8; -message AttachedDisk { - // The different mode of the attached disk. - enum DiskMode { - // The disk mode is not known/set. - DISK_MODE_UNSPECIFIED = 0; - - // Attaches the disk in read-write mode. Only one TPU node can attach a disk - // in read-write mode at a time. - READ_WRITE = 1; - - // Attaches the disk in read-only mode. Multiple TPU nodes can attach - // a disk in read-only mode at a time. - READ_ONLY = 2; - } - - // Specifies the full path to an existing disk. - // For example: "projects/my-project/zones/us-central1-c/disks/my-disk". - string source_disk = 3; - - // The mode in which to attach this disk. - // If not specified, the default is READ_WRITE mode. - // Only applicable to data_disks. - DiskMode mode = 4; -} - -// Sets the scheduling options for this node. -message SchedulingConfig { - // Defines whether the node is preemptible. - bool preemptible = 1; - - // Whether the node is created under a reservation. - bool reserved = 2; -} - -// A network endpoint over which a TPU worker can be reached. -message NetworkEndpoint { - // The internal IP address of this network endpoint. - string ip_address = 1; - - // The port of this network endpoint. - int32 port = 2; - - // The access config for the TPU worker. - AccessConfig access_config = 5; -} - -// An access config attached to the TPU worker. -message AccessConfig { - // Output only. An external IP address associated with the TPU worker. - string external_ip = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Network related configurations. -message NetworkConfig { - // The name of the network for the TPU node. It must be a preexisting Google - // Compute Engine network. If none is provided, "default" will be used. - string network = 1; - - // The name of the subnetwork for the TPU node. It must be a preexisting - // Google Compute Engine subnetwork. If none is provided, "default" will be - // used. - string subnetwork = 2; - - // Indicates that external IP addresses would be associated with the TPU - // workers. If set to false, the specified subnetwork or network should have - // Private Google Access enabled. - bool enable_external_ips = 3; -} - -// A service account. -message ServiceAccount { - // Email address of the service account. If empty, default Compute service - // account will be used. - string email = 1; - - // The list of scopes to be made available for this service account. If empty, - // access to all Cloud APIs will be allowed. - repeated string scope = 2; -} - -// A TPU instance. -message Node { - option (google.api.resource) = { - type: "tpu.googleapis.com/Node" - pattern: "projects/{project}/locations/{location}/nodes/{node}" - }; - - // Represents the different states of a TPU node during its lifecycle. - enum State { - // TPU node state is not known/set. - STATE_UNSPECIFIED = 0; - - // TPU node is being created. - CREATING = 1; - - // TPU node has been created. - READY = 2; - - // TPU node is restarting. - RESTARTING = 3; - - // TPU node is undergoing reimaging. - REIMAGING = 4; - - // TPU node is being deleted. - DELETING = 5; - - // TPU node is being repaired and may be unusable. Details can be - // found in the `help_description` field. - REPAIRING = 6; - - // TPU node is stopped. - STOPPED = 8; - - // TPU node is currently stopping. - STOPPING = 9; - - // TPU node is currently starting. - STARTING = 10; - - // TPU node has been preempted. Only applies to Preemptible TPU Nodes. - PREEMPTED = 11; - - // TPU node has been terminated due to maintenance or has reached the end of - // its life cycle (for preemptible nodes). - TERMINATED = 12; - - // TPU node is currently hiding. - HIDING = 13; - - // TPU node has been hidden. - HIDDEN = 14; - - // TPU node is currently unhiding. - UNHIDING = 15; - } - - // Health defines the status of a TPU node as reported by - // Health Monitor. - enum Health { - // Health status is unknown: not initialized or failed to retrieve. - HEALTH_UNSPECIFIED = 0; - - // The resource is healthy. - HEALTHY = 1; - - // The resource is unresponsive. - TIMEOUT = 3; - - // The in-guest ML stack is unhealthy. - UNHEALTHY_TENSORFLOW = 4; - - // The node is under maintenance/priority boost caused rescheduling and - // will resume running once rescheduled. - UNHEALTHY_MAINTENANCE = 5; - } - - // TPU API Version. - enum ApiVersion { - // API version is unknown. - API_VERSION_UNSPECIFIED = 0; - - // TPU API V1Alpha1 version. - V1_ALPHA1 = 1; - - // TPU API V1 version. - V1 = 2; - - // TPU API V2Alpha1 version. - V2_ALPHA1 = 3; - } - - // Output only. Immutable. The name of the TPU. - string name = 1 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = IMMUTABLE - ]; - - // The user-supplied description of the TPU. Maximum of 512 characters. - string description = 3; - - // Required. The type of hardware accelerators associated with this node. - string accelerator_type = 5 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The current state for the TPU Node. - State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. If this field is populated, it contains a description of why - // the TPU Node is unhealthy. - string health_description = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The runtime version running in the Node. - string runtime_version = 11 [(google.api.field_behavior) = REQUIRED]; - - // Network configurations for the TPU node. - NetworkConfig network_config = 36; - - // The CIDR block that the TPU node will use when selecting an IP address. - // This CIDR block must be a /29 block; the Compute Engine networks API - // forbids a smaller block, and using a larger block would be wasteful (a - // node can only consume one IP address). Errors will occur if the CIDR block - // has already been used for a currently existing TPU node, the CIDR block - // conflicts with any subnetworks in the user's provided network, or the - // provided network is peered with another network that is using that CIDR - // block. - string cidr_block = 13; - - // The Google Cloud Platform Service Account to be used by the TPU node VMs. - // If None is specified, the default compute service account will be used. - ServiceAccount service_account = 37; - - // Output only. The time when the node was created. - google.protobuf.Timestamp create_time = 16 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The scheduling options for this node. - SchedulingConfig scheduling_config = 17; - - // Output only. The network endpoints where TPU workers can be accessed and - // sent work. It is recommended that runtime clients of the node reach out - // to the 0th entry in this map first. - repeated NetworkEndpoint network_endpoints = 21 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The health status of the TPU node. - Health health = 22; - - // Resource labels to represent user-provided metadata. - map labels = 24; - - // Custom metadata to apply to the TPU Node. - // Can set startup-script and shutdown-script - map metadata = 34; - - // Tags to apply to the TPU Node. Tags are used to identify valid sources or - // targets for network firewalls. - repeated string tags = 40; - - // Output only. The unique identifier for the TPU Node. - int64 id = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The additional data disks for the Node. - repeated AttachedDisk data_disks = 41; - - // Output only. The API version that created this Node. - ApiVersion api_version = 38 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The Symptoms that have occurred to the TPU Node. - repeated Symptom symptoms = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Shielded Instance options. - ShieldedInstanceConfig shielded_instance_config = 45; -} - -// Request for [ListNodes][google.cloud.tpu.v2alpha1.Tpu.ListNodes]. -message ListNodesRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } - ]; - - // The maximum number of items to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; -} - -// Response for [ListNodes][google.cloud.tpu.v2alpha1.Tpu.ListNodes]. -message ListNodesResponse { - // The listed nodes. - repeated Node nodes = 1; - - // The next page token or empty if none. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for [GetNode][google.cloud.tpu.v2alpha1.Tpu.GetNode]. -message GetNodeRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } - ]; -} - -// Request for [CreateNode][google.cloud.tpu.v2alpha1.Tpu.CreateNode]. -message CreateNodeRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The unqualified resource name. - string node_id = 2; - - // Required. The node. - Node node = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for [DeleteNode][google.cloud.tpu.v2alpha1.Tpu.DeleteNode]. -message DeleteNodeRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } - ]; -} - -// Request for [StopNode][google.cloud.tpu.v2alpha1.Tpu.StopNode]. -message StopNodeRequest { - // The resource name. - string name = 1; -} - -// Request for [StartNode][google.cloud.tpu.v2alpha1.Tpu.StartNode]. -message StartNodeRequest { - // The resource name. - string name = 1; -} - -// Request for [UpdateNode][google.cloud.tpu.v2alpha1.Tpu.UpdateNode]. -message UpdateNodeRequest { - // Required. Mask of fields from [Node][Tpu.Node] to update. - // Supported fields: None. - google.protobuf.FieldMask update_mask = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The node. Only fields specified in update_mask are updated. - Node node = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The per-product per-project service identity for Cloud TPU service. -message ServiceIdentity { - // The email address of the service identity. - string email = 1; -} - -// Request for -// [GenerateServiceIdentity][google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity]. -message GenerateServiceIdentityRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; -} - -// Response for -// [GenerateServiceIdentity][google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity]. -message GenerateServiceIdentityResponse { - // ServiceIdentity that was created or retrieved. - ServiceIdentity identity = 1; -} - -// A accelerator type that a Node can be configured with. -message AcceleratorType { - option (google.api.resource) = { - type: "tpu.googleapis.com/AcceleratorType" - pattern: "projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}" - }; - - // The resource name. - string name = 1; - - // the accelerator type. - string type = 2; -} - -// Request for -// [GetAcceleratorType][google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType]. -message GetAcceleratorTypeRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/AcceleratorType" - } - ]; -} - -// Request for -// [ListAcceleratorTypes][google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes]. -message ListAcceleratorTypesRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/AcceleratorType" - } - ]; - - // The maximum number of items to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; - - // List filter. - string filter = 5; - - // Sort results. - string order_by = 6; -} - -// Response for -// [ListAcceleratorTypes][google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes]. -message ListAcceleratorTypesResponse { - // The listed nodes. - repeated AcceleratorType accelerator_types = 1; - - // The next page token or empty if none. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Note: the following OperationMetadata message was added manually. -// This is caused by a conflict with some other message and will -// be resolved separately. Please make sure to add this message back -// if it's removed during public proto regeneration. - -// Metadata describing an [Operation][google.longrunning.Operation] -message OperationMetadata { - // The time the operation was created. - google.protobuf.Timestamp create_time = 1; - - // The time the operation finished running. - google.protobuf.Timestamp end_time = 2; - - // Target of the operation - for example - // projects/project-1/connectivityTests/test-1 - string target = 3; - - // Name of the verb executed by the operation. - string verb = 4; - - // Human-readable status of the operation, if any. - string status_detail = 5; - - // Specifies if cancellation was requested for the operation. - bool cancel_requested = 6; - - // API version. - string api_version = 7; -} - -// A runtime version that a Node can be configured with. -message RuntimeVersion { - option (google.api.resource) = { - type: "tpu.googleapis.com/RuntimeVersion" - pattern: "projects/{project}/locations/{location}/runtimeVersions/{runtime_version}" - }; - - // The resource name. - string name = 1; - - // The runtime version. - string version = 2; -} - -// Request for -// [GetRuntimeVersion][google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion]. -message GetRuntimeVersionRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/RuntimeVersion" - } - ]; -} - -// Request for -// [ListRuntimeVersions][google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions]. -message ListRuntimeVersionsRequest { - // Required. The parent resource name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "tpu.googleapis.com/RuntimeVersion" - } - ]; - - // The maximum number of items to return. - int32 page_size = 2; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 3; - - // List filter. - string filter = 5; - - // Sort results. - string order_by = 6; -} - -// Response for -// [ListRuntimeVersions][google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions]. -message ListRuntimeVersionsResponse { - // The listed nodes. - repeated RuntimeVersion runtime_versions = 1; - - // The next page token or empty if none. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// A Symptom instance. -message Symptom { - // SymptomType represents the different types of Symptoms that a TPU can be - // at. - enum SymptomType { - // Unspecified symptom. - SYMPTOM_TYPE_UNSPECIFIED = 0; - - // TPU VM memory is low. - LOW_MEMORY = 1; - - // TPU runtime is out of memory. - OUT_OF_MEMORY = 2; - - // TPU runtime execution has timed out. - EXECUTE_TIMED_OUT = 3; - - // TPU runtime fails to construct a mesh that recognizes each TPU device's - // neighbors. - MESH_BUILD_FAIL = 4; - - // TPU HBM is out of memory. - HBM_OUT_OF_MEMORY = 5; - - // Abusive behaviors have been identified on the current project. - PROJECT_ABUSE = 6; - } - - // Timestamp when the Symptom is created. - google.protobuf.Timestamp create_time = 1; - - // Type of the Symptom. - SymptomType symptom_type = 2; - - // Detailed information of the current Symptom. - string details = 3; - - // A string used to uniquely distinguish a worker within a TPU node. - string worker_id = 4; -} - -// Request for -// [GetGuestAttributes][google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes]. -message GetGuestAttributesRequest { - // Required. The resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "tpu.googleapis.com/Node" } - ]; - - // The guest attributes path to be queried. - string query_path = 2; - - // The 0-based worker ID. If it is empty, all workers' GuestAttributes will be - // returned. - repeated string worker_ids = 3; -} - -// Response for -// [GetGuestAttributes][google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes]. -message GetGuestAttributesResponse { - // The guest attributes for the TPU workers. - repeated GuestAttributes guest_attributes = 1; -} - -// A set of Shielded Instance options. -message ShieldedInstanceConfig { - // Defines whether the instance has Secure Boot enabled. - bool enable_secure_boot = 1; -} \ No newline at end of file diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json deleted file mode 100644 index 251f9461801..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/snippet_metadata.google.cloud.tpu.v2alpha1.json +++ /dev/null @@ -1,595 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-tpu", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.tpu.v2alpha1", - "version": "v2alpha1" - } - ] - }, - "snippets": [ - { - "regionTag": "tpu_v2alpha1_generated_Tpu_ListNodes_async", - "title": "Tpu listNodes Sample", - "origin": "API_DEFINITION", - "description": " Lists nodes.", - "canonical": true, - "file": "tpu.list_nodes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListNodes", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListNodes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.ListNodesResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "ListNodes", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListNodes", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_GetNode_async", - "title": "Tpu getNode Sample", - "origin": "API_DEFINITION", - "description": " Gets the details of a node.", - "canonical": true, - "file": "tpu.get_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.Node", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "GetNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_CreateNode_async", - "title": "Tpu createNode Sample", - "origin": "API_DEFINITION", - "description": " Creates a node.", - "canonical": true, - "file": "tpu.create_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.CreateNode", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "node_id", - "type": "TYPE_STRING" - }, - { - "name": "node", - "type": ".google.cloud.tpu.v2alpha1.Node" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "CreateNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.CreateNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_DeleteNode_async", - "title": "Tpu deleteNode Sample", - "origin": "API_DEFINITION", - "description": " Deletes a node.", - "canonical": true, - "file": "tpu.delete_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.DeleteNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "DeleteNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.DeleteNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_StopNode_async", - "title": "Tpu stopNode Sample", - "origin": "API_DEFINITION", - "description": " Stops a node. This operation is only available with single TPU nodes.", - "canonical": true, - "file": "tpu.stop_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StopNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.StopNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "StopNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.StopNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_StartNode_async", - "title": "Tpu startNode Sample", - "origin": "API_DEFINITION", - "description": " Starts a node.", - "canonical": true, - "file": "tpu.start_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StartNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.StartNode", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "StartNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.StartNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_UpdateNode_async", - "title": "Tpu updateNode Sample", - "origin": "API_DEFINITION", - "description": " Updates the configurations of a node.", - "canonical": true, - "file": "tpu.update_node.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.UpdateNode", - "async": true, - "parameters": [ - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "node", - "type": ".google.cloud.tpu.v2alpha1.Node" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "UpdateNode", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.UpdateNode", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async", - "title": "Tpu generateServiceIdentity Sample", - "origin": "API_DEFINITION", - "description": " Generates the Cloud TPU service identity for the project.", - "canonical": true, - "file": "tpu.generate_service_identity.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GenerateServiceIdentity", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "GenerateServiceIdentity", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async", - "title": "Tpu listAcceleratorTypes Sample", - "origin": "API_DEFINITION", - "description": " Lists accelerator types supported by this API.", - "canonical": true, - "file": "tpu.list_accelerator_types.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListAcceleratorTypes", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.ListAcceleratorTypesResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "ListAcceleratorTypes", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async", - "title": "Tpu getAcceleratorType Sample", - "origin": "API_DEFINITION", - "description": " Gets AcceleratorType.", - "canonical": true, - "file": "tpu.get_accelerator_type.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAcceleratorType", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.AcceleratorType", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "GetAcceleratorType", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async", - "title": "Tpu listRuntimeVersions Sample", - "origin": "API_DEFINITION", - "description": " Lists runtime versions supported by this API.", - "canonical": true, - "file": "tpu.list_runtime_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRuntimeVersions", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.ListRuntimeVersionsResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "ListRuntimeVersions", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async", - "title": "Tpu getRuntimeVersion Sample", - "origin": "API_DEFINITION", - "description": " Gets a runtime version.", - "canonical": true, - "file": "tpu.get_runtime_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRuntimeVersion", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.RuntimeVersion", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "GetRuntimeVersion", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - }, - { - "regionTag": "tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async", - "title": "Tpu getGuestAttributes Sample", - "origin": "API_DEFINITION", - "description": " Retrieves the guest attributes for the node.", - "canonical": true, - "file": "tpu.get_guest_attributes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetGuestAttributes", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "query_path", - "type": "TYPE_STRING" - }, - { - "name": "worker_ids", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.cloud.tpu.v2alpha1.GetGuestAttributesResponse", - "client": { - "shortName": "TpuClient", - "fullName": "google.cloud.tpu.v2alpha1.TpuClient" - }, - "method": { - "shortName": "GetGuestAttributes", - "fullName": "google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes", - "service": { - "shortName": "Tpu", - "fullName": "google.cloud.tpu.v2alpha1.Tpu" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js deleted file mode 100644 index e99cae62be7..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.create_node.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, node) { - // [START tpu_v2alpha1_generated_Tpu_CreateNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The unqualified resource name. - */ - // const nodeId = 'abc123' - /** - * Required. The node. - */ - // const node = {} - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callCreateNode() { - // Construct request - const request = { - parent, - node, - }; - - // Run request - const [operation] = await tpuClient.createNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateNode(); - // [END tpu_v2alpha1_generated_Tpu_CreateNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js deleted file mode 100644 index c61789134fb..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.delete_node.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v2alpha1_generated_Tpu_DeleteNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callDeleteNode() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await tpuClient.deleteNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteNode(); - // [END tpu_v2alpha1_generated_Tpu_DeleteNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js deleted file mode 100644 index 6120c836015..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.generate_service_identity.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGenerateServiceIdentity() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await tpuClient.generateServiceIdentity(request); - console.log(response); - } - - callGenerateServiceIdentity(); - // [END tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js deleted file mode 100644 index c09ba898d76..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_accelerator_type.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetAcceleratorType() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getAcceleratorType(request); - console.log(response); - } - - callGetAcceleratorType(); - // [END tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js deleted file mode 100644 index e6b83bcafac..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_guest_attributes.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - /** - * The guest attributes path to be queried. - */ - // const queryPath = 'abc123' - /** - * The 0-based worker ID. If it is empty, all workers' GuestAttributes will be - * returned. - */ - // const workerIds = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetGuestAttributes() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getGuestAttributes(request); - console.log(response); - } - - callGetGuestAttributes(); - // [END tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js deleted file mode 100644 index ad9a1a2c833..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_node.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v2alpha1_generated_Tpu_GetNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetNode() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getNode(request); - console.log(response); - } - - callGetNode(); - // [END tpu_v2alpha1_generated_Tpu_GetNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js deleted file mode 100644 index 8b9a3ee8556..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.get_runtime_version.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callGetRuntimeVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await tpuClient.getRuntimeVersion(request); - console.log(response); - } - - callGetRuntimeVersion(); - // [END tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js deleted file mode 100644 index bbaeacf2d0d..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_accelerator_types.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * List filter. - */ - // const filter = 'abc123' - /** - * Sort results. - */ - // const orderBy = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callListAcceleratorTypes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await tpuClient.listAcceleratorTypesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListAcceleratorTypes(); - // [END tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js deleted file mode 100644 index 4a43bdcc192..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_nodes.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v2alpha1_generated_Tpu_ListNodes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callListNodes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await tpuClient.listNodesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListNodes(); - // [END tpu_v2alpha1_generated_Tpu_ListNodes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js deleted file mode 100644 index ba51c03858c..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.list_runtime_versions.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. - */ - // const parent = 'abc123' - /** - * The maximum number of items to return. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * List filter. - */ - // const filter = 'abc123' - /** - * Sort results. - */ - // const orderBy = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callListRuntimeVersions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await tpuClient.listRuntimeVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRuntimeVersions(); - // [END tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js deleted file mode 100644 index 047f5124c7b..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.start_node.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START tpu_v2alpha1_generated_Tpu_StartNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callStartNode() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await tpuClient.startNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStartNode(); - // [END tpu_v2alpha1_generated_Tpu_StartNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js deleted file mode 100644 index 21ceb97b54b..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.stop_node.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START tpu_v2alpha1_generated_Tpu_StopNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The resource name. - */ - // const name = 'abc123' - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callStopNode() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await tpuClient.stopNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callStopNode(); - // [END tpu_v2alpha1_generated_Tpu_StopNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js deleted file mode 100644 index 80769d98505..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/samples/generated/v2alpha1/tpu.update_node.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(updateMask, node) { - // [START tpu_v2alpha1_generated_Tpu_UpdateNode_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Mask of fields from Node Tpu.Node to update. - * Supported fields: None. - */ - // const updateMask = {} - /** - * Required. The node. Only fields specified in update_mask are updated. - */ - // const node = {} - - // Imports the Tpu library - const {TpuClient} = require('@google-cloud/tpu').v2alpha1; - - // Instantiates a client - const tpuClient = new TpuClient(); - - async function callUpdateNode() { - // Construct request - const request = { - updateMask, - node, - }; - - // Run request - const [operation] = await tpuClient.updateNode(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateNode(); - // [END tpu_v2alpha1_generated_Tpu_UpdateNode_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts deleted file mode 100644 index e00ff687292..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v2alpha1 from './v2alpha1'; -const TpuClient = v2alpha1.TpuClient; -type TpuClient = v2alpha1.TpuClient; -export {v2alpha1, TpuClient}; -export default {v2alpha1, TpuClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json deleted file mode 100644 index d4f743c1646..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/gapic_metadata.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.tpu.v2alpha1", - "libraryPackage": "@google-cloud/tpu", - "services": { - "Tpu": { - "clients": { - "grpc": { - "libraryClient": "TpuClient", - "rpcs": { - "GetNode": { - "methods": [ - "getNode" - ] - }, - "GenerateServiceIdentity": { - "methods": [ - "generateServiceIdentity" - ] - }, - "GetAcceleratorType": { - "methods": [ - "getAcceleratorType" - ] - }, - "GetRuntimeVersion": { - "methods": [ - "getRuntimeVersion" - ] - }, - "GetGuestAttributes": { - "methods": [ - "getGuestAttributes" - ] - }, - "CreateNode": { - "methods": [ - "createNode" - ] - }, - "DeleteNode": { - "methods": [ - "deleteNode" - ] - }, - "StopNode": { - "methods": [ - "stopNode" - ] - }, - "StartNode": { - "methods": [ - "startNode" - ] - }, - "UpdateNode": { - "methods": [ - "updateNode" - ] - }, - "ListNodes": { - "methods": [ - "listNodes", - "listNodesStream", - "listNodesAsync" - ] - }, - "ListAcceleratorTypes": { - "methods": [ - "listAcceleratorTypes", - "listAcceleratorTypesStream", - "listAcceleratorTypesAsync" - ] - }, - "ListRuntimeVersions": { - "methods": [ - "listRuntimeVersions", - "listRuntimeVersionsStream", - "listRuntimeVersionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TpuClient", - "rpcs": { - "GetNode": { - "methods": [ - "getNode" - ] - }, - "GenerateServiceIdentity": { - "methods": [ - "generateServiceIdentity" - ] - }, - "GetAcceleratorType": { - "methods": [ - "getAcceleratorType" - ] - }, - "GetRuntimeVersion": { - "methods": [ - "getRuntimeVersion" - ] - }, - "GetGuestAttributes": { - "methods": [ - "getGuestAttributes" - ] - }, - "CreateNode": { - "methods": [ - "createNode" - ] - }, - "DeleteNode": { - "methods": [ - "deleteNode" - ] - }, - "StopNode": { - "methods": [ - "stopNode" - ] - }, - "StartNode": { - "methods": [ - "startNode" - ] - }, - "UpdateNode": { - "methods": [ - "updateNode" - ] - }, - "ListNodes": { - "methods": [ - "listNodes", - "listNodesStream", - "listNodesAsync" - ] - }, - "ListAcceleratorTypes": { - "methods": [ - "listAcceleratorTypes", - "listAcceleratorTypesStream", - "listAcceleratorTypesAsync" - ] - }, - "ListRuntimeVersions": { - "methods": [ - "listRuntimeVersions", - "listRuntimeVersionsStream", - "listRuntimeVersionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts deleted file mode 100644 index 27c81814923..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {TpuClient} from './tpu_client'; diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts deleted file mode 100644 index 2a1a8bfbe34..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client.ts +++ /dev/null @@ -1,1955 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha1/tpu_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tpu_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Manages TPU nodes and other resources - * - * TPU API v2alpha1 - * @class - * @memberof v2alpha1 - */ -export class TpuClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tpuStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TpuClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new TpuClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof TpuClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - 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. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - acceleratorTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - nodePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/nodes/{node}' - ), - runtimeVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/runtimeVersions/{runtime_version}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listNodes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'nodes'), - listAcceleratorTypes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'acceleratorTypes'), - listRuntimeVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'runtimeVersions') - }; - - 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 lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*}',},{get: '/v2alpha1/{name=projects/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha1/{name=projects/*}/locations',additional_bindings: [{get: '/v1/{name=projects/*}/locations',},{get: '/v2alpha1/{name=projects/*}/locations',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha1/{name=projects/*/locations/*/operations/*}:cancel',additional_bindings: [{post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',},{post: '/v2alpha1/{name=projects/*/locations/*/operations/*}:cancel',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha1/{name=projects/*/locations/*/operations/*}',additional_bindings: [{delete: '/v1/{name=projects/*/locations/*/operations/*}',},{delete: '/v2alpha1/{name=projects/*/locations/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha1/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha1/{name=projects/*/locations/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha1/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v2alpha1/{name=projects/*/locations/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; - const createNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; - const deleteNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; - const deleteNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; - const stopNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; - const stopNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; - const startNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; - const startNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; - const updateNodeResponse = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.Node') as gax.protobuf.Type; - const updateNodeMetadata = protoFilesRoot.lookup( - '.google.cloud.tpu.v2alpha1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createNodeResponse.decode.bind(createNodeResponse), - createNodeMetadata.decode.bind(createNodeMetadata)), - deleteNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteNodeResponse.decode.bind(deleteNodeResponse), - deleteNodeMetadata.decode.bind(deleteNodeMetadata)), - stopNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - stopNodeResponse.decode.bind(stopNodeResponse), - stopNodeMetadata.decode.bind(stopNodeMetadata)), - startNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - startNodeResponse.decode.bind(startNodeResponse), - startNodeMetadata.decode.bind(startNodeMetadata)), - updateNode: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateNodeResponse.decode.bind(updateNodeResponse), - updateNodeMetadata.decode.bind(updateNodeMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.tpu.v2alpha1.Tpu', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.tpuStub) { - return this.tpuStub; - } - - // Put together the "service stub" for - // google.cloud.tpu.v2alpha1.Tpu. - this.tpuStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.tpu.v2alpha1.Tpu') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.tpu.v2alpha1.Tpu, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const tpuStubMethods = - ['listNodes', 'getNode', 'createNode', 'deleteNode', 'stopNode', 'startNode', 'updateNode', 'generateServiceIdentity', 'listAcceleratorTypes', 'getAcceleratorType', 'listRuntimeVersions', 'getRuntimeVersion', 'getGuestAttributes']; - for (const methodName of tpuStubMethods) { - const callPromise = this.tpuStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.tpuStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'tpu.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'tpu.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets the details of a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Node]{@link google.cloud.tpu.v2alpha1.Node}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.get_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_GetNode_async - */ - getNode( - request?: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.INode, - protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|undefined, {}|undefined - ]>; - getNode( - request: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.INode, - protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, - {}|null|undefined>): void; - getNode( - request: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.INode, - protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, - {}|null|undefined>): void; - getNode( - request?: protos.google.cloud.tpu.v2alpha1.IGetNodeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v2alpha1.INode, - protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v2alpha1.INode, - protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.INode, - protos.google.cloud.tpu.v2alpha1.IGetNodeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getNode(request, options, callback); - } -/** - * Generates the Cloud TPU service identity for the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GenerateServiceIdentityResponse]{@link google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.generate_service_identity.js - * region_tag:tpu_v2alpha1_generated_Tpu_GenerateServiceIdentity_async - */ - generateServiceIdentity( - request?: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|undefined, {}|undefined - ]>; - generateServiceIdentity( - request: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, - {}|null|undefined>): void; - generateServiceIdentity( - request: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, - {}|null|undefined>): void; - generateServiceIdentity( - request?: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse, - protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.generateServiceIdentity(request, options, callback); - } -/** - * Gets AcceleratorType. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.get_accelerator_type.js - * region_tag:tpu_v2alpha1_generated_Tpu_GetAcceleratorType_async - */ - getAcceleratorType( - request?: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IAcceleratorType, - protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|undefined, {}|undefined - ]>; - getAcceleratorType( - request: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IAcceleratorType, - protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>): void; - getAcceleratorType( - request: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IAcceleratorType, - protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>): void; - getAcceleratorType( - request?: protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v2alpha1.IAcceleratorType, - protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v2alpha1.IAcceleratorType, - protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IAcceleratorType, - protos.google.cloud.tpu.v2alpha1.IGetAcceleratorTypeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getAcceleratorType(request, options, callback); - } -/** - * Gets a runtime version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.get_runtime_version.js - * region_tag:tpu_v2alpha1_generated_Tpu_GetRuntimeVersion_async - */ - getRuntimeVersion( - request?: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, - protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|undefined, {}|undefined - ]>; - getRuntimeVersion( - request: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, - protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, - {}|null|undefined>): void; - getRuntimeVersion( - request: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, - protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, - {}|null|undefined>): void; - getRuntimeVersion( - request?: protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, - protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, - protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion, - protos.google.cloud.tpu.v2alpha1.IGetRuntimeVersionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getRuntimeVersion(request, options, callback); - } -/** - * Retrieves the guest attributes for the node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {string} request.queryPath - * The guest attributes path to be queried. - * @param {string[]} request.workerIds - * The 0-based worker ID. If it is empty, all workers' GuestAttributes will be - * returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GetGuestAttributesResponse]{@link google.cloud.tpu.v2alpha1.GetGuestAttributesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.get_guest_attributes.js - * region_tag:tpu_v2alpha1_generated_Tpu_GetGuestAttributes_async - */ - getGuestAttributes( - request?: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|undefined, {}|undefined - ]>; - getGuestAttributes( - request: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, - {}|null|undefined>): void; - getGuestAttributes( - request: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, - callback: Callback< - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, - {}|null|undefined>): void; - getGuestAttributes( - request?: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse, - protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getGuestAttributes(request, options, callback); - } - -/** - * Creates a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {string} request.nodeId - * The unqualified resource name. - * @param {google.cloud.tpu.v2alpha1.Node} request.node - * Required. The node. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.create_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_CreateNode_async - */ - createNode( - request?: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createNode( - request: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createNode( - request: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createNode( - request?: protos.google.cloud.tpu.v2alpha1.ICreateNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.create_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_CreateNode_async - */ - async checkCreateNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.delete_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_DeleteNode_async - */ - deleteNode( - request?: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteNode( - request: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteNode( - request: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteNode( - request?: protos.google.cloud.tpu.v2alpha1.IDeleteNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.delete_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_DeleteNode_async - */ - async checkDeleteNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Stops a node. This operation is only available with single TPU nodes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.stop_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_StopNode_async - */ - stopNode( - request?: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - stopNode( - request: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopNode( - request: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - stopNode( - request?: protos.google.cloud.tpu.v2alpha1.IStopNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.stopNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `stopNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.stop_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_StopNode_async - */ - async checkStopNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.stopNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.start_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_StartNode_async - */ - startNode( - request?: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - startNode( - request: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startNode( - request: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - startNode( - request?: protos.google.cloud.tpu.v2alpha1.IStartNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.startNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `startNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.start_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_StartNode_async - */ - async checkStartNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.startNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the configurations of a node. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields from {@link Tpu.Node|Node} to update. - * Supported fields: None. - * @param {google.cloud.tpu.v2alpha1.Node} request.node - * Required. The node. Only fields specified in update_mask are updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.update_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_UpdateNode_async - */ - updateNode( - request?: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateNode( - request: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateNode( - request: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateNode( - request?: protos.google.cloud.tpu.v2alpha1.IUpdateNodeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'node.name': request.node!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateNode(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateNode()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.update_node.js - * region_tag:tpu_v2alpha1_generated_Tpu_UpdateNode_async - */ - async checkUpdateNodeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateNode, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists nodes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Node]{@link google.cloud.tpu.v2alpha1.Node}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listNodesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listNodes( - request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.INode[], - protos.google.cloud.tpu.v2alpha1.IListNodesRequest|null, - protos.google.cloud.tpu.v2alpha1.IListNodesResponse - ]>; - listNodes( - request: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.INode>): void; - listNodes( - request: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - callback: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.INode>): void; - listNodes( - request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.INode>, - callback?: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - protos.google.cloud.tpu.v2alpha1.IListNodesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.INode>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.INode[], - protos.google.cloud.tpu.v2alpha1.IListNodesRequest|null, - protos.google.cloud.tpu.v2alpha1.IListNodesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listNodes(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Node]{@link google.cloud.tpu.v2alpha1.Node} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listNodesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listNodesStream( - request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listNodes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listNodes.createStream( - this.innerApiCalls.listNodes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listNodes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Node]{@link google.cloud.tpu.v2alpha1.Node}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.list_nodes.js - * region_tag:tpu_v2alpha1_generated_Tpu_ListNodes_async - */ - listNodesAsync( - request?: protos.google.cloud.tpu.v2alpha1.IListNodesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listNodes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listNodes.asyncIterate( - this.innerApiCalls['listNodes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists accelerator types supported by this API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAcceleratorTypesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listAcceleratorTypes( - request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IAcceleratorType[], - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest|null, - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse - ]>; - listAcceleratorTypes( - request: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IAcceleratorType>): void; - listAcceleratorTypes( - request: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - callback: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IAcceleratorType>): void; - listAcceleratorTypes( - request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IAcceleratorType>, - callback?: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IAcceleratorType>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IAcceleratorType[], - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest|null, - protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listAcceleratorTypes(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAcceleratorTypesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listAcceleratorTypesStream( - request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listAcceleratorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAcceleratorTypes.createStream( - this.innerApiCalls.listAcceleratorTypes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listAcceleratorTypes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [AcceleratorType]{@link google.cloud.tpu.v2alpha1.AcceleratorType}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.list_accelerator_types.js - * region_tag:tpu_v2alpha1_generated_Tpu_ListAcceleratorTypes_async - */ - listAcceleratorTypesAsync( - request?: protos.google.cloud.tpu.v2alpha1.IListAcceleratorTypesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listAcceleratorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listAcceleratorTypes.asyncIterate( - this.innerApiCalls['listAcceleratorTypes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists runtime versions supported by this API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRuntimeVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listRuntimeVersions( - request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[], - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest|null, - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse - ]>; - listRuntimeVersions( - request: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>): void; - listRuntimeVersions( - request: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>): void; - listRuntimeVersions( - request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>, - callback?: PaginationCallback< - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse|null|undefined, - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion>): - Promise<[ - protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[], - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest|null, - protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listRuntimeVersions(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRuntimeVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listRuntimeVersionsStream( - request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listRuntimeVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRuntimeVersions.createStream( - this.innerApiCalls.listRuntimeVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRuntimeVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. - * @param {number} request.pageSize - * The maximum number of items to return. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {string} request.filter - * List filter. - * @param {string} request.orderBy - * Sort results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [RuntimeVersion]{@link google.cloud.tpu.v2alpha1.RuntimeVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2alpha1/tpu.list_runtime_versions.js - * region_tag:tpu_v2alpha1_generated_Tpu_ListRuntimeVersions_async - */ - listRuntimeVersionsAsync( - request?: protos.google.cloud.tpu.v2alpha1.IListRuntimeVersionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listRuntimeVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRuntimeVersions.asyncIterate( - this.innerApiCalls['listRuntimeVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified acceleratorType resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} accelerator_type - * @returns {string} Resource name string. - */ - acceleratorTypePath(project:string,location:string,acceleratorType:string) { - return this.pathTemplates.acceleratorTypePathTemplate.render({ - project: project, - location: location, - accelerator_type: acceleratorType, - }); - } - - /** - * Parse the project from AcceleratorType resource. - * - * @param {string} acceleratorTypeName - * A fully-qualified path representing AcceleratorType resource. - * @returns {string} A string representing the project. - */ - matchProjectFromAcceleratorTypeName(acceleratorTypeName: string) { - return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).project; - } - - /** - * Parse the location from AcceleratorType resource. - * - * @param {string} acceleratorTypeName - * A fully-qualified path representing AcceleratorType resource. - * @returns {string} A string representing the location. - */ - matchLocationFromAcceleratorTypeName(acceleratorTypeName: string) { - return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).location; - } - - /** - * Parse the accelerator_type from AcceleratorType resource. - * - * @param {string} acceleratorTypeName - * A fully-qualified path representing AcceleratorType resource. - * @returns {string} A string representing the accelerator_type. - */ - matchAcceleratorTypeFromAcceleratorTypeName(acceleratorTypeName: string) { - return this.pathTemplates.acceleratorTypePathTemplate.match(acceleratorTypeName).accelerator_type; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified node resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} node - * @returns {string} Resource name string. - */ - nodePath(project:string,location:string,node:string) { - return this.pathTemplates.nodePathTemplate.render({ - project: project, - location: location, - node: node, - }); - } - - /** - * Parse the project from Node resource. - * - * @param {string} nodeName - * A fully-qualified path representing Node resource. - * @returns {string} A string representing the project. - */ - matchProjectFromNodeName(nodeName: string) { - return this.pathTemplates.nodePathTemplate.match(nodeName).project; - } - - /** - * Parse the location from Node resource. - * - * @param {string} nodeName - * A fully-qualified path representing Node resource. - * @returns {string} A string representing the location. - */ - matchLocationFromNodeName(nodeName: string) { - return this.pathTemplates.nodePathTemplate.match(nodeName).location; - } - - /** - * Parse the node from Node resource. - * - * @param {string} nodeName - * A fully-qualified path representing Node resource. - * @returns {string} A string representing the node. - */ - matchNodeFromNodeName(nodeName: string) { - return this.pathTemplates.nodePathTemplate.match(nodeName).node; - } - - /** - * Return a fully-qualified runtimeVersion resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} runtime_version - * @returns {string} Resource name string. - */ - runtimeVersionPath(project:string,location:string,runtimeVersion:string) { - return this.pathTemplates.runtimeVersionPathTemplate.render({ - project: project, - location: location, - runtime_version: runtimeVersion, - }); - } - - /** - * Parse the project from RuntimeVersion resource. - * - * @param {string} runtimeVersionName - * A fully-qualified path representing RuntimeVersion resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuntimeVersionName(runtimeVersionName: string) { - return this.pathTemplates.runtimeVersionPathTemplate.match(runtimeVersionName).project; - } - - /** - * Parse the location from RuntimeVersion resource. - * - * @param {string} runtimeVersionName - * A fully-qualified path representing RuntimeVersion resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuntimeVersionName(runtimeVersionName: string) { - return this.pathTemplates.runtimeVersionPathTemplate.match(runtimeVersionName).location; - } - - /** - * Parse the runtime_version from RuntimeVersion resource. - * - * @param {string} runtimeVersionName - * A fully-qualified path representing RuntimeVersion resource. - * @returns {string} A string representing the runtime_version. - */ - matchRuntimeVersionFromRuntimeVersionName(runtimeVersionName: string) { - return this.pathTemplates.runtimeVersionPathTemplate.match(runtimeVersionName).runtime_version; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.tpuStub && !this._terminated) { - return this.tpuStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json deleted file mode 100644 index d268f63d19d..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_client_config.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "interfaces": { - "google.cloud.tpu.v2alpha1.Tpu": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListNodes": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StopNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StartNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateNode": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GenerateServiceIdentity": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListAcceleratorTypes": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetAcceleratorType": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRuntimeVersions": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetRuntimeVersion": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetGuestAttributes": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json deleted file mode 100644 index 17217f28408..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/src/v2alpha1/tpu_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/tpu/v2alpha1/cloud_tpu.proto" -] diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 9cb87c17e68..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const tpu = require('@google-cloud/tpu'); - -function main() { - const tpuClient = new tpu.TpuClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 50ac473b84f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {TpuClient} from '@google-cloud/tpu'; - -// check that the client class type name can be used -function doStuffWithTpuClient(client: TpuClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const tpuClient = new TpuClient(); - doStuffWithTpuClient(tpuClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts b/owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts deleted file mode 100644 index 66fde4f2869..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/test/gapic_tpu_v2alpha1.ts +++ /dev/null @@ -1,2441 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as tpuModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha1.TpuClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = tpuModule.v2alpha1.TpuClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tpuModule.v2alpha1.TpuClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tpuModule.v2alpha1.TpuClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tpuModule.v2alpha1.TpuClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tpuModule.v2alpha1.TpuClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tpuStub, undefined); - await client.initialize(); - assert(client.tpuStub); - }); - - it('has close method for the initialized client', done => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tpuStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tpuStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getNode', () => { - it('invokes getNode without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.Node() - ); - client.innerApiCalls.getNode = stubSimpleCall(expectedResponse); - const [response] = await client.getNode(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.Node() - ); - client.innerApiCalls.getNode = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNode( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.INode|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getNode = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNode(request), expectedError); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode with closed client', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getNode(request), expectedError); - }); - }); - - describe('generateServiceIdentity', () => { - it('invokes generateServiceIdentity without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse() - ); - client.innerApiCalls.generateServiceIdentity = stubSimpleCall(expectedResponse); - const [response] = await client.generateServiceIdentity(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateServiceIdentity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateServiceIdentity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes generateServiceIdentity without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityResponse() - ); - client.innerApiCalls.generateServiceIdentity = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateServiceIdentity( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IGenerateServiceIdentityResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateServiceIdentity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateServiceIdentity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes generateServiceIdentity with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateServiceIdentity = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateServiceIdentity(request), expectedError); - const actualRequest = (client.innerApiCalls.generateServiceIdentity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateServiceIdentity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes generateServiceIdentity with closed client', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GenerateServiceIdentityRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.generateServiceIdentity(request), expectedError); - }); - }); - - describe('getAcceleratorType', () => { - it('invokes getAcceleratorType without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.AcceleratorType() - ); - client.innerApiCalls.getAcceleratorType = stubSimpleCall(expectedResponse); - const [response] = await client.getAcceleratorType(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAcceleratorType without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.AcceleratorType() - ); - client.innerApiCalls.getAcceleratorType = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAcceleratorType( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IAcceleratorType|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAcceleratorType with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAcceleratorType = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAcceleratorType(request), expectedError); - const actualRequest = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAcceleratorType as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAcceleratorType with closed client', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetAcceleratorTypeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAcceleratorType(request), expectedError); - }); - }); - - describe('getRuntimeVersion', () => { - it('invokes getRuntimeVersion without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.RuntimeVersion() - ); - client.innerApiCalls.getRuntimeVersion = stubSimpleCall(expectedResponse); - const [response] = await client.getRuntimeVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuntimeVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntimeVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntimeVersion without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.RuntimeVersion() - ); - client.innerApiCalls.getRuntimeVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRuntimeVersion( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuntimeVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntimeVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntimeVersion with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRuntimeVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRuntimeVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.getRuntimeVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuntimeVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuntimeVersion with closed client', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetRuntimeVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRuntimeVersion(request), expectedError); - }); - }); - - describe('getGuestAttributes', () => { - it('invokes getGuestAttributes without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesResponse() - ); - client.innerApiCalls.getGuestAttributes = stubSimpleCall(expectedResponse); - const [response] = await client.getGuestAttributes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getGuestAttributes without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesResponse() - ); - client.innerApiCalls.getGuestAttributes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getGuestAttributes( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IGetGuestAttributesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getGuestAttributes with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getGuestAttributes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getGuestAttributes(request), expectedError); - const actualRequest = (client.innerApiCalls.getGuestAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getGuestAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getGuestAttributes with closed client', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.GetGuestAttributesRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getGuestAttributes(request), expectedError); - }); - }); - - describe('createNode', () => { - it('invokes createNode without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.createNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNode without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNode with call error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createNode(request), expectedError); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNode with LRO error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.CreateNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.CreateNodeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateNodeProgress without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateNodeProgress with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteNode', () => { - it('invokes deleteNode without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNode without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNode with call error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteNode(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNode with LRO error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.DeleteNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.DeleteNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteNodeProgress without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteNodeProgress with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('stopNode', () => { - it('invokes stopNode without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.stopNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopNode without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.stopNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopNode with call error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.stopNode(request), expectedError); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopNode with LRO error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StopNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StopNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.stopNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStopNodeProgress without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStopNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStopNodeProgress with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStopNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('startNode', () => { - it('invokes startNode without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.startNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startNode without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startNode with call error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startNode(request), expectedError); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startNode with LRO error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.StartNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.StartNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.startNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkStartNodeProgress without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkStartNodeProgress with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateNode', () => { - it('invokes updateNode without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() - ); - request.node ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); - request.node.name = defaultValue1; - const expectedHeaderRequestParams = `node.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateNode = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateNode(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateNode without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() - ); - request.node ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); - request.node.name = defaultValue1; - const expectedHeaderRequestParams = `node.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateNode = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateNode( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateNode with call error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() - ); - request.node ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); - request.node.name = defaultValue1; - const expectedHeaderRequestParams = `node.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateNode = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateNode(request), expectedError); - const actualRequest = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateNode with LRO error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.UpdateNodeRequest() - ); - request.node ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.UpdateNodeRequest', ['node', 'name']); - request.node.name = defaultValue1; - const expectedHeaderRequestParams = `node.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateNode = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateNode(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateNodeProgress without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateNodeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateNodeProgress with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateNodeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listNodes', () => { - it('invokes listNodes without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - ]; - client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); - const [response] = await client.listNodes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodes without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - ]; - client.innerApiCalls.listNodes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNodes( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.INode[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodes with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNodes(request), expectedError); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodesStream without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - ]; - client.descriptors.page.listNodes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v2alpha1.Node[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.Node) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); - assert( - (client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listNodesStream with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listNodes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v2alpha1.Node[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.Node) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); - assert( - (client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNodes without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.Node()), - ]; - client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tpu.v2alpha1.INode[] = []; - const iterable = client.listNodesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNodes with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNodesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tpu.v2alpha1.INode[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listAcceleratorTypes', () => { - it('invokes listAcceleratorTypes without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - ]; - client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(expectedResponse); - const [response] = await client.listAcceleratorTypes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAcceleratorTypes without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - ]; - client.innerApiCalls.listAcceleratorTypes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAcceleratorTypes( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IAcceleratorType[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAcceleratorTypes with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAcceleratorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAcceleratorTypes(request), expectedError); - const actualRequest = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAcceleratorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAcceleratorTypesStream without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - ]; - client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAcceleratorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v2alpha1.AcceleratorType[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.AcceleratorType) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); - assert( - (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAcceleratorTypesStream with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAcceleratorTypes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAcceleratorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v2alpha1.AcceleratorType[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.AcceleratorType) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAcceleratorTypes, request)); - assert( - (client.descriptors.page.listAcceleratorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAcceleratorTypes without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.AcceleratorType()), - ]; - client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tpu.v2alpha1.IAcceleratorType[] = []; - const iterable = client.listAcceleratorTypesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAcceleratorTypes with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListAcceleratorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listAcceleratorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAcceleratorTypesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tpu.v2alpha1.IAcceleratorType[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAcceleratorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listRuntimeVersions', () => { - it('invokes listRuntimeVersions without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - ]; - client.innerApiCalls.listRuntimeVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listRuntimeVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuntimeVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimeVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimeVersions without error using callback', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - ]; - client.innerApiCalls.listRuntimeVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRuntimeVersions( - request, - (err?: Error|null, result?: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuntimeVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimeVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimeVersions with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRuntimeVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRuntimeVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listRuntimeVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuntimeVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuntimeVersionsStream without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - ]; - client.descriptors.page.listRuntimeVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRuntimeVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v2alpha1.RuntimeVersion[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.RuntimeVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRuntimeVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuntimeVersions, request)); - assert( - (client.descriptors.page.listRuntimeVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRuntimeVersionsStream with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuntimeVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRuntimeVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tpu.v2alpha1.RuntimeVersion[] = []; - stream.on('data', (response: protos.google.cloud.tpu.v2alpha1.RuntimeVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRuntimeVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuntimeVersions, request)); - assert( - (client.descriptors.page.listRuntimeVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuntimeVersions without error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - generateSampleMessage(new protos.google.cloud.tpu.v2alpha1.RuntimeVersion()), - ]; - client.descriptors.page.listRuntimeVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[] = []; - const iterable = client.listRuntimeVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuntimeVersions with error', async () => { - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tpu.v2alpha1.ListRuntimeVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuntimeVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRuntimeVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tpu.v2alpha1.IRuntimeVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuntimeVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('acceleratorType', () => { - const fakePath = "/rendered/path/acceleratorType"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - accelerator_type: "acceleratorTypeValue", - }; - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.acceleratorTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.acceleratorTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('acceleratorTypePath', () => { - const result = client.acceleratorTypePath("projectValue", "locationValue", "acceleratorTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.acceleratorTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAcceleratorTypeName', () => { - const result = client.matchProjectFromAcceleratorTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAcceleratorTypeName', () => { - const result = client.matchLocationFromAcceleratorTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAcceleratorTypeFromAcceleratorTypeName', () => { - const result = client.matchAcceleratorTypeFromAcceleratorTypeName(fakePath); - assert.strictEqual(result, "acceleratorTypeValue"); - assert((client.pathTemplates.acceleratorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('node', () => { - const fakePath = "/rendered/path/node"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - node: "nodeValue", - }; - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.nodePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.nodePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('nodePath', () => { - const result = client.nodePath("projectValue", "locationValue", "nodeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.nodePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNodeName', () => { - const result = client.matchProjectFromNodeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromNodeName', () => { - const result = client.matchLocationFromNodeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNodeFromNodeName', () => { - const result = client.matchNodeFromNodeName(fakePath); - assert.strictEqual(result, "nodeValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('runtimeVersion', () => { - const fakePath = "/rendered/path/runtimeVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - runtime_version: "runtimeVersionValue", - }; - const client = new tpuModule.v2alpha1.TpuClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.runtimeVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.runtimeVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('runtimeVersionPath', () => { - const result = client.runtimeVersionPath("projectValue", "locationValue", "runtimeVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.runtimeVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuntimeVersionName', () => { - const result = client.matchProjectFromRuntimeVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.runtimeVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuntimeVersionName', () => { - const result = client.matchLocationFromRuntimeVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.runtimeVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuntimeVersionFromRuntimeVersionName', () => { - const result = client.matchRuntimeVersionFromRuntimeVersionName(fakePath); - assert.strictEqual(result, "runtimeVersionValue"); - assert((client.pathTemplates.runtimeVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json b/owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js b/owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js deleted file mode 100644 index 8ee514d072f..00000000000 --- a/owl-bot-staging/google-cloud-tpu/v2alpha1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Tpu', - filename: './tpu.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/packages/google-cloud-tpu/protos/google/cloud/tpu/v1/cloud_tpu.proto b/packages/google-cloud-tpu/protos/google/cloud/tpu/v1/cloud_tpu.proto index 08e83550b1f..c2acf92f439 100644 --- a/packages/google-cloud-tpu/protos/google/cloud/tpu/v1/cloud_tpu.proto +++ b/packages/google-cloud-tpu/protos/google/cloud/tpu/v1/cloud_tpu.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ service Tpu { }; } - // Stops a node. + // Stops a node, this operation is only available with single TPU nodes. rpc StopNode(StopNodeRequest) returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1/{name=projects/*/locations/*/nodes/*}:stop" @@ -178,7 +178,7 @@ message Node { // TPU node is being created. CREATING = 1; - // TPU node has been created and is fully usable. + // TPU node has been created. READY = 2; // TPU node is restarting. @@ -550,11 +550,6 @@ message ListAcceleratorTypesResponse { repeated string unreachable = 3; } -// Note: the following OperationMetadata message was added manually. -// This is caused by a conflict with some other message and will -// be resolved separately. Please make sure to add this message back -// if it's removed during public proto regeneration. - // Metadata describing an [Operation][google.longrunning.Operation] message OperationMetadata { // The time the operation was created. diff --git a/packages/google-cloud-tpu/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json b/packages/google-cloud-tpu/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json index d2e128baac9..873d9de2217 100644 --- a/packages/google-cloud-tpu/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json +++ b/packages/google-cloud-tpu/samples/generated/v1/snippet_metadata.google.cloud.tpu.v1.json @@ -235,7 +235,7 @@ "regionTag": "tpu_v1_generated_Tpu_StopNode_async", "title": "Tpu stopNode Sample", "origin": "API_DEFINITION", - "description": " Stops a node.", + "description": " Stops a node, this operation is only available with single TPU nodes.", "canonical": true, "file": "tpu.stop_node.js", "language": "JAVASCRIPT", diff --git a/packages/google-cloud-tpu/src/v1/tpu_client.ts b/packages/google-cloud-tpu/src/v1/tpu_client.ts index 7086123dd39..36dec5dd088 100644 --- a/packages/google-cloud-tpu/src/v1/tpu_client.ts +++ b/packages/google-cloud-tpu/src/v1/tpu_client.ts @@ -27,6 +27,8 @@ import type { LROperation, PaginationCallback, GaxCall, + LocationsClient, + LocationProtos, } from 'google-gax'; import {Transform} from 'stream'; import * as protos from '../../protos/protos'; @@ -63,6 +65,7 @@ export class TpuClient { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; operationsClient: gax.OperationsClient; tpuStub?: Promise<{[name: string]: Function}>; @@ -157,6 +160,10 @@ export class TpuClient { if (servicePath === staticMembers.servicePath) { this.auth.defaultScopes = staticMembers.scopes; } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; @@ -1145,7 +1152,7 @@ export class TpuClient { >; } /** - * Stops a node. + * Stops a node, this operation is only available with single TPU nodes. * * @param {Object} request * The request object that will be sent. @@ -2007,6 +2014,263 @@ export class TpuClient { callSettings ) as AsyncIterable; } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + // -------------------- // -- Path templates -- // -------------------- @@ -2250,6 +2514,7 @@ export class TpuClient { return this.tpuStub.then(stub => { this._terminated = true; stub.close(); + this.locationsClient.close(); this.operationsClient.close(); }); } diff --git a/packages/google-cloud-tpu/test/gapic_tpu_v1.ts b/packages/google-cloud-tpu/test/gapic_tpu_v1.ts index 5c8d3ac4f7a..0e7f236f301 100644 --- a/packages/google-cloud-tpu/test/gapic_tpu_v1.ts +++ b/packages/google-cloud-tpu/test/gapic_tpu_v1.ts @@ -25,7 +25,12 @@ import * as tpuModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, LROperation, operationsProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -2540,6 +2545,509 @@ describe('v1.TpuClient', () => { ); }); }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new tpuModule.v1.TpuClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); describe('Path templates', () => { describe('acceleratorType', () => {