From e85f90eff62d430be6e12faa7999b588b17c4324 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 4 Jan 2023 02:02:04 +0000 Subject: [PATCH 1/2] feat: support secret and encrypted environment variables in v1 PiperOrigin-RevId: 499338464 Source-Link: https://github.com/googleapis/googleapis/commit/af050dcf9b72d192ef20b79149a6655a9afee870 Source-Link: https://github.com/googleapis/googleapis-gen/commit/413df7a1d735359d333c56e19f6af9c7f95957e4 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI0MTNkZjdhMWQ3MzUzNTlkMzMzYzU2ZTE5ZjZhZjljN2Y5NTk1N2U0In0= --- .../google-cloud-batch/v1/.eslintignore | 7 + .../google-cloud-batch/v1/.eslintrc.json | 3 + .../google-cloud-batch/v1/.gitignore | 14 + .../google-cloud-batch/v1/.jsdoc.js | 55 + .../google-cloud-batch/v1/.mocharc.js | 33 + .../google-cloud-batch/v1/.prettierrc.js | 22 + .../google-cloud-batch/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../google-cloud-batch/v1/package.json | 64 + .../protos/google/cloud/batch/v1/batch.proto | 273 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 475 ++++ .../protos/google/cloud/batch/v1/task.proto | 313 +++ .../protos/google/cloud/batch/v1/volume.proto | 76 + .../generated/v1/batch_service.create_job.js | 92 + .../generated/v1/batch_service.delete_job.js | 79 + .../generated/v1/batch_service.get_job.js | 61 + .../generated/v1/batch_service.get_task.js | 61 + .../generated/v1/batch_service.list_jobs.js | 74 + .../generated/v1/batch_service.list_tasks.js | 79 + ...nippet_metadata.google.cloud.batch.v1.json | 299 +++ .../google-cloud-batch/v1/src/index.ts | 25 + .../v1/src/v1/batch_service_client.ts | 1743 ++++++++++++++ .../src/v1/batch_service_client_config.json | 68 + .../v1/src/v1/batch_service_proto_list.json | 6 + .../v1/src/v1/gapic_metadata.json | 91 + .../google-cloud-batch/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_batch_service_v1.ts | 2111 +++++++++++++++++ .../google-cloud-batch/v1/tsconfig.json | 19 + .../google-cloud-batch/v1/webpack.config.js | 64 + .../google-cloud-batch/v1alpha/.eslintignore | 7 + .../google-cloud-batch/v1alpha/.eslintrc.json | 3 + .../google-cloud-batch/v1alpha/.gitignore | 14 + .../google-cloud-batch/v1alpha/.jsdoc.js | 55 + .../google-cloud-batch/v1alpha/.mocharc.js | 33 + .../google-cloud-batch/v1alpha/.prettierrc.js | 22 + .../google-cloud-batch/v1alpha/README.md | 1 + .../v1alpha/linkinator.config.json | 16 + .../google-cloud-batch/v1alpha/package.json | 64 + .../google/cloud/batch/v1alpha/batch.proto | 273 +++ .../google/cloud/batch/v1alpha/job.proto | 580 +++++ .../google/cloud/batch/v1alpha/task.proto | 321 +++ .../google/cloud/batch/v1alpha/volume.proto | 94 + .../v1alpha/batch_service.create_job.js | 92 + .../v1alpha/batch_service.delete_job.js | 79 + .../v1alpha/batch_service.get_job.js | 61 + .../v1alpha/batch_service.get_task.js | 61 + .../v1alpha/batch_service.list_jobs.js | 74 + .../v1alpha/batch_service.list_tasks.js | 79 + ...t_metadata.google.cloud.batch.v1alpha.json | 299 +++ .../google-cloud-batch/v1alpha/src/index.ts | 25 + .../src/v1alpha/batch_service_client.ts | 1743 ++++++++++++++ .../v1alpha/batch_service_client_config.json | 68 + .../src/v1alpha/batch_service_proto_list.json | 6 + .../v1alpha/src/v1alpha/gapic_metadata.json | 91 + .../v1alpha/src/v1alpha/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1alpha/system-test/install.ts | 49 + .../test/gapic_batch_service_v1alpha.ts | 2111 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12833 insertions(+) create mode 100644 owl-bot-staging/google-cloud-batch/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-batch/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-batch/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/README.md create mode 100644 owl-bot-staging/google-cloud-batch/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/package.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.delete_job.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_job.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_task.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_tasks.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-batch/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.eslintignore create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.gitignore create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/README.md create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/package.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/index.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/index.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/webpack.config.js diff --git a/owl-bot-staging/google-cloud-batch/v1/.eslintignore b/owl-bot-staging/google-cloud-batch/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-batch/v1/.eslintrc.json b/owl-bot-staging/google-cloud-batch/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-batch/v1/.gitignore b/owl-bot-staging/google-cloud-batch/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/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-batch/v1/.jsdoc.js b/owl-bot-staging/google-cloud-batch/v1/.jsdoc.js new file mode 100644 index 00000000000..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/batch', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-batch/v1/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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-batch/v1/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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-batch/v1/README.md b/owl-bot-staging/google-cloud-batch/v1/README.md new file mode 100644 index 00000000000..15b2fa3f3e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/README.md @@ -0,0 +1 @@ +Batch: Nodejs Client diff --git a/owl-bot-staging/google-cloud-batch/v1/linkinator.config.json b/owl-bot-staging/google-cloud-batch/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/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-batch/v1/package.json b/owl-bot-staging/google-cloud-batch/v1/package.json new file mode 100644 index 00000000000..ca54def4a50 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/batch", + "version": "0.1.0", + "description": "Batch client for Node.js", + "repository": "googleapis/nodejs-batch", + "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 batch", + "batch", + "batch service" + ], + "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-batch/v1/protos/google/cloud/batch/v1/batch.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto new file mode 100644 index 00000000000..1fa330088f6 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,273 @@ +// 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.batch.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/batch/v1/job.proto"; +import "google/cloud/batch/v1/task.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; +option java_multiple_files = true; +option java_outer_classname = "BatchProto"; +option java_package = "com.google.cloud.batch.v1"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1"; +option ruby_package = "Google::Cloud::Batch::V1"; + +// Google Batch Service. +// The service manages user submitted batch jobs and allocates Google Compute +// Engine VM instances to run the jobs. +service BatchService { + option (google.api.default_host) = "batch.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Create a Job. + rpc CreateJob(CreateJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/jobs" + body: "job" + }; + option (google.api.method_signature) = "parent,job,job_id"; + } + + // Get a Job specified by its resource name. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Delete a Job. + rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.batch.v1.OperationMetadata" + }; + } + + // List all Jobs for a project within a region. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Return a single Task. + rpc GetTask(GetTaskRequest) returns (Task) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/jobs/*/taskGroups/*/tasks/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List Tasks associated with a job. + rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/jobs/*/taskGroups/*}/tasks" + }; + option (google.api.method_signature) = "parent"; + } +} + +// CreateJob Request. +message CreateJobRequest { + // Required. The parent resource name where the Job will be created. + // Pattern: "projects/{project}/locations/{location}" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "batch.googleapis.com/Job" + } + ]; + + // ID used to uniquely identify the Job within its parent scope. + // This field should contain at most 63 characters and must start with + // lowercase characters. + // Only lowercase characters, numbers and '-' are accepted. + // The '-' character cannot be the first or the last one. + // A system generated ID will be used if the field is not set. + // + // The job.name field in the request will be ignored and the created resource + // name of the Job will be "{parent}/jobs/{job_id}". + string job_id = 2; + + // Required. The Job to create. + Job job = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional request ID to identify requests. Specify a unique request ID + // so that if you must retry your request, the server will know to ignore + // the request if it has already been completed. The server will guarantee + // that for at least 60 minutes since the first request. + // + // For example, consider a situation where you make an initial request and t + // he request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// GetJob Request. +message GetJobRequest { + // Required. Job name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "batch.googleapis.com/Job" + } + ]; +} + +// DeleteJob Request. +message DeleteJobRequest { + // Job name. + string name = 1; + + // Optional. Reason for this deletion. + string reason = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An optional request ID to identify requests. Specify a unique request ID + // so that if you must retry your request, the server will know to ignore + // the request if it has already been completed. The server will guarantee + // that for at least 60 minutes after the first request. + // + // For example, consider a situation where you make an initial request and t + // he request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// ListJob Request. +message ListJobsRequest { + // Parent path. + string parent = 1; + + // List filter. + string filter = 4; + + // Page size. + int32 page_size = 2; + + // Page token. + string page_token = 3; +} + +// ListJob Response. +message ListJobsResponse { + // Jobs. + repeated Job jobs = 1; + + // Next page token. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// ListTasks Request. +message ListTasksRequest { + // Required. Name of a TaskGroup from which Tasks are being requested. + // Pattern: + // "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "batch.googleapis.com/TaskGroup" + } + ]; + + // Task filter, null filter matches all Tasks. + // Filter string should be of the format State=TaskStatus.State e.g. + // State=RUNNING + string filter = 2; + + // Page size. + int32 page_size = 3; + + // Page token. + string page_token = 4; +} + +// ListTasks Response. +message ListTasksResponse { + // Tasks. + repeated Task tasks = 1; + + // Next page token. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for a single Task by name. +message GetTaskRequest { + // Required. Task name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "batch.googleapis.com/Task" + } + ]; +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // Output only. The time the operation was created. + google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the operation finished running. + google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server-defined resource path for the target of the operation. + string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the verb executed by the operation. + string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Human-readable status of the operation, if any. + string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. API version used to start the operation. + string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto new file mode 100644 index 00000000000..be86dbf8cad --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,475 @@ +// 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.batch.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/batch/v1/task.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.batch.v1"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1"; +option ruby_package = "Google::Cloud::Batch::V1"; + +// The Cloud Batch Job description. +message Job { + option (google.api.resource) = { + type: "batch.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + }; + + // Output only. Job name. + // For example: "projects/123456/locations/us-central1/jobs/job01". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system generated unique ID (in UUID4 format) for the Job. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Priority of the Job. + // The valid value range is [0, 100). + // A job with higher priority value is more likely to run earlier if all other + // requirements are satisfied. + int64 priority = 3; + + // Required. TaskGroups in the Job. Only one TaskGroup is supported now. + repeated TaskGroup task_groups = 4 [(google.api.field_behavior) = REQUIRED]; + + // Compute resource allocation for all TaskGroups in the Job. + AllocationPolicy allocation_policy = 7; + + // Labels for the Job. Labels could be user provided or system generated. + // For example, + // "labels": { + // "department": "finance", + // "environment": "test" + // } + // You can assign up to 64 labels. [Google Compute Engine label + // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) + // apply. + // Label names that start with "goog-" or "google-" are reserved. + map labels = 8; + + // Output only. Job status. It is read only for users. + JobStatus status = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. When the Job was created. + google.protobuf.Timestamp create_time = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last time the Job was updated. + google.protobuf.Timestamp update_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Log preservation policy for the Job. + LogsPolicy logs_policy = 13; + + // Notification configurations. + repeated JobNotification notifications = 14; +} + +// LogsPolicy describes how outputs from a Job's Tasks (stdout/stderr) will be +// preserved. +message LogsPolicy { + // The destination (if any) for logs. + enum Destination { + // Logs are not preserved. + DESTINATION_UNSPECIFIED = 0; + + // Logs are streamed to Cloud Logging. + CLOUD_LOGGING = 1; + + // Logs are saved to a file path. + PATH = 2; + } + + // Where logs should be saved. + Destination destination = 1; + + // The path to which logs are saved when the destination = PATH. This can be a + // local file path on the VM, or under the mount point of a Persistent Disk or + // Filestore, or a Cloud Storage path. + string logs_path = 2; +} + +// Job status. +message JobStatus { + // VM instance status. + message InstanceStatus { + // The Compute Engine machine type. + string machine_type = 1; + + // The VM instance provisioning model. + AllocationPolicy.ProvisioningModel provisioning_model = 2; + + // The max number of tasks can be assigned to this instance type. + int64 task_pack = 3; + } + + // Aggregated task status for a TaskGroup. + message TaskGroupStatus { + // Count of task in each state in the TaskGroup. + // The map key is task state name. + map counts = 1; + + // Status of instances allocated for the TaskGroup. + repeated InstanceStatus instances = 2; + } + + // Valid Job states. + enum State { + STATE_UNSPECIFIED = 0; + + // Job is admitted (validated and persisted) and waiting for resources. + QUEUED = 1; + + // Job is scheduled to run as soon as resource allocation is ready. + // The resource allocation may happen at a later time but with a high + // chance to succeed. + SCHEDULED = 2; + + // Resource allocation has been successful. At least one Task in the Job is + // RUNNING. + RUNNING = 3; + + // All Tasks in the Job have finished successfully. + SUCCEEDED = 4; + + // At least one Task in the Job has failed. + FAILED = 5; + + // The Job will be deleted, but has not been deleted yet. Typically this is + // because resources used by the Job are still being cleaned up. + DELETION_IN_PROGRESS = 6; + } + + // Job state + State state = 1; + + // Job status events + repeated StatusEvent status_events = 2; + + // Aggregated task status for each TaskGroup in the Job. + // The map key is TaskGroup ID. + map task_groups = 4; + + // The duration of time that the Job spent in status RUNNING. + google.protobuf.Duration run_duration = 5; +} + +// Notification configurations. +message JobNotification { + // Message details. + // Describe the attribute that a message should have. + // Without specified message attributes, no message will be sent by default. + message Message { + // The message type. + Type type = 1; + + // The new job state. + JobStatus.State new_job_state = 2; + + // The new task state. + TaskStatus.State new_task_state = 3; + } + + // The message type. + enum Type { + // Unspecified. + TYPE_UNSPECIFIED = 0; + + // Notify users that the job state has changed. + JOB_STATE_CHANGED = 1; + + // Notify users that the task state has changed. + TASK_STATE_CHANGED = 2; + } + + // The Pub/Sub topic where notifications like the job state changes + // will be published. This topic exist in the same project as the job + // and billings will be charged to this project. + // If not specified, no Pub/Sub messages will be sent. + // Topic format: `projects/{project}/topics/{topic}`. + string pubsub_topic = 1; + + // The attribute requirements of messages to be sent to this Pub/Sub topic. + // Without this field, no message will be sent. + Message message = 2; +} + +// A Job's resource allocation policy describes when, where, and how compute +// resources should be allocated for the Job. +message AllocationPolicy { + message LocationPolicy { + // A list of allowed location names represented by internal URLs. + // Each location can be a region or a zone. + // Only one region or multiple zones in one region is supported now. + // For example, + // ["regions/us-central1"] allow VMs in any zones in region us-central1. + // ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs + // in zones us-central1-a and us-central1-c. + // All locations end up in different regions would cause errors. + // For example, + // ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", + // "zones/us-west1-a"] contains 2 regions "us-central1" and + // "us-west1". An error is expected in this case. + repeated string allowed_locations = 1; + } + + // A new persistent disk or a local ssd. + // A VM can only have one local SSD setting but multiple local SSD partitions. + // https://cloud.google.com/compute/docs/disks#pdspecs. + // https://cloud.google.com/compute/docs/disks#localssds. + message Disk { + // A data source from which a PD will be created. + oneof data_source { + // Name of a public or custom image used as the data source. + string image = 4; + + // Name of a snapshot used as the data source. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list` + // For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd". + string type = 1; + + // Disk size in GB. + // This field is ignored if `data_source` is `disk` or `image`. + // If `type` is `local-ssd`, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + int64 size_gb = 2; + + // Local SSDs are available through both "SCSI" and "NVMe" interfaces. + // If not indicated, "NVMe" will be the default one for local ssds. + // We only support "SCSI" for persistent disks now. + string disk_interface = 6; + } + + // A new or an existing persistent disk (PD) or a local ssd attached to a VM + // instance. + message AttachedDisk { + oneof attached { + Disk new_disk = 1; + + // Name of an existing PD. + string existing_disk = 2; + } + + // Device name that the guest operating system will see. + // It is used by Runnable.volumes field to mount disks. So please specify + // the device_name if you want Batch to help mount the disk, and it should + // match the device_name field in volumes. + string device_name = 3; + } + + // Accelerator describes Compute Engine accelerators to be attached to the VM. + message Accelerator { + // The accelerator type. For example, "nvidia-tesla-t4". + // See `gcloud compute accelerator-types list`. + string type = 1; + + // The number of accelerators of this type. + int64 count = 2; + + // Deprecated: please use instances[0].install_gpu_drivers instead. + bool install_gpu_drivers = 3 [deprecated = true]; + } + + // InstancePolicy describes an instance type and resources attached to each VM + // created by this InstancePolicy. + message InstancePolicy { + // The Compute Engine machine type. + string machine_type = 2; + + // The minimum CPU platform. + // See + // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. + // Not yet implemented. + string min_cpu_platform = 3; + + // The provisioning model. + ProvisioningModel provisioning_model = 4; + + // The accelerators attached to each VM instance. + repeated Accelerator accelerators = 5; + + // Non-boot disks to be attached for each VM created by this InstancePolicy. + // New disks will be deleted when the VM is deleted. + repeated AttachedDisk disks = 6; + } + + // Either an InstancePolicy or an instance template. + message InstancePolicyOrTemplate { + oneof policy_template { + // InstancePolicy. + InstancePolicy policy = 1; + + // Name of an instance template used to create VMs. + // Named the field as 'instance_template' instead of 'template' to avoid + // c++ keyword conflict. + string instance_template = 2; + } + + // Set this field true if users want Batch to help fetch drivers from a + // third party location and install them for GPUs specified in + // policy.accelerators or instance_template on their behalf. Default is + // false. + bool install_gpu_drivers = 3; + } + + // A network interface. + message NetworkInterface { + // The URL of an existing network resource. + // You can specify the network as a full or partial URL. + // For example, the following are all valid URLs: + // https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} + // projects/{project}/global/networks/{network} + // global/networks/{network} + string network = 1; + + // The URL of an existing subnetwork resource in the network. + // You can specify the subnetwork as a full or partial URL. + // For example, the following are all valid URLs: + // https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork} + // projects/{project}/regions/{region}/subnetworks/{subnetwork} + // regions/{region}/subnetworks/{subnetwork} + string subnetwork = 2; + + // Default is false (with an external IP address). Required if + // no external public IP address is attached to the VM. If no external + // public IP address, additional configuration is required to allow the VM + // to access Google Services. See + // https://cloud.google.com/vpc/docs/configure-private-google-access and + // https://cloud.google.com/nat/docs/gce-example#create-nat for more + // information. + bool no_external_ip_address = 3; + } + + // NetworkPolicy describes VM instance network configurations. + message NetworkPolicy { + // Network configurations. + repeated NetworkInterface network_interfaces = 1; + } + + // Compute Engine VM instance provisioning model. + enum ProvisioningModel { + // Unspecified. + PROVISIONING_MODEL_UNSPECIFIED = 0; + + // Standard VM. + STANDARD = 1; + + // SPOT VM. + SPOT = 2; + + // Preemptible VM (PVM). + // + // Above SPOT VM is the preferable model for preemptible VM instances: the + // old preemptible VM model (indicated by this field) is the older model, + // and has been migrated to use the SPOT model as the underlying technology. + // This old model will still be supported. + PREEMPTIBLE = 3; + } + + // Location where compute resources should be allocated for the Job. + LocationPolicy location = 1; + + // Describe instances that can be created by this AllocationPolicy. + // Only instances[0] is supported now. + repeated InstancePolicyOrTemplate instances = 8; + + // Service account that VMs will run as. + ServiceAccount service_account = 9; + + // Labels applied to all VM instances and other resources + // created by AllocationPolicy. + // Labels could be user provided or system generated. + // You can assign up to 64 labels. [Google Compute Engine label + // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) + // apply. + // Label names that start with "goog-" or "google-" are reserved. + map labels = 6; + + // The network policy. + NetworkPolicy network = 7; +} + +// A TaskGroup contains one or multiple Tasks that share the same +// Runnable but with different runtime parameters. +message TaskGroup { + option (google.api.resource) = { + type: "batch.googleapis.com/TaskGroup" + pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + }; + + // Output only. TaskGroup name. + // The system generates this field based on parent Job name. + // For example: + // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Tasks in the group share the same task spec. + TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; + + // Number of Tasks in the TaskGroup. + // default is 1 + int64 task_count = 4; + + // Max number of tasks that can run in parallel. + // Default to min(task_count, 1000). + int64 parallelism = 5; + + // An array of environment variable mappings, which are passed to Tasks with + // matching indices. If task_environments is used then task_count should + // not be specified in the request (and will be ignored). Task count will be + // the length of task_environments. + // + // Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in + // addition to any environment variables set in task_environments, specifying + // the number of Tasks in the Task's parent TaskGroup, and the specific Task's + // index in the TaskGroup (0 through BATCH_TASK_COUNT - 1). + // + // task_environments supports up to 200 entries. + repeated Environment task_environments = 9; + + // Max number of tasks that can be run on a VM at the same time. + // If not specified, the system will decide a value based on available + // compute resources on a VM and task requirements. + int64 task_count_per_node = 10; + + // When true, Batch will populate a file with a list of all VMs assigned to + // the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path + // of that file. Defaults to false. + bool require_hosts_file = 11; + + // When true, Batch will configure SSH to allow passwordless login between + // VMs running the Batch tasks in the same TaskGroup. + bool permissive_ssh = 12; +} + +// Carries information about a Google Cloud service account. +message ServiceAccount { + // Email address of the service account. If not specified, the default + // Compute Engine service account for the project will be used. If instance + // template is being used, the service account has to be specified in the + // instance template and it has to match the email field here. + string email = 1; +} diff --git a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto new file mode 100644 index 00000000000..1085bfcb083 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,313 @@ +// 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.batch.v1; + +import "google/api/resource.proto"; +import "google/cloud/batch/v1/volume.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; +option java_multiple_files = true; +option java_outer_classname = "TaskProto"; +option java_package = "com.google.cloud.batch.v1"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1"; +option ruby_package = "Google::Cloud::Batch::V1"; + +// Compute resource requirements +message ComputeResource { + // The milliCPU count. + int64 cpu_milli = 1; + + // Memory in MiB. + int64 memory_mib = 2; + + // Extra boot disk size in MiB for each task. + int64 boot_disk_mib = 4; +} + +// Status event +message StatusEvent { + // Type of the event. + string type = 3; + + // Description of the event. + string description = 1; + + // The time this event occurred. + google.protobuf.Timestamp event_time = 2; + + // Task Execution + TaskExecution task_execution = 4; +} + +// This Task Execution field includes detail information for +// task execution procedures, based on StatusEvent types. +message TaskExecution { + // When task is completed as the status of FAILED or SUCCEEDED, + // exit code is for one task execution result, default is 0 as success. + int32 exit_code = 1; +} + +// Status of a task +message TaskStatus { + // Task states. + enum State { + // unknown state + STATE_UNSPECIFIED = 0; + + // The Task is created and waiting for resources. + PENDING = 1; + + // The Task is assigned to at least one VM. + ASSIGNED = 2; + + // The Task is running. + RUNNING = 3; + + // The Task has failed. + FAILED = 4; + + // The Task has succeeded. + SUCCEEDED = 5; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; +} + +// Runnable describes instructions for executing a specific script or container +// as part of a Task. +message Runnable { + // Container runnable. + message Container { + // The URI to pull the container image from. + string image_uri = 1; + + // Overrides the `CMD` specified in the container. If there is an ENTRYPOINT + // (either in the container image or with the entrypoint field below) then + // commands are appended as arguments to the ENTRYPOINT. + repeated string commands = 2; + + // Overrides the `ENTRYPOINT` specified in the container. + string entrypoint = 3; + + // Volumes to mount (bind mount) from the host machine files or directories + // into the container, formatted to match docker run's --volume option, + // e.g. /foo:/bar, or /foo:/bar:ro + repeated string volumes = 7; + + // Arbitrary additional options to include in the "docker run" command when + // running this container, e.g. "--network host". + string options = 8; + + // If set to true, external network access to and from container will be + // blocked. The container will use the default internal network + // 'goog-internal'. + bool block_external_network = 9; + + // Optional username for logging in to a docker registry. If username + // matches `projects/*/secrets/*/versions/*` then Batch will read the + // username from the Secret Manager. + string username = 10; + + // Optional password for logging in to a docker registry. If password + // matches `projects/*/secrets/*/versions/*` then Batch will read the + // password from the Secret Manager; + string password = 11; + } + + // Script runnable. + message Script { + oneof command { + // Script file path on the host VM. + string path = 1; + + // Shell script text. + string text = 2; + } + } + + // Barrier runnable blocks until all tasks in a taskgroup reach it. + message Barrier { + // Barriers are identified by their index in runnable list. + // Names are not required, but if present should be an identifier. + string name = 1; + } + + // The script or container to run. + oneof executable { + // Container runnable. + Container container = 1; + + // Script runnable. + Script script = 2; + + // Barrier runnable. + Barrier barrier = 6; + } + + // Normally, a non-zero exit status causes the Task to fail. This flag allows + // execution of other Runnables to continue instead. + bool ignore_exit_status = 3; + + // This flag allows a Runnable to continue running in the background while the + // Task executes subsequent Runnables. This is useful to provide services to + // other Runnables (or to provide debugging support tools like SSH servers). + bool background = 4; + + // By default, after a Runnable fails, no further Runnable are executed. This + // flag indicates that this Runnable must be run even if the Task has already + // failed. This is useful for Runnables that copy output files off of the VM + // or for debugging. + // + // The always_run flag does not override the Task's overall max_run_duration. + // If the max_run_duration has expired then no further Runnables will execute, + // not even always_run Runnables. + bool always_run = 5; + + // Environment variables for this Runnable (overrides variables set for the + // whole Task or TaskGroup). + Environment environment = 7; + + // Timeout for this Runnable. + google.protobuf.Duration timeout = 8; +} + +// Spec of a task +message TaskSpec { + // The sequence of scripts or containers to run for this Task. Each Task using + // this TaskSpec executes its list of runnables in order. The Task succeeds if + // all of its runnables either exit with a zero status or any that exit with a + // non-zero status have the ignore_exit_status flag. + // + // Background runnables are killed automatically (if they have not already + // exited) a short time after all foreground runnables have completed. Even + // though this is likely to result in a non-zero exit status for the + // background runnable, these automatic kills are not treated as Task + // failures. + repeated Runnable runnables = 8; + + // ComputeResource requirements. + ComputeResource compute_resource = 3; + + // Maximum duration the task should run. + // The task will be killed and marked as FAILED if over this limit. + google.protobuf.Duration max_run_duration = 4; + + // Maximum number of retries on failures. + // The default, 0, which means never retry. + // The valid value range is [0, 10]. + int32 max_retry_count = 5; + + // Lifecycle management schema when any task in a task group is failed. + // The valid size of lifecycle policies are [0, 10]. + // For each lifecycle policy, when the condition is met, + // the action in that policy will execute. + // If there are multiple policies that the task execution result matches, + // we use the action from the first matched policy. If task execution result + // does not meet with any of the defined lifecycle policy, we consider it as + // the default policy. Default policy means if the exit code is 0, exit task. + // If task ends with non-zero exit code, retry the task with max_retry_count. + repeated LifecyclePolicy lifecycle_policies = 9; + + // Deprecated: please use environment(non-plural) instead. + map environments = 6 [deprecated = true]; + + // Volumes to mount before running Tasks using this TaskSpec. + repeated Volume volumes = 7; + + // Environment variables to set before running the Task. + Environment environment = 10; +} + +// LifecyclePolicy describes how to deal with task failures +// based on different conditions. +message LifecyclePolicy { + // Conditions for actions to deal with task failures. + message ActionCondition { + // Exit codes of a task execution. + // If there are more than 1 exit codes, + // when task executes with any of the exit code in the list, + // the condition is met and the action will be executed. + repeated int32 exit_codes = 1; + } + + // Action on task failures based on different conditions. + enum Action { + // Action unspecified. + ACTION_UNSPECIFIED = 0; + + // Action that tasks in the group will be scheduled to re-execute. + RETRY_TASK = 1; + + // Action that tasks in the group will be stopped immediately. + FAIL_TASK = 2; + } + + // Action to execute when ActionCondition is true. + Action action = 1; + + // Conditions that decide why a task failure is dealt with a specific action. + ActionCondition action_condition = 2; +} + +// A Cloud Batch task. +message Task { + option (google.api.resource) = { + type: "batch.googleapis.com/Task" + pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}" + }; + + // Task name. + // The name is generated from the parent TaskGroup name and 'id' field. + // For example: + // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01/tasks/task01". + string name = 1; + + // Task Status. + TaskStatus status = 2; +} + +// An Environment describes a collection of environment variables to set when +// executing Tasks. +message Environment { + message KMSEnvMap { + // The name of the KMS key that will be used to decrypt the cipher text. + string key_name = 1; + + // The value of the cipherText response from the `encrypt` method. + string cipher_text = 2; + } + + // A map of environment variable names to values. + map variables = 1; + + // A map of environment variable names to Secret Manager secret names. + // The VM will access the named secrets to set the value of each environment + // variable. + map secret_variables = 2; + + // An encrypted JSON dictionary where the key/value pairs correspond to + // environment variable names and their values. + KMSEnvMap encrypted_variables = 3; +} diff --git a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto new file mode 100644 index 00000000000..7b6ebac48fb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// 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.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; +option java_multiple_files = true; +option java_outer_classname = "VolumeProto"; +option java_package = "com.google.cloud.batch.v1"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1"; +option ruby_package = "Google::Cloud::Batch::V1"; + +// Volume describes a volume and parameters for it to be mounted to a VM. +message Volume { + // The source for the volume. + oneof source { + // A Network File System (NFS) volume. For example, a + // Filestore file share. + NFS nfs = 1; + + // A Google Cloud Storage (GCS) volume. + GCS gcs = 3; + + // Device name of an attached disk volume, which should align with a + // device_name specified by + // job.allocation_policy.instances[0].policy.disks[i].device_name or + // defined by the given instance template in + // job.allocation_policy.instances[0].instance_template. + string device_name = 6; + } + + // The mount path for the volume, e.g. /mnt/disks/share. + string mount_path = 4; + + // For Google Cloud Storage (GCS), mount options are the options supported by + // the gcsfuse tool (https://github.com/GoogleCloudPlatform/gcsfuse). + // For existing persistent disks, mount options provided by the + // mount command (https://man7.org/linux/man-pages/man8/mount.8.html) except + // writing are supported. This is due to restrictions of multi-writer mode + // (https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms). + // For other attached disks and Network File System (NFS), mount options are + // these supported by the mount command + // (https://man7.org/linux/man-pages/man8/mount.8.html). + repeated string mount_options = 5; +} + +// Represents an NFS volume. +message NFS { + // The IP address of the NFS. + string server = 1; + + // Remote source path exported from the NFS, e.g., "/share". + string remote_path = 2; +} + +// Represents a Google Cloud Storage volume. +message GCS { + // Remote path, either a bucket name or a subdirectory of a bucket, e.g.: + // bucket_name, bucket_name/subdirectory/ + string remote_path = 1; +} diff --git a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js new file mode 100644 index 00000000000..4de994b2f73 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js @@ -0,0 +1,92 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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, job) { + // [START batch_v1_generated_BatchService_CreateJob_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 where the Job will be created. + * Pattern: "projects/{project}/locations/{location}" + */ + // const parent = 'abc123' + /** + * ID used to uniquely identify the Job within its parent scope. + * This field should contain at most 63 characters and must start with + * lowercase characters. + * Only lowercase characters, numbers and '-' are accepted. + * The '-' character cannot be the first or the last one. + * A system generated ID will be used if the field is not set. + * The job.name field in the request will be ignored and the created resource + * name of the Job will be "{parent}/jobs/{job_id}". + */ + // const jobId = 'abc123' + /** + * Required. The Job to create. + */ + // const job = {} + /** + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + }; + + // Run request + const response = await batchClient.createJob(request); + console.log(response); + } + + callCreateJob(); + // [END batch_v1_generated_BatchService_CreateJob_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-batch/v1/samples/generated/v1/batch_service.delete_job.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.delete_job.js new file mode 100644 index 00000000000..e19a6808169 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.delete_job.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batch_v1_generated_BatchService_DeleteJob_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. + */ + /** + * Job name. + */ + // const name = 'abc123' + /** + * Optional. Reason for this deletion. + */ + // const reason = 'abc123' + /** + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callDeleteJob() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await batchClient.deleteJob(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteJob(); + // [END batch_v1_generated_BatchService_DeleteJob_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-batch/v1/samples/generated/v1/batch_service.get_job.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_job.js new file mode 100644 index 00000000000..c45a5b7f46d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_job.js @@ -0,0 +1,61 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batch_v1_generated_BatchService_GetJob_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. Job name. + */ + // const name = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await batchClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END batch_v1_generated_BatchService_GetJob_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-batch/v1/samples/generated/v1/batch_service.get_task.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_task.js new file mode 100644 index 00000000000..12a0c45a2a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_task.js @@ -0,0 +1,61 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batch_v1_generated_BatchService_GetTask_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. Task name. + */ + // const name = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callGetTask() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await batchClient.getTask(request); + console.log(response); + } + + callGetTask(); + // [END batch_v1_generated_BatchService_GetTask_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-batch/v1/samples/generated/v1/batch_service.list_jobs.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_jobs.js new file mode 100644 index 00000000000..10807d04141 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_jobs.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batch_v1_generated_BatchService_ListJobs_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. + */ + /** + * Parent path. + */ + // const parent = 'abc123' + /** + * List filter. + */ + // const filter = 'abc123' + /** + * Page size. + */ + // const pageSize = 1234 + /** + * Page token. + */ + // const pageToken = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callListJobs() { + // Construct request + const request = { + }; + + // Run request + const iterable = await batchClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END batch_v1_generated_BatchService_ListJobs_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-batch/v1/samples/generated/v1/batch_service.list_tasks.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_tasks.js new file mode 100644 index 00000000000..2c53d7f22ce --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_tasks.js @@ -0,0 +1,79 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batch_v1_generated_BatchService_ListTasks_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. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + */ + // const parent = 'abc123' + /** + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + */ + // const filter = 'abc123' + /** + * Page size. + */ + // const pageSize = 1234 + /** + * Page token. + */ + // const pageToken = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callListTasks() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await batchClient.listTasksAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTasks(); + // [END batch_v1_generated_BatchService_ListTasks_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-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json new file mode 100644 index 00000000000..78e8ef02681 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json @@ -0,0 +1,299 @@ +{ + "clientLibrary": { + "name": "nodejs-batch", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.batch.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "batch_v1_generated_BatchService_CreateJob_async", + "title": "BatchService createJob Sample", + "origin": "API_DEFINITION", + "description": " Create a Job.", + "canonical": true, + "file": "batch_service.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 84, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.batch.v1.BatchService.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job_id", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.batch.v1.Job" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1.Job", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1.BatchServiceClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.batch.v1.BatchService.CreateJob", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1_generated_BatchService_GetJob_async", + "title": "BatchService getJob Sample", + "origin": "API_DEFINITION", + "description": " Get a Job specified by its resource name.", + "canonical": true, + "file": "batch_service.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.batch.v1.BatchService.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1.Job", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1.BatchServiceClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.batch.v1.BatchService.GetJob", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1_generated_BatchService_DeleteJob_async", + "title": "BatchService deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Delete a Job.", + "canonical": true, + "file": "batch_service.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.batch.v1.BatchService.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "reason", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1.BatchServiceClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.batch.v1.BatchService.DeleteJob", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1_generated_BatchService_ListJobs_async", + "title": "BatchService listJobs Sample", + "origin": "API_DEFINITION", + "description": " List all Jobs for a project within a region.", + "canonical": true, + "file": "batch_service.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.batch.v1.BatchService.ListJobs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1.ListJobsResponse", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1.BatchServiceClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.batch.v1.BatchService.ListJobs", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1_generated_BatchService_GetTask_async", + "title": "BatchService getTask Sample", + "origin": "API_DEFINITION", + "description": " Return a single Task.", + "canonical": true, + "file": "batch_service.get_task.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTask", + "fullName": "google.cloud.batch.v1.BatchService.GetTask", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1.Task", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1.BatchServiceClient" + }, + "method": { + "shortName": "GetTask", + "fullName": "google.cloud.batch.v1.BatchService.GetTask", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1_generated_BatchService_ListTasks_async", + "title": "BatchService listTasks Sample", + "origin": "API_DEFINITION", + "description": " List Tasks associated with a job.", + "canonical": true, + "file": "batch_service.list_tasks.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTasks", + "fullName": "google.cloud.batch.v1.BatchService.ListTasks", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1.ListTasksResponse", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1.BatchServiceClient" + }, + "method": { + "shortName": "ListTasks", + "fullName": "google.cloud.batch.v1.BatchService.ListTasks", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1.BatchService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/index.ts b/owl-bot-staging/google-cloud-batch/v1/src/index.ts new file mode 100644 index 00000000000..1026aa0e2b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 BatchServiceClient = v1.BatchServiceClient; +type BatchServiceClient = v1.BatchServiceClient; +export {v1, BatchServiceClient}; +export default {v1, BatchServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts new file mode 100644 index 00000000000..64e8c3f492a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1743 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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, IamClient, IamProtos, 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/batch_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './batch_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Google Batch Service. + * The service manages user submitted batch jobs and allocates Google Compute + * Engine VM instances to run the jobs. + * @class + * @memberof v1 + */ +export class BatchServiceClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + batchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of BatchServiceClient. + * + * @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 BatchServiceClient({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 BatchServiceClient; + 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 = { + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}' + ), + taskGroupPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}' + ), + }; + + // 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 = { + listJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs'), + listTasks: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') + }; + + 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.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/jobs/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/jobs/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/jobs/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{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 deleteJobResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteJobMetadata = protoFilesRoot.lookup( + '.google.cloud.batch.v1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + deleteJob: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteJobResponse.decode.bind(deleteJobResponse), + deleteJobMetadata.decode.bind(deleteJobMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.batch.v1.BatchService', 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.batchServiceStub) { + return this.batchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.batch.v1.BatchService. + this.batchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.batch.v1.BatchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.batch.v1.BatchService, + 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 batchServiceStubMethods = + ['createJob', 'getJob', 'deleteJob', 'listJobs', 'getTask', 'listTasks']; + for (const methodName of batchServiceStubMethods) { + const callPromise = this.batchServiceStub.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.batchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'batch.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 'batch.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 -- + // ------------------- +/** + * Create a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name where the Job will be created. + * Pattern: "projects/{project}/locations/{location}" + * @param {string} request.jobId + * ID used to uniquely identify the Job within its parent scope. + * This field should contain at most 63 characters and must start with + * lowercase characters. + * Only lowercase characters, numbers and '-' are accepted. + * The '-' character cannot be the first or the last one. + * A system generated ID will be used if the field is not set. + * + * The job.name field in the request will be ignored and the created resource + * name of the Job will be "{parent}/jobs/{job_id}". + * @param {google.cloud.batch.v1.Job} request.job + * Required. The Job to create. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 [Job]{@link google.cloud.batch.v1.Job}. + * 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/batch_service.create_job.js + * region_tag:batch_v1_generated_BatchService_CreateJob_async + */ + createJob( + request?: protos.google.cloud.batch.v1.ICreateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.ICreateJobRequest|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.batch.v1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.batch.v1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.batch.v1.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.ICreateJobRequest|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.createJob(request, options, callback); + } +/** + * Get a Job specified by its resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Job 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 [Job]{@link google.cloud.batch.v1.Job}. + * 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/batch_service.get_job.js + * region_tag:batch_v1_generated_BatchService_GetJob_async + */ + getJob( + request?: protos.google.cloud.batch.v1.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.batch.v1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.batch.v1.IGetJobRequest, + callback: Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.batch.v1.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.batch.v1.IJob, + protos.google.cloud.batch.v1.IGetJobRequest|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.getJob(request, options, callback); + } +/** + * Return a single Task. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Task 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 [Task]{@link google.cloud.batch.v1.Task}. + * 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/batch_service.get_task.js + * region_tag:batch_v1_generated_BatchService_GetTask_async + */ + getTask( + request?: protos.google.cloud.batch.v1.IGetTaskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1.ITask, + protos.google.cloud.batch.v1.IGetTaskRequest|undefined, {}|undefined + ]>; + getTask( + request: protos.google.cloud.batch.v1.IGetTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.batch.v1.ITask, + protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, + {}|null|undefined>): void; + getTask( + request: protos.google.cloud.batch.v1.IGetTaskRequest, + callback: Callback< + protos.google.cloud.batch.v1.ITask, + protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, + {}|null|undefined>): void; + getTask( + request?: protos.google.cloud.batch.v1.IGetTaskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.batch.v1.ITask, + protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.batch.v1.ITask, + protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.batch.v1.ITask, + protos.google.cloud.batch.v1.IGetTaskRequest|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.getTask(request, options, callback); + } + +/** + * Delete a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Job name. + * @param {string} [request.reason] + * Optional. Reason for this deletion. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/batch_service.delete_job.js + * region_tag:batch_v1_generated_BatchService_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.batch.v1.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.batch.v1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.batch.v1.IDeleteJobRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.batch.v1.IDeleteJobRequest, + 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.deleteJob(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteJob()`. + * @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/batch_service.delete_job.js + * region_tag:batch_v1_generated_BatchService_DeleteJob_async + */ + async checkDeleteJobProgress(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.deleteJob, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List all Jobs for a project within a region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Parent path. + * @param {string} request.filter + * List filter. + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Job]{@link google.cloud.batch.v1.Job}. + * 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 `listJobsAsync()` + * 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. + */ + listJobs( + request?: protos.google.cloud.batch.v1.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1.IJob[], + protos.google.cloud.batch.v1.IListJobsRequest|null, + protos.google.cloud.batch.v1.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.batch.v1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.batch.v1.IListJobsRequest, + protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1.IJob>): void; + listJobs( + request: protos.google.cloud.batch.v1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.batch.v1.IListJobsRequest, + protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1.IJob>): void; + listJobs( + request?: protos.google.cloud.batch.v1.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.batch.v1.IListJobsRequest, + protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1.IJob>, + callback?: PaginationCallback< + protos.google.cloud.batch.v1.IListJobsRequest, + protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1.IJob>): + Promise<[ + protos.google.cloud.batch.v1.IJob[], + protos.google.cloud.batch.v1.IListJobsRequest|null, + protos.google.cloud.batch.v1.IListJobsResponse + ]>|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.listJobs(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 + * Parent path. + * @param {string} request.filter + * List filter. + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Job]{@link google.cloud.batch.v1.Job} 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 `listJobsAsync()` + * 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. + */ + listJobsStream( + request?: protos.google.cloud.batch.v1.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.createStream( + this.innerApiCalls.listJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listJobs`, 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 + * Parent path. + * @param {string} request.filter + * List filter. + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * 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 + * [Job]{@link google.cloud.batch.v1.Job}. 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/batch_service.list_jobs.js + * region_tag:batch_v1_generated_BatchService_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.batch.v1.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.asyncIterate( + this.innerApiCalls['listJobs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List Tasks associated with a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @param {string} request.filter + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Task]{@link google.cloud.batch.v1.Task}. + * 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 `listTasksAsync()` + * 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. + */ + listTasks( + request?: protos.google.cloud.batch.v1.IListTasksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1.ITask[], + protos.google.cloud.batch.v1.IListTasksRequest|null, + protos.google.cloud.batch.v1.IListTasksResponse + ]>; + listTasks( + request: protos.google.cloud.batch.v1.IListTasksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.batch.v1.IListTasksRequest, + protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1.ITask>): void; + listTasks( + request: protos.google.cloud.batch.v1.IListTasksRequest, + callback: PaginationCallback< + protos.google.cloud.batch.v1.IListTasksRequest, + protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1.ITask>): void; + listTasks( + request?: protos.google.cloud.batch.v1.IListTasksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.batch.v1.IListTasksRequest, + protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1.ITask>, + callback?: PaginationCallback< + protos.google.cloud.batch.v1.IListTasksRequest, + protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1.ITask>): + Promise<[ + protos.google.cloud.batch.v1.ITask[], + protos.google.cloud.batch.v1.IListTasksRequest|null, + protos.google.cloud.batch.v1.IListTasksResponse + ]>|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.listTasks(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. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @param {string} request.filter + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Task]{@link google.cloud.batch.v1.Task} 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 `listTasksAsync()` + * 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. + */ + listTasksStream( + request?: protos.google.cloud.batch.v1.IListTasksRequest, + 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['listTasks']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTasks.createStream( + this.innerApiCalls.listTasks as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTasks`, 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. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @param {string} request.filter + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * 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 + * [Task]{@link google.cloud.batch.v1.Task}. 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/batch_service.list_tasks.js + * region_tag:batch_v1_generated_BatchService_ListTasks_async + */ + listTasksAsync( + request?: protos.google.cloud.batch.v1.IListTasksRequest, + 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['listTasks']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTasks.asyncIterate( + this.innerApiCalls['listTasks'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions} + * @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/interfaces/CallOptions.html} 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 [Policy]{@link google.iam.v1.Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise { + return this.iamClient.testIamPermissions(request, options, callback); + } + +/** + * 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 job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 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 task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} task_group + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,taskGroup:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + task_group: taskGroup, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the task_group from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task_group. + */ + matchTaskGroupFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task_group; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * Return a fully-qualified taskGroup resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} task_group + * @returns {string} Resource name string. + */ + taskGroupPath(project:string,location:string,job:string,taskGroup:string) { + return this.pathTemplates.taskGroupPathTemplate.render({ + project: project, + location: location, + job: job, + task_group: taskGroup, + }); + } + + /** + * Parse the project from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).project; + } + + /** + * Parse the location from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).location; + } + + /** + * Parse the job from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).job; + } + + /** + * Parse the task_group from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the task_group. + */ + matchTaskGroupFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).task_group; + } + + /** + * 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.batchServiceStub && !this._terminated) { + return this.batchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json new file mode 100644 index 00000000000..be602f6e2eb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json @@ -0,0 +1,68 @@ +{ + "interfaces": { + "google.cloud.batch.v1.BatchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateJob": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteJob": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListJobs": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetTask": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListTasks": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json new file mode 100644 index 00000000000..d9013a506a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/batch/v1/batch.proto", + "../../protos/google/cloud/batch/v1/job.proto", + "../../protos/google/cloud/batch/v1/task.proto", + "../../protos/google/cloud/batch/v1/volume.proto" +] diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..914e910ca19 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json @@ -0,0 +1,91 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.batch.v1", + "libraryPackage": "@google-cloud/batch", + "services": { + "BatchService": { + "clients": { + "grpc": { + "libraryClient": "BatchServiceClient", + "rpcs": { + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "GetJob": { + "methods": [ + "getJob" + ] + }, + "GetTask": { + "methods": [ + "getTask" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + }, + "ListTasks": { + "methods": [ + "listTasks", + "listTasksStream", + "listTasksAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "BatchServiceClient", + "rpcs": { + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "GetJob": { + "methods": [ + "getJob" + ] + }, + "GetTask": { + "methods": [ + "getTask" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + }, + "ListTasks": { + "methods": [ + "listTasks", + "listTasksStream", + "listTasksAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts new file mode 100644 index 00000000000..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 {BatchServiceClient} from './batch_service_client'; diff --git a/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batch = require('@google-cloud/batch'); + +function main() { + const batchServiceClient = new batch.BatchServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 {BatchServiceClient} from '@google-cloud/batch'; + +// check that the client class type name can be used +function doStuffWithBatchServiceClient(client: BatchServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const batchServiceClient = new BatchServiceClient(); + doStuffWithBatchServiceClient(batchServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-batch/v1/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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-batch/v1/test/gapic_batch_service_v1.ts b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts new file mode 100644 index 00000000000..c2d04b16459 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,2111 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// 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 batchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, 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.BatchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = batchserviceModule.v1.BatchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = batchserviceModule.v1.BatchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = batchserviceModule.v1.BatchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new batchserviceModule.v1.BatchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.batchServiceStub, undefined); + await client.initialize(); + assert(client.batchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.batchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.batchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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('createJob', () => { + it('invokes createJob without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with closed client', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createJob(request), expectedError); + }); + }); + + describe('getJob', () => { + it('invokes getJob without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with closed client', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('getTask', () => { + it('invokes getTask without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1.Task() + ); + client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); + const [response] = await client.getTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1.Task() + ); + client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTask( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1.ITask|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTask(request), expectedError); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask with closed client', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTask(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteJob = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + 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.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with call error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with LRO error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteJobProgress without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + 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.checkDeleteJobProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteJobProgress with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + 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.checkDeleteJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1.IJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobsStream without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listJobsStream with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1.Job) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.batch.v1.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.batch.v1.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listTasks', () => { + it('invokes listTasks without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); + const [response] = await client.listTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasks without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTasks( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1.ITask[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasks with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTasks(request), expectedError); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasksStream without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + ]; + client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1.Task[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1.Task) => { + 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.listTasks.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listTasksStream with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1.Task[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1.Task) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTasks without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1.Task()), + ]; + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.batch.v1.ITask[] = []; + const iterable = client.listTasksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTasks with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTasksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.batch.v1.ITask[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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 batchserviceModule.v1.BatchServiceClient({ + 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('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new batchserviceModule.v1.BatchServiceClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new batchserviceModule.v1.BatchServiceClient({ + 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('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + task_group: "taskGroupValue", + task: "taskValue", + }; + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "taskGroupValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskGroupFromTaskName', () => { + const result = client.matchTaskGroupFromTaskName(fakePath); + assert.strictEqual(result, "taskGroupValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('taskGroup', () => { + const fakePath = "/rendered/path/taskGroup"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + task_group: "taskGroupValue", + }; + const client = new batchserviceModule.v1.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskGroupPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskGroupPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskGroupPath', () => { + const result = client.taskGroupPath("projectValue", "locationValue", "jobValue", "taskGroupValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskGroupPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskGroupName', () => { + const result = client.matchProjectFromTaskGroupName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskGroupName', () => { + const result = client.matchLocationFromTaskGroupName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskGroupName', () => { + const result = client.matchJobFromTaskGroupName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskGroupFromTaskGroupName', () => { + const result = client.matchTaskGroupFromTaskGroupName(fakePath); + assert.strictEqual(result, "taskGroupValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-batch/v1/tsconfig.json b/owl-bot-staging/google-cloud-batch/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/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-batch/v1/webpack.config.js b/owl-bot-staging/google-cloud-batch/v1/webpack.config.js new file mode 100644 index 00000000000..04a4c53960a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/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: 'BatchService', + filename: './batch-service.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-batch/v1alpha/.eslintignore b/owl-bot-staging/google-cloud-batch/v1alpha/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json b/owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/.gitignore b/owl-bot-staging/google-cloud-batch/v1alpha/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/.jsdoc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.jsdoc.js new file mode 100644 index 00000000000..b3e5d7c63ae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/batch', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/README.md b/owl-bot-staging/google-cloud-batch/v1alpha/README.md new file mode 100644 index 00000000000..15b2fa3f3e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/README.md @@ -0,0 +1 @@ +Batch: Nodejs Client diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/linkinator.config.json b/owl-bot-staging/google-cloud-batch/v1alpha/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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-batch/v1alpha/package.json b/owl-bot-staging/google-cloud-batch/v1alpha/package.json new file mode 100644 index 00000000000..ca54def4a50 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/batch", + "version": "0.1.0", + "description": "Batch client for Node.js", + "repository": "googleapis/nodejs-batch", + "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 batch", + "batch", + "batch service" + ], + "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-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto new file mode 100644 index 00000000000..cc6dd16a536 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,273 @@ +// 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.batch.v1alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/batch/v1alpha/job.proto"; +import "google/cloud/batch/v1alpha/task.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; +option java_multiple_files = true; +option java_outer_classname = "BatchProto"; +option java_package = "com.google.cloud.batch.v1alpha"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; +option ruby_package = "Google::Cloud::Batch::V1alpha"; + +// Google Batch Service. +// The service manages user submitted batch jobs and allocates Google Compute +// Engine VM instances to run the jobs. +service BatchService { + option (google.api.default_host) = "batch.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Create a Job. + rpc CreateJob(CreateJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1alpha/{parent=projects/*/locations/*}/jobs" + body: "job" + }; + option (google.api.method_signature) = "parent,job,job_id"; + } + + // Get a Job specified by its resource name. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Delete a Job. + rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1alpha/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.batch.v1alpha.OperationMetadata" + }; + } + + // List all Jobs for a project within a region. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Return a single Task. + rpc GetTask(GetTaskRequest) returns (Task) { + option (google.api.http) = { + get: "/v1alpha/{name=projects/*/locations/*/jobs/*/taskGroups/*/tasks/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List Tasks associated with a job. + rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { + option (google.api.http) = { + get: "/v1alpha/{parent=projects/*/locations/*/jobs/*/taskGroups/*}/tasks" + }; + option (google.api.method_signature) = "parent"; + } +} + +// CreateJob Request. +message CreateJobRequest { + // Required. The parent resource name where the Job will be created. + // Pattern: "projects/{project}/locations/{location}" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "batch.googleapis.com/Job" + } + ]; + + // ID used to uniquely identify the Job within its parent scope. + // This field should contain at most 63 characters and must start with + // lowercase characters. + // Only lowercase characters, numbers and '-' are accepted. + // The '-' character cannot be the first or the last one. + // A system generated ID will be used if the field is not set. + // + // The job.name field in the request will be ignored and the created resource + // name of the Job will be "{parent}/jobs/{job_id}". + string job_id = 2; + + // Required. The Job to create. + Job job = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional request ID to identify requests. Specify a unique request ID + // so that if you must retry your request, the server will know to ignore + // the request if it has already been completed. The server will guarantee + // that for at least 60 minutes since the first request. + // + // For example, consider a situation where you make an initial request and t + // he request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// GetJob Request. +message GetJobRequest { + // Required. Job name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "batch.googleapis.com/Job" + } + ]; +} + +// DeleteJob Request. +message DeleteJobRequest { + // Job name. + string name = 1; + + // Optional. Reason for this deletion. + string reason = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An optional request ID to identify requests. Specify a unique request ID + // so that if you must retry your request, the server will know to ignore + // the request if it has already been completed. The server will guarantee + // that for at least 60 minutes after the first request. + // + // For example, consider a situation where you make an initial request and t + // he request times out. If you make the request again with the same request + // ID, the server can check if original operation with the same request ID + // was received, and if so, will ignore the second request. This prevents + // clients from accidentally creating duplicate commitments. + // + // The request ID must be a valid UUID with the exception that zero UUID is + // not supported (00000000-0000-0000-0000-000000000000). + string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// ListJob Request. +message ListJobsRequest { + // Parent path. + string parent = 1; + + // List filter. + string filter = 4; + + // Page size. + int32 page_size = 2; + + // Page token. + string page_token = 3; +} + +// ListJob Response. +message ListJobsResponse { + // Jobs. + repeated Job jobs = 1; + + // Next page token. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// ListTasks Request. +message ListTasksRequest { + // Required. Name of a TaskGroup from which Tasks are being requested. + // Pattern: + // "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "batch.googleapis.com/TaskGroup" + } + ]; + + // Task filter, null filter matches all Tasks. + // Filter string should be of the format State=TaskStatus.State e.g. + // State=RUNNING + string filter = 2; + + // Page size. + int32 page_size = 3; + + // Page token. + string page_token = 4; +} + +// ListTasks Response. +message ListTasksResponse { + // Tasks. + repeated Task tasks = 1; + + // Next page token. + string next_page_token = 2; + + // Locations that could not be reached. + repeated string unreachable = 3; +} + +// Request for a single Task by name. +message GetTaskRequest { + // Required. Task name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "batch.googleapis.com/Task" + } + ]; +} + +// Represents the metadata of the long-running operation. +message OperationMetadata { + // Output only. The time the operation was created. + google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the operation finished running. + google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Server-defined resource path for the target of the operation. + string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the verb executed by the operation. + string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Human-readable status of the operation, if any. + string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Identifies whether the user has requested cancellation + // of the operation. Operations that have successfully been cancelled + // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + // corresponding to `Code.CANCELLED`. + bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. API version used to start the operation. + string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto new file mode 100644 index 00000000000..9cde8514acd --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,580 @@ +// 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.batch.v1alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/batch/v1alpha/task.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.batch.v1alpha"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; +option ruby_package = "Google::Cloud::Batch::V1alpha"; + +// The Cloud Batch Job description. +message Job { + option (google.api.resource) = { + type: "batch.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + }; + + // The order that TaskGroups are scheduled relative to each other. + // + // Not yet implemented. + enum SchedulingPolicy { + // Unspecified. + SCHEDULING_POLICY_UNSPECIFIED = 0; + + // Run all TaskGroups as soon as possible. + AS_SOON_AS_POSSIBLE = 1; + } + + // Output only. Job name. + // For example: "projects/123456/locations/us-central1/jobs/job01". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A system generated unique ID (in UUID4 format) for the Job. + string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Priority of the Job. + // The valid value range is [0, 100). + // A job with higher priority value is more likely to run earlier if all other + // requirements are satisfied. + int64 priority = 3; + + // Required. TaskGroups in the Job. Only one TaskGroup is supported now. + repeated TaskGroup task_groups = 4 [(google.api.field_behavior) = REQUIRED]; + + // Scheduling policy for TaskGroups in the job. + SchedulingPolicy scheduling_policy = 5; + + // At least one of the dependencies must be satisfied before the Job is + // scheduled to run. + // Only one JobDependency is supported now. + // Not yet implemented. + repeated JobDependency dependencies = 6; + + // Compute resource allocation for all TaskGroups in the Job. + AllocationPolicy allocation_policy = 7; + + // Labels for the Job. Labels could be user provided or system generated. + // For example, + // "labels": { + // "department": "finance", + // "environment": "test" + // } + // You can assign up to 64 labels. [Google Compute Engine label + // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) + // apply. + // Label names that start with "goog-" or "google-" are reserved. + map labels = 8; + + // Output only. Job status. It is read only for users. + JobStatus status = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Deprecated: please use notifications instead. + JobNotification notification = 10 [deprecated = true]; + + // Output only. When the Job was created. + google.protobuf.Timestamp create_time = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The last time the Job was updated. + google.protobuf.Timestamp update_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Log preservation policy for the Job. + LogsPolicy logs_policy = 13; + + // Notification configurations. + repeated JobNotification notifications = 14; +} + +// LogsPolicy describes how outputs from a Job's Tasks (stdout/stderr) will be +// preserved. +message LogsPolicy { + // The destination (if any) for logs. + enum Destination { + // Logs are not preserved. + DESTINATION_UNSPECIFIED = 0; + + // Logs are streamed to Cloud Logging. + CLOUD_LOGGING = 1; + + // Logs are saved to a file path. + PATH = 2; + } + + // Where logs should be saved. + Destination destination = 1; + + // The path to which logs are saved when the destination = PATH. This can be a + // local file path on the VM, or under the mount point of a Persistent Disk or + // Filestore, or a Cloud Storage path. + string logs_path = 2; +} + +// JobDependency describes the state of other Jobs that the start of this Job +// depends on. +// All dependent Jobs must have been submitted in the same region. +message JobDependency { + // Dependency type. + enum Type { + // Unspecified. + TYPE_UNSPECIFIED = 0; + + // The dependent Job has succeeded. + SUCCEEDED = 1; + + // The dependent Job has failed. + FAILED = 2; + + // SUCCEEDED or FAILED. + FINISHED = 3; + } + + // Each item maps a Job name to a Type. + // All items must be satisfied for the JobDependency to be satisfied (the AND + // operation). + // Once a condition for one item becomes true, it won't go back to false + // even the dependent Job state changes again. + map items = 1; +} + +// Job status. +message JobStatus { + // VM instance status. + message InstanceStatus { + // The Compute Engine machine type. + string machine_type = 1; + + // The VM instance provisioning model. + AllocationPolicy.ProvisioningModel provisioning_model = 2; + + // The max number of tasks can be assigned to this instance type. + int64 task_pack = 3; + } + + // Aggregated task status for a TaskGroup. + message TaskGroupStatus { + // Count of task in each state in the TaskGroup. + // The map key is task state name. + map counts = 1; + + // Status of instances allocated for the TaskGroup. + repeated InstanceStatus instances = 2; + } + + // Valid Job states. + enum State { + STATE_UNSPECIFIED = 0; + + // Job is admitted (validated and persisted) and waiting for resources. + QUEUED = 1; + + // Job is scheduled to run as soon as resource allocation is ready. + // The resource allocation may happen at a later time but with a high + // chance to succeed. + SCHEDULED = 2; + + // Resource allocation has been successful. At least one Task in the Job is + // RUNNING. + RUNNING = 3; + + // All Tasks in the Job have finished successfully. + SUCCEEDED = 4; + + // At least one Task in the Job has failed. + FAILED = 5; + + // The Job will be deleted, but has not been deleted yet. Typically this is + // because resources used by the Job are still being cleaned up. + DELETION_IN_PROGRESS = 6; + } + + // Job state + State state = 1; + + // Job status events + repeated StatusEvent status_events = 2; + + // Aggregated task status for each TaskGroup in the Job. + // The map key is TaskGroup ID. + map task_groups = 4; + + // The duration of time that the Job spent in status RUNNING. + google.protobuf.Duration run_duration = 5; +} + +// Notification configurations. +message JobNotification { + // Message details. + // Describe the attribute that a message should have. + // Without specified message attributes, no message will be sent by default. + message Message { + // The message type. + Type type = 1; + + // The new job state. + JobStatus.State new_job_state = 2; + + // The new task state. + TaskStatus.State new_task_state = 3; + } + + // The message type. + enum Type { + // Unspecified. + TYPE_UNSPECIFIED = 0; + + // Notify users that the job state has changed. + JOB_STATE_CHANGED = 1; + + // Notify users that the task state has changed. + TASK_STATE_CHANGED = 2; + } + + // The Pub/Sub topic where notifications like the job state changes + // will be published. This topic exist in the same project as the job + // and billings will be charged to this project. + // If not specified, no Pub/Sub messages will be sent. + // Topic format: `projects/{project}/topics/{topic}`. + string pubsub_topic = 1; + + // The attribute requirements of messages to be sent to this Pub/Sub topic. + // Without this field, no message will be sent. + Message message = 2; +} + +// A Job's resource allocation policy describes when, where, and how compute +// resources should be allocated for the Job. +message AllocationPolicy { + message LocationPolicy { + // A list of allowed location names represented by internal URLs. + // Each location can be a region or a zone. + // Only one region or multiple zones in one region is supported now. + // For example, + // ["regions/us-central1"] allow VMs in any zones in region us-central1. + // ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs + // in zones us-central1-a and us-central1-c. + // All locations end up in different regions would cause errors. + // For example, + // ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", + // "zones/us-west1-a"] contains 2 regions "us-central1" and + // "us-west1". An error is expected in this case. + repeated string allowed_locations = 1; + + // A list of denied location names. + // + // Not yet implemented. + repeated string denied_locations = 2; + } + + // A new persistent disk or a local ssd. + // A VM can only have one local SSD setting but multiple local SSD partitions. + // https://cloud.google.com/compute/docs/disks#pdspecs. + // https://cloud.google.com/compute/docs/disks#localssds. + message Disk { + // A data source from which a PD will be created. + oneof data_source { + // Name of a public or custom image used as the data source. + string image = 4; + + // Name of a snapshot used as the data source. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list` + // For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd". + string type = 1; + + // Disk size in GB. + // This field is ignored if `data_source` is `disk` or `image`. + // If `type` is `local-ssd`, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + int64 size_gb = 2; + + // Local SSDs are available through both "SCSI" and "NVMe" interfaces. + // If not indicated, "NVMe" will be the default one for local ssds. + // We only support "SCSI" for persistent disks now. + string disk_interface = 6; + } + + // A new or an existing persistent disk (PD) or a local ssd attached to a VM + // instance. + message AttachedDisk { + oneof attached { + Disk new_disk = 1; + + // Name of an existing PD. + string existing_disk = 2; + } + + // Device name that the guest operating system will see. + // It is used by Runnable.volumes field to mount disks. So please specify + // the device_name if you want Batch to help mount the disk, and it should + // match the device_name field in volumes. + string device_name = 3; + } + + // Accelerator describes Compute Engine accelerators to be attached to the VM. + message Accelerator { + // The accelerator type. For example, "nvidia-tesla-t4". + // See `gcloud compute accelerator-types list`. + string type = 1; + + // The number of accelerators of this type. + int64 count = 2; + + // Deprecated: please use instances[0].install_gpu_drivers instead. + bool install_gpu_drivers = 3 [deprecated = true]; + } + + // InstancePolicy describes an instance type and resources attached to each VM + // created by this InstancePolicy. + message InstancePolicy { + // Deprecated: please use machine_type instead. + repeated string allowed_machine_types = 1 [deprecated = true]; + + // The Compute Engine machine type. + string machine_type = 2; + + // The minimum CPU platform. + // See + // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. + // Not yet implemented. + string min_cpu_platform = 3; + + // The provisioning model. + ProvisioningModel provisioning_model = 4; + + // The accelerators attached to each VM instance. + repeated Accelerator accelerators = 5; + + // Book disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + Disk boot_disk = 8; + + // Non-boot disks to be attached for each VM created by this InstancePolicy. + // New disks will be deleted when the VM is deleted. + repeated AttachedDisk disks = 6; + + // If specified, VMs will be allocated only inside the matching reservation. + string reservation = 7; + } + + // Either an InstancePolicy or an instance template. + message InstancePolicyOrTemplate { + oneof policy_template { + // InstancePolicy. + InstancePolicy policy = 1; + + // Name of an instance template used to create VMs. + // Named the field as 'instance_template' instead of 'template' to avoid + // c++ keyword conflict. + string instance_template = 2; + } + + // Set this field true if users want Batch to help fetch drivers from a + // third party location and install them for GPUs specified in + // policy.accelerators or instance_template on their behalf. Default is + // false. + bool install_gpu_drivers = 3; + } + + // A network interface. + message NetworkInterface { + // The URL of an existing network resource. + // You can specify the network as a full or partial URL. + // For example, the following are all valid URLs: + // https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} + // projects/{project}/global/networks/{network} + // global/networks/{network} + string network = 1; + + // The URL of an existing subnetwork resource in the network. + // You can specify the subnetwork as a full or partial URL. + // For example, the following are all valid URLs: + // https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork} + // projects/{project}/regions/{region}/subnetworks/{subnetwork} + // regions/{region}/subnetworks/{subnetwork} + string subnetwork = 2; + + // Default is false (with an external IP address). Required if + // no external public IP address is attached to the VM. If no external + // public IP address, additional configuration is required to allow the VM + // to access Google Services. See + // https://cloud.google.com/vpc/docs/configure-private-google-access and + // https://cloud.google.com/nat/docs/gce-example#create-nat for more + // information. + bool no_external_ip_address = 3; + } + + // NetworkPolicy describes VM instance network configurations. + message NetworkPolicy { + // Network configurations. + repeated NetworkInterface network_interfaces = 1; + } + + // Compute Engine VM instance provisioning model. + enum ProvisioningModel { + // Unspecified. + PROVISIONING_MODEL_UNSPECIFIED = 0; + + // Standard VM. + STANDARD = 1; + + // SPOT VM. + SPOT = 2; + + // Preemptible VM (PVM). + // + // Above SPOT VM is the preferable model for preemptible VM instances: the + // old preemptible VM model (indicated by this field) is the older model, + // and has been migrated to use the SPOT model as the underlying technology. + // This old model will still be supported. + PREEMPTIBLE = 3; + } + + // Location where compute resources should be allocated for the Job. + LocationPolicy location = 1; + + // Deprecated: please use instances[0].policy instead. + InstancePolicy instance = 2 [deprecated = true]; + + // Describe instances that can be created by this AllocationPolicy. + // Only instances[0] is supported now. + repeated InstancePolicyOrTemplate instances = 8; + + // Deprecated: please use instances[0].template instead. + repeated string instance_templates = 3 [deprecated = true]; + + // Deprecated: please use instances[0].policy.provisioning_model instead. + repeated ProvisioningModel provisioning_models = 4 [deprecated = true]; + + // Deprecated: please use service_account instead. + string service_account_email = 5 [deprecated = true]; + + // Service account that VMs will run as. + ServiceAccount service_account = 9; + + // Labels applied to all VM instances and other resources + // created by AllocationPolicy. + // Labels could be user provided or system generated. + // You can assign up to 64 labels. [Google Compute Engine label + // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) + // apply. + // Label names that start with "goog-" or "google-" are reserved. + map labels = 6; + + // The network policy. + NetworkPolicy network = 7; +} + +// A TaskGroup contains one or multiple Tasks that share the same +// Runnable but with different runtime parameters. +message TaskGroup { + option (google.api.resource) = { + type: "batch.googleapis.com/TaskGroup" + pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + }; + + // How Tasks in the TaskGroup should be scheduled relative to each other. + enum SchedulingPolicy { + // Unspecified. + SCHEDULING_POLICY_UNSPECIFIED = 0; + + // Run Tasks as soon as resources are available. + AS_SOON_AS_POSSIBLE = 1; + } + + // Output only. TaskGroup name. + // The system generates this field based on parent Job name. + // For example: + // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Tasks in the group share the same task spec. + TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; + + // Number of Tasks in the TaskGroup. + // default is 1 + int64 task_count = 4; + + // Max number of tasks that can run in parallel. + // Default to min(task_count, 1000). + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + SchedulingPolicy scheduling_policy = 6; + + // Compute resource allocation for the TaskGroup. + // If specified, it overrides resources in Job. + AllocationPolicy allocation_policy = 7; + + // Labels for the TaskGroup. + // Labels could be user provided or system generated. + // You can assign up to 64 labels. [Google Compute Engine label + // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) + // apply. + // Label names that start with "goog-" or "google-" are reserved. + map labels = 8; + + // An array of environment variable mappings, which are passed to Tasks with + // matching indices. If task_environments is used then task_count should + // not be specified in the request (and will be ignored). Task count will be + // the length of task_environments. + // + // Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in + // addition to any environment variables set in task_environments, specifying + // the number of Tasks in the Task's parent TaskGroup, and the specific Task's + // index in the TaskGroup (0 through BATCH_TASK_COUNT - 1). + // + // task_environments supports up to 200 entries. + repeated Environment task_environments = 9; + + // Max number of tasks that can be run on a VM at the same time. + // If not specified, the system will decide a value based on available + // compute resources on a VM and task requirements. + int64 task_count_per_node = 10; + + // When true, Batch will populate a file with a list of all VMs assigned to + // the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path + // of that file. Defaults to false. + bool require_hosts_file = 11; + + // When true, Batch will configure SSH to allow passwordless login between + // VMs running the Batch tasks in the same TaskGroup. + bool permissive_ssh = 12; +} + +// Carries information about a Google Cloud service account. +message ServiceAccount { + // Email address of the service account. If not specified, the default + // Compute Engine service account for the project will be used. If instance + // template is being used, the service account has to be specified in the + // instance template and it has to match the email field here. + string email = 1; + + // List of scopes to be enabled for this service account on the VM, in + // addition to the cloud-platform API scope that will be added by default. + repeated string scopes = 2; +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto new file mode 100644 index 00000000000..a28545ad495 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,321 @@ +// 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.batch.v1alpha; + +import "google/api/resource.proto"; +import "google/cloud/batch/v1alpha/volume.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; +option java_multiple_files = true; +option java_outer_classname = "TaskProto"; +option java_package = "com.google.cloud.batch.v1alpha"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; +option ruby_package = "Google::Cloud::Batch::V1alpha"; + +// Compute resource requirements +message ComputeResource { + // The milliCPU count. + int64 cpu_milli = 1; + + // Memory in MiB. + int64 memory_mib = 2; + + // The GPU count. + // + // Not yet implemented. + int64 gpu_count = 3; + + // Extra boot disk size in MiB for each task. + int64 boot_disk_mib = 4; +} + +// Status event +message StatusEvent { + // Type of the event. + string type = 3; + + // Description of the event. + string description = 1; + + // The time this event occurred. + google.protobuf.Timestamp event_time = 2; + + // Task Execution + TaskExecution task_execution = 4; +} + +// This Task Execution field includes detail information for +// task execution procedures, based on StatusEvent types. +message TaskExecution { + // When task is completed as the status of FAILED or SUCCEEDED, + // exit code is for one task execution result, default is 0 as success. + int32 exit_code = 1; +} + +// Status of a task +message TaskStatus { + // Task states. + enum State { + // unknown state + STATE_UNSPECIFIED = 0; + + // The Task is created and waiting for resources. + PENDING = 1; + + // The Task is assigned to at least one VM. + ASSIGNED = 2; + + // The Task is running. + RUNNING = 3; + + // The Task has failed. + FAILED = 4; + + // The Task has succeeded. + SUCCEEDED = 5; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; +} + +// Runnable describes instructions for executing a specific script or container +// as part of a Task. +message Runnable { + // Container runnable. + message Container { + // The URI to pull the container image from. + string image_uri = 1; + + // Overrides the `CMD` specified in the container. If there is an ENTRYPOINT + // (either in the container image or with the entrypoint field below) then + // commands are appended as arguments to the ENTRYPOINT. + repeated string commands = 2; + + // Overrides the `ENTRYPOINT` specified in the container. + string entrypoint = 3; + + // Volumes to mount (bind mount) from the host machine files or directories + // into the container, formatted to match docker run's --volume option, + // e.g. /foo:/bar, or /foo:/bar:ro + repeated string volumes = 7; + + // Arbitrary additional options to include in the "docker run" command when + // running this container, e.g. "--network host". + string options = 8; + + // If set to true, external network access to and from container will be + // blocked. The container will use the default internal network + // 'goog-internal'. + bool block_external_network = 9; + + // Optional username for logging in to a docker registry. If username + // matches `projects/*/secrets/*/versions/*` then Batch will read the + // username from the Secret Manager. + string username = 10; + + // Optional password for logging in to a docker registry. If password + // matches `projects/*/secrets/*/versions/*` then Batch will read the + // password from the Secret Manager; + string password = 11; + } + + // Script runnable. + message Script { + oneof command { + // Script file path on the host VM. + string path = 1; + + // Shell script text. + string text = 2; + } + } + + // Barrier runnable blocks until all tasks in a taskgroup reach it. + message Barrier { + // Barriers are identified by their index in runnable list. + // Names are not required, but if present should be an identifier. + string name = 1; + } + + // The script or container to run. + oneof executable { + // Container runnable. + Container container = 1; + + // Script runnable. + Script script = 2; + + // Barrier runnable. + Barrier barrier = 6; + } + + // Normally, a non-zero exit status causes the Task to fail. This flag allows + // execution of other Runnables to continue instead. + bool ignore_exit_status = 3; + + // This flag allows a Runnable to continue running in the background while the + // Task executes subsequent Runnables. This is useful to provide services to + // other Runnables (or to provide debugging support tools like SSH servers). + bool background = 4; + + // By default, after a Runnable fails, no further Runnable are executed. This + // flag indicates that this Runnable must be run even if the Task has already + // failed. This is useful for Runnables that copy output files off of the VM + // or for debugging. + // + // The always_run flag does not override the Task's overall max_run_duration. + // If the max_run_duration has expired then no further Runnables will execute, + // not even always_run Runnables. + bool always_run = 5; + + // Environment variables for this Runnable (overrides variables set for the + // whole Task or TaskGroup). + Environment environment = 7; + + // Timeout for this Runnable. + google.protobuf.Duration timeout = 8; + + // Labels for this Runnable. + map labels = 9; +} + +// Spec of a task +message TaskSpec { + // The sequence of scripts or containers to run for this Task. Each Task using + // this TaskSpec executes its list of runnables in order. The Task succeeds if + // all of its runnables either exit with a zero status or any that exit with a + // non-zero status have the ignore_exit_status flag. + // + // Background runnables are killed automatically (if they have not already + // exited) a short time after all foreground runnables have completed. Even + // though this is likely to result in a non-zero exit status for the + // background runnable, these automatic kills are not treated as Task + // failures. + repeated Runnable runnables = 8; + + // ComputeResource requirements. + ComputeResource compute_resource = 3; + + // Maximum duration the task should run. + // The task will be killed and marked as FAILED if over this limit. + google.protobuf.Duration max_run_duration = 4; + + // Maximum number of retries on failures. + // The default, 0, which means never retry. + // The valid value range is [0, 10]. + int32 max_retry_count = 5; + + // Lifecycle management schema when any task in a task group is failed. + // The valid size of lifecycle policies are [0, 10]. + // For each lifecycle policy, when the condition is met, + // the action in that policy will execute. + // If there are multiple policies that the task execution result matches, + // we use the action from the first matched policy. If task execution result + // does not meet with any of the defined lifecycle policy, we consider it as + // the default policy. Default policy means if the exit code is 0, exit task. + // If task ends with non-zero exit code, retry the task with max_retry_count. + repeated LifecyclePolicy lifecycle_policies = 9; + + // Deprecated: please use environment(non-plural) instead. + map environments = 6 [deprecated = true]; + + // Volumes to mount before running Tasks using this TaskSpec. + repeated Volume volumes = 7; + + // Environment variables to set before running the Task. + Environment environment = 10; +} + +// LifecyclePolicy describes how to deal with task failures +// based on different conditions. +message LifecyclePolicy { + // Conditions for actions to deal with task failures. + message ActionCondition { + // Exit codes of a task execution. + // If there are more than 1 exit codes, + // when task executes with any of the exit code in the list, + // the condition is met and the action will be executed. + repeated int32 exit_codes = 1; + } + + // Action on task failures based on different conditions. + enum Action { + // Action unspecified. + ACTION_UNSPECIFIED = 0; + + // Action that tasks in the group will be scheduled to re-execute. + RETRY_TASK = 1; + + // Action that tasks in the group will be stopped immediately. + FAIL_TASK = 2; + } + + // Action to execute when ActionCondition is true. + Action action = 1; + + // Conditions that decide why a task failure is dealt with a specific action. + ActionCondition action_condition = 2; +} + +// A Cloud Batch task. +message Task { + option (google.api.resource) = { + type: "batch.googleapis.com/Task" + pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}" + }; + + // Task name. + // The name is generated from the parent TaskGroup name and 'id' field. + // For example: + // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01/tasks/task01". + string name = 1; + + // Task Status. + TaskStatus status = 2; +} + +// An Environment describes a collection of environment variables to set when +// executing Tasks. +message Environment { + message KMSEnvMap { + // The name of the KMS key that will be used to decrypt the cipher text. + string key_name = 1; + + // The value of the cipherText response from the `encrypt` method. + string cipher_text = 2; + } + + // A map of environment variable names to values. + map variables = 1; + + // A map of environment variable names to Secret Manager secret names. + // The VM will access the named secrets to set the value of each environment + // variable. + map secret_variables = 2; + + // An encrypted JSON dictionary where the key/value pairs correspond to + // environment variable names and their values. + KMSEnvMap encrypted_variables = 3; +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto new file mode 100644 index 00000000000..4112d2363a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// 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.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; +option java_multiple_files = true; +option java_outer_classname = "VolumeProto"; +option java_package = "com.google.cloud.batch.v1alpha"; +option objc_class_prefix = "GCB"; +option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; +option ruby_package = "Google::Cloud::Batch::V1alpha"; + +// Volume describes a volume and parameters for it to be mounted to a VM. +message Volume { + // The source for the volume. + oneof source { + // A Network File System (NFS) volume. For example, a + // Filestore file share. + NFS nfs = 1; + + // Deprecated: please use device_name instead. + PD pd = 2 [deprecated = true]; + + // A Google Cloud Storage (GCS) volume. + GCS gcs = 3; + + // Device name of an attached disk volume, which should align with a + // device_name specified by + // job.allocation_policy.instances[0].policy.disks[i].device_name or + // defined by the given instance template in + // job.allocation_policy.instances[0].instance_template. + string device_name = 6; + } + + // The mount path for the volume, e.g. /mnt/disks/share. + string mount_path = 4; + + // For Google Cloud Storage (GCS), mount options are the options supported by + // the gcsfuse tool (https://github.com/GoogleCloudPlatform/gcsfuse). + // For existing persistent disks, mount options provided by the + // mount command (https://man7.org/linux/man-pages/man8/mount.8.html) except + // writing are supported. This is due to restrictions of multi-writer mode + // (https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms). + // For other attached disks and Network File System (NFS), mount options are + // these supported by the mount command + // (https://man7.org/linux/man-pages/man8/mount.8.html). + repeated string mount_options = 5; +} + +// Represents an NFS volume. +message NFS { + // The IP address of the NFS. + string server = 1; + + // Remote source path exported from the NFS, e.g., "/share". + string remote_path = 2; +} + +// Deprecated: please use device_name instead. +message PD { + // PD disk name, e.g. pd-1. + string disk = 1; + + // PD device name, e.g. persistent-disk-1. + string device = 2; + + // Whether this is an existing PD. Default is false. If false, i.e., new + // PD, we will format it into ext4 and mount to the given path. If true, i.e., + // existing PD, it should be in ext4 format and we will mount it to the given + // path. + bool existing = 3 [deprecated = true]; +} + +// Represents a Google Cloud Storage volume. +message GCS { + // Remote path, either a bucket name or a subdirectory of a bucket, e.g.: + // bucket_name, bucket_name/subdirectory/ + string remote_path = 1; +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js new file mode 100644 index 00000000000..8207e50d060 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js @@ -0,0 +1,92 @@ +// 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, job) { + // [START batch_v1alpha_generated_BatchService_CreateJob_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 where the Job will be created. + * Pattern: "projects/{project}/locations/{location}" + */ + // const parent = 'abc123' + /** + * ID used to uniquely identify the Job within its parent scope. + * This field should contain at most 63 characters and must start with + * lowercase characters. + * Only lowercase characters, numbers and '-' are accepted. + * The '-' character cannot be the first or the last one. + * A system generated ID will be used if the field is not set. + * The job.name field in the request will be ignored and the created resource + * name of the Job will be "{parent}/jobs/{job_id}". + */ + // const jobId = 'abc123' + /** + * Required. The Job to create. + */ + // const job = {} + /** + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + }; + + // Run request + const response = await batchClient.createJob(request); + console.log(response); + } + + callCreateJob(); + // [END batch_v1alpha_generated_BatchService_CreateJob_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-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.js new file mode 100644 index 00000000000..bb942a135b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.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() { + // [START batch_v1alpha_generated_BatchService_DeleteJob_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. + */ + /** + * Job name. + */ + // const name = 'abc123' + /** + * Optional. Reason for this deletion. + */ + // const reason = 'abc123' + /** + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + */ + // const requestId = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callDeleteJob() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await batchClient.deleteJob(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteJob(); + // [END batch_v1alpha_generated_BatchService_DeleteJob_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-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.js new file mode 100644 index 00000000000..dcb65219962 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.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 batch_v1alpha_generated_BatchService_GetJob_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. Job name. + */ + // const name = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await batchClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END batch_v1alpha_generated_BatchService_GetJob_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-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.js new file mode 100644 index 00000000000..7e6c762eec6 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.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 batch_v1alpha_generated_BatchService_GetTask_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. Task name. + */ + // const name = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callGetTask() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await batchClient.getTask(request); + console.log(response); + } + + callGetTask(); + // [END batch_v1alpha_generated_BatchService_GetTask_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-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js new file mode 100644 index 00000000000..7526e461b9c --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js @@ -0,0 +1,74 @@ +// 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 batch_v1alpha_generated_BatchService_ListJobs_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. + */ + /** + * Parent path. + */ + // const parent = 'abc123' + /** + * List filter. + */ + // const filter = 'abc123' + /** + * Page size. + */ + // const pageSize = 1234 + /** + * Page token. + */ + // const pageToken = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callListJobs() { + // Construct request + const request = { + }; + + // Run request + const iterable = await batchClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END batch_v1alpha_generated_BatchService_ListJobs_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-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js new file mode 100644 index 00000000000..b58fc1eee54 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.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 batch_v1alpha_generated_BatchService_ListTasks_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. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + */ + // const parent = 'abc123' + /** + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + */ + // const filter = 'abc123' + /** + * Page size. + */ + // const pageSize = 1234 + /** + * Page token. + */ + // const pageToken = 'abc123' + + // Imports the Batch library + const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; + + // Instantiates a client + const batchClient = new BatchServiceClient(); + + async function callListTasks() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await batchClient.listTasksAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTasks(); + // [END batch_v1alpha_generated_BatchService_ListTasks_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-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json new file mode 100644 index 00000000000..d2276b2647b --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -0,0 +1,299 @@ +{ + "clientLibrary": { + "name": "nodejs-batch", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.batch.v1alpha", + "version": "v1alpha" + } + ] + }, + "snippets": [ + { + "regionTag": "batch_v1alpha_generated_BatchService_CreateJob_async", + "title": "BatchService createJob Sample", + "origin": "API_DEFINITION", + "description": " Create a Job.", + "canonical": true, + "file": "batch_service.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 84, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.batch.v1alpha.BatchService.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job_id", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.batch.v1alpha.Job" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1alpha.Job", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.batch.v1alpha.BatchService.CreateJob", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1alpha.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1alpha_generated_BatchService_GetJob_async", + "title": "BatchService getJob Sample", + "origin": "API_DEFINITION", + "description": " Get a Job specified by its resource name.", + "canonical": true, + "file": "batch_service.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.batch.v1alpha.BatchService.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1alpha.Job", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.batch.v1alpha.BatchService.GetJob", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1alpha.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1alpha_generated_BatchService_DeleteJob_async", + "title": "BatchService deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Delete a Job.", + "canonical": true, + "file": "batch_service.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.batch.v1alpha.BatchService.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "reason", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.batch.v1alpha.BatchService.DeleteJob", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1alpha.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1alpha_generated_BatchService_ListJobs_async", + "title": "BatchService listJobs Sample", + "origin": "API_DEFINITION", + "description": " List all Jobs for a project within a region.", + "canonical": true, + "file": "batch_service.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.batch.v1alpha.BatchService.ListJobs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1alpha.ListJobsResponse", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.batch.v1alpha.BatchService.ListJobs", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1alpha.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1alpha_generated_BatchService_GetTask_async", + "title": "BatchService getTask Sample", + "origin": "API_DEFINITION", + "description": " Return a single Task.", + "canonical": true, + "file": "batch_service.get_task.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTask", + "fullName": "google.cloud.batch.v1alpha.BatchService.GetTask", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1alpha.Task", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" + }, + "method": { + "shortName": "GetTask", + "fullName": "google.cloud.batch.v1alpha.BatchService.GetTask", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1alpha.BatchService" + } + } + } + }, + { + "regionTag": "batch_v1alpha_generated_BatchService_ListTasks_async", + "title": "BatchService listTasks Sample", + "origin": "API_DEFINITION", + "description": " List Tasks associated with a job.", + "canonical": true, + "file": "batch_service.list_tasks.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTasks", + "fullName": "google.cloud.batch.v1alpha.BatchService.ListTasks", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.batch.v1alpha.ListTasksResponse", + "client": { + "shortName": "BatchServiceClient", + "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" + }, + "method": { + "shortName": "ListTasks", + "fullName": "google.cloud.batch.v1alpha.BatchService.ListTasks", + "service": { + "shortName": "BatchService", + "fullName": "google.cloud.batch.v1alpha.BatchService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/index.ts b/owl-bot-staging/google-cloud-batch/v1alpha/src/index.ts new file mode 100644 index 00000000000..69f087aa775 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 v1alpha from './v1alpha'; +const BatchServiceClient = v1alpha.BatchServiceClient; +type BatchServiceClient = v1alpha.BatchServiceClient; +export {v1alpha, BatchServiceClient}; +export default {v1alpha, BatchServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts new file mode 100644 index 00000000000..1503d22686d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1743 @@ +// 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, IamClient, IamProtos, 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/v1alpha/batch_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './batch_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Google Batch Service. + * The service manages user submitted batch jobs and allocates Google Compute + * Engine VM instances to run the jobs. + * @class + * @memberof v1alpha + */ +export class BatchServiceClient { + 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}; + iamClient: IamClient; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + batchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of BatchServiceClient. + * + * @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 BatchServiceClient({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 BatchServiceClient; + 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); + + 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 = { + jobPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + taskPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}' + ), + taskGroupPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}' + ), + }; + + // 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 = { + listJobs: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs'), + listTasks: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') + }; + + 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: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const deleteJobResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteJobMetadata = protoFilesRoot.lookup( + '.google.cloud.batch.v1alpha.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + deleteJob: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteJobResponse.decode.bind(deleteJobResponse), + deleteJobMetadata.decode.bind(deleteJobMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.batch.v1alpha.BatchService', 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.batchServiceStub) { + return this.batchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.batch.v1alpha.BatchService. + this.batchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.batch.v1alpha.BatchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.batch.v1alpha.BatchService, + 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 batchServiceStubMethods = + ['createJob', 'getJob', 'deleteJob', 'listJobs', 'getTask', 'listTasks']; + for (const methodName of batchServiceStubMethods) { + const callPromise = this.batchServiceStub.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.batchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'batch.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 'batch.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 -- + // ------------------- +/** + * Create a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name where the Job will be created. + * Pattern: "projects/{project}/locations/{location}" + * @param {string} request.jobId + * ID used to uniquely identify the Job within its parent scope. + * This field should contain at most 63 characters and must start with + * lowercase characters. + * Only lowercase characters, numbers and '-' are accepted. + * The '-' character cannot be the first or the last one. + * A system generated ID will be used if the field is not set. + * + * The job.name field in the request will be ignored and the created resource + * name of the Job will be "{parent}/jobs/{job_id}". + * @param {google.cloud.batch.v1alpha.Job} request.job + * Required. The Job to create. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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 [Job]{@link google.cloud.batch.v1alpha.Job}. + * 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/v1alpha/batch_service.create_job.js + * region_tag:batch_v1alpha_generated_BatchService_CreateJob_async + */ + createJob( + request?: protos.google.cloud.batch.v1alpha.ICreateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.ICreateJobRequest|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.batch.v1alpha.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.batch.v1alpha.ICreateJobRequest, + callback: Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.batch.v1alpha.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.ICreateJobRequest|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.createJob(request, options, callback); + } +/** + * Get a Job specified by its resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Job 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 [Job]{@link google.cloud.batch.v1alpha.Job}. + * 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/v1alpha/batch_service.get_job.js + * region_tag:batch_v1alpha_generated_BatchService_GetJob_async + */ + getJob( + request?: protos.google.cloud.batch.v1alpha.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.batch.v1alpha.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.batch.v1alpha.IGetJobRequest, + callback: Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.batch.v1alpha.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.batch.v1alpha.IJob, + protos.google.cloud.batch.v1alpha.IGetJobRequest|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.getJob(request, options, callback); + } +/** + * Return a single Task. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Task 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 [Task]{@link google.cloud.batch.v1alpha.Task}. + * 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/v1alpha/batch_service.get_task.js + * region_tag:batch_v1alpha_generated_BatchService_GetTask_async + */ + getTask( + request?: protos.google.cloud.batch.v1alpha.IGetTaskRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1alpha.ITask, + protos.google.cloud.batch.v1alpha.IGetTaskRequest|undefined, {}|undefined + ]>; + getTask( + request: protos.google.cloud.batch.v1alpha.IGetTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.batch.v1alpha.ITask, + protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, + {}|null|undefined>): void; + getTask( + request: protos.google.cloud.batch.v1alpha.IGetTaskRequest, + callback: Callback< + protos.google.cloud.batch.v1alpha.ITask, + protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, + {}|null|undefined>): void; + getTask( + request?: protos.google.cloud.batch.v1alpha.IGetTaskRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.batch.v1alpha.ITask, + protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.batch.v1alpha.ITask, + protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.batch.v1alpha.ITask, + protos.google.cloud.batch.v1alpha.IGetTaskRequest|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.getTask(request, options, callback); + } + +/** + * Delete a Job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Job name. + * @param {string} [request.reason] + * Optional. Reason for this deletion. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @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/v1alpha/batch_service.delete_job.js + * region_tag:batch_v1alpha_generated_BatchService_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, + 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.deleteJob(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteJob()`. + * @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/v1alpha/batch_service.delete_job.js + * region_tag:batch_v1alpha_generated_BatchService_DeleteJob_async + */ + async checkDeleteJobProgress(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.deleteJob, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * List all Jobs for a project within a region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Parent path. + * @param {string} request.filter + * List filter. + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Job]{@link google.cloud.batch.v1alpha.Job}. + * 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 `listJobsAsync()` + * 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. + */ + listJobs( + request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1alpha.IJob[], + protos.google.cloud.batch.v1alpha.IListJobsRequest|null, + protos.google.cloud.batch.v1alpha.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.batch.v1alpha.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.batch.v1alpha.IListJobsRequest, + protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1alpha.IJob>): void; + listJobs( + request: protos.google.cloud.batch.v1alpha.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.batch.v1alpha.IListJobsRequest, + protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1alpha.IJob>): void; + listJobs( + request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.batch.v1alpha.IListJobsRequest, + protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1alpha.IJob>, + callback?: PaginationCallback< + protos.google.cloud.batch.v1alpha.IListJobsRequest, + protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, + protos.google.cloud.batch.v1alpha.IJob>): + Promise<[ + protos.google.cloud.batch.v1alpha.IJob[], + protos.google.cloud.batch.v1alpha.IListJobsRequest|null, + protos.google.cloud.batch.v1alpha.IListJobsResponse + ]>|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.listJobs(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 + * Parent path. + * @param {string} request.filter + * List filter. + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Job]{@link google.cloud.batch.v1alpha.Job} 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 `listJobsAsync()` + * 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. + */ + listJobsStream( + request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.createStream( + this.innerApiCalls.listJobs as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listJobs`, 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 + * Parent path. + * @param {string} request.filter + * List filter. + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * 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 + * [Job]{@link google.cloud.batch.v1alpha.Job}. 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/v1alpha/batch_service.list_jobs.js + * region_tag:batch_v1alpha_generated_BatchService_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, + 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['listJobs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listJobs.asyncIterate( + this.innerApiCalls['listJobs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * List Tasks associated with a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @param {string} request.filter + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Task]{@link google.cloud.batch.v1alpha.Task}. + * 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 `listTasksAsync()` + * 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. + */ + listTasks( + request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.batch.v1alpha.ITask[], + protos.google.cloud.batch.v1alpha.IListTasksRequest|null, + protos.google.cloud.batch.v1alpha.IListTasksResponse + ]>; + listTasks( + request: protos.google.cloud.batch.v1alpha.IListTasksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.batch.v1alpha.IListTasksRequest, + protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1alpha.ITask>): void; + listTasks( + request: protos.google.cloud.batch.v1alpha.IListTasksRequest, + callback: PaginationCallback< + protos.google.cloud.batch.v1alpha.IListTasksRequest, + protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1alpha.ITask>): void; + listTasks( + request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.batch.v1alpha.IListTasksRequest, + protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1alpha.ITask>, + callback?: PaginationCallback< + protos.google.cloud.batch.v1alpha.IListTasksRequest, + protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, + protos.google.cloud.batch.v1alpha.ITask>): + Promise<[ + protos.google.cloud.batch.v1alpha.ITask[], + protos.google.cloud.batch.v1alpha.IListTasksRequest|null, + protos.google.cloud.batch.v1alpha.IListTasksResponse + ]>|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.listTasks(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. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @param {string} request.filter + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * Page token. + * @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 [Task]{@link google.cloud.batch.v1alpha.Task} 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 `listTasksAsync()` + * 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. + */ + listTasksStream( + request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, + 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['listTasks']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTasks.createStream( + this.innerApiCalls.listTasks as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTasks`, 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. Name of a TaskGroup from which Tasks are being requested. + * Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @param {string} request.filter + * Task filter, null filter matches all Tasks. + * Filter string should be of the format State=TaskStatus.State e.g. + * State=RUNNING + * @param {number} request.pageSize + * Page size. + * @param {string} request.pageToken + * 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 + * [Task]{@link google.cloud.batch.v1alpha.Task}. 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/v1alpha/batch_service.list_tasks.js + * region_tag:batch_v1alpha_generated_BatchService_ListTasks_async + */ + listTasksAsync( + request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, + 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['listTasks']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTasks.asyncIterate( + this.innerApiCalls['listTasks'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions} + * @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/interfaces/CallOptions.html} 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 [Policy]{@link google.iam.v1.Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIamPolicy( + request: IamProtos.google.iam.v1.GetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise { + return this.iamClient.getIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + setIamPolicy( + request: IamProtos.google.iam.v1.SetIamPolicyRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.Policy, + IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ):Promise { + return this.iamClient.setIamPolicy(request, options, callback); + } + +/** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ + testIamPermissions( + request: IamProtos.google.iam.v1.TestIamPermissionsRequest, + options?: + | gax.CallOptions + | Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + IamProtos.google.iam.v1.TestIamPermissionsResponse, + IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ):Promise { + return this.iamClient.testIamPermissions(request, options, callback); + } + +/** + * 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 job resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @returns {string} Resource name string. + */ + jobPath(project:string,location:string,job:string) { + return this.pathTemplates.jobPathTemplate.render({ + project: project, + location: location, + job: job, + }); + } + + /** + * Parse the project from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the project. + */ + matchProjectFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).project; + } + + /** + * Parse the location from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the location. + */ + matchLocationFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).location; + } + + /** + * Parse the job from Job resource. + * + * @param {string} jobName + * A fully-qualified path representing Job resource. + * @returns {string} A string representing the job. + */ + matchJobFromJobName(jobName: string) { + return this.pathTemplates.jobPathTemplate.match(jobName).job; + } + + /** + * 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 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 task resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} task_group + * @param {string} task + * @returns {string} Resource name string. + */ + taskPath(project:string,location:string,job:string,taskGroup:string,task:string) { + return this.pathTemplates.taskPathTemplate.render({ + project: project, + location: location, + job: job, + task_group: taskGroup, + task: task, + }); + } + + /** + * Parse the project from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).project; + } + + /** + * Parse the location from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).location; + } + + /** + * Parse the job from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).job; + } + + /** + * Parse the task_group from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task_group. + */ + matchTaskGroupFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task_group; + } + + /** + * Parse the task from Task resource. + * + * @param {string} taskName + * A fully-qualified path representing Task resource. + * @returns {string} A string representing the task. + */ + matchTaskFromTaskName(taskName: string) { + return this.pathTemplates.taskPathTemplate.match(taskName).task; + } + + /** + * Return a fully-qualified taskGroup resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} job + * @param {string} task_group + * @returns {string} Resource name string. + */ + taskGroupPath(project:string,location:string,job:string,taskGroup:string) { + return this.pathTemplates.taskGroupPathTemplate.render({ + project: project, + location: location, + job: job, + task_group: taskGroup, + }); + } + + /** + * Parse the project from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).project; + } + + /** + * Parse the location from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the location. + */ + matchLocationFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).location; + } + + /** + * Parse the job from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the job. + */ + matchJobFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).job; + } + + /** + * Parse the task_group from TaskGroup resource. + * + * @param {string} taskGroupName + * A fully-qualified path representing TaskGroup resource. + * @returns {string} A string representing the task_group. + */ + matchTaskGroupFromTaskGroupName(taskGroupName: string) { + return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).task_group; + } + + /** + * 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.batchServiceStub && !this._terminated) { + return this.batchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.iamClient.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json new file mode 100644 index 00000000000..b8f623ace5a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json @@ -0,0 +1,68 @@ +{ + "interfaces": { + "google.cloud.batch.v1alpha.BatchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateJob": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteJob": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListJobs": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetTask": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListTasks": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json new file mode 100644 index 00000000000..82136a8b22d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json @@ -0,0 +1,6 @@ +[ + "../../protos/google/cloud/batch/v1alpha/batch.proto", + "../../protos/google/cloud/batch/v1alpha/job.proto", + "../../protos/google/cloud/batch/v1alpha/task.proto", + "../../protos/google/cloud/batch/v1alpha/volume.proto" +] diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json new file mode 100644 index 00000000000..3de59b0c964 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json @@ -0,0 +1,91 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.batch.v1alpha", + "libraryPackage": "@google-cloud/batch", + "services": { + "BatchService": { + "clients": { + "grpc": { + "libraryClient": "BatchServiceClient", + "rpcs": { + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "GetJob": { + "methods": [ + "getJob" + ] + }, + "GetTask": { + "methods": [ + "getTask" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + }, + "ListTasks": { + "methods": [ + "listTasks", + "listTasksStream", + "listTasksAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "BatchServiceClient", + "rpcs": { + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "GetJob": { + "methods": [ + "getJob" + ] + }, + "GetTask": { + "methods": [ + "getTask" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + }, + "ListTasks": { + "methods": [ + "listTasks", + "listTasksStream", + "listTasksAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/index.ts b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/index.ts new file mode 100644 index 00000000000..0f129526252 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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 {BatchServiceClient} from './batch_service_client'; diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..230aacd757b --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 batch = require('@google-cloud/batch'); + +function main() { + const batchServiceClient = new batch.BatchServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..a09668ae84d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 {BatchServiceClient} from '@google-cloud/batch'; + +// check that the client class type name can be used +function doStuffWithBatchServiceClient(client: BatchServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const batchServiceClient = new BatchServiceClient(); + doStuffWithBatchServiceClient(batchServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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-batch/v1alpha/test/gapic_batch_service_v1alpha.ts b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts new file mode 100644 index 00000000000..a4660b3c6e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,2111 @@ +// 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 batchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, IamProtos, 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('v1alpha.BatchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = batchserviceModule.v1alpha.BatchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = batchserviceModule.v1alpha.BatchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = batchserviceModule.v1alpha.BatchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.batchServiceStub, undefined); + await client.initialize(); + assert(client.batchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.batchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.batchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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('createJob', () => { + it('invokes createJob without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.Job() + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createJob with closed client', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createJob(request), expectedError); + }); + }); + + describe('getJob', () => { + it('invokes getJob without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.Job() + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with closed client', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('getTask', () => { + it('invokes getTask without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.Task() + ); + client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); + const [response] = await client.getTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.Task() + ); + client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTask( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.ITask|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTask(request), expectedError); + const actualRequest = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getTask with closed client', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.GetTaskRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTask(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteJob = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + 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.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with call error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with LRO error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteJobProgress without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + 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.checkDeleteJobProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteJobProgress with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + 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.checkDeleteJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.IJob[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobs with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listJobsStream without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1alpha.Job[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1alpha.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listJobsStream with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1alpha.Job[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1alpha.Job) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.batch.v1alpha.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listJobs with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.batch.v1alpha.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listTasks', () => { + it('invokes listTasks without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); + const [response] = await client.listTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasks without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTasks( + request, + (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.ITask[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasks with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTasks(request), expectedError); + const actualRequest = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listTasksStream without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + ]; + client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1alpha.Task[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1alpha.Task) => { + 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.listTasks.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listTasksStream with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.batch.v1alpha.Task[] = []; + stream.on('data', (response: protos.google.cloud.batch.v1alpha.Task) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTasks without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), + ]; + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.batch.v1alpha.ITask[] = []; + const iterable = client.listTasksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listTasks with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.batch.v1alpha.ListTasksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTasksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.batch.v1alpha.ITask[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy() + ); + client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); + assert((client.iamClient.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse() + ); + client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + expectedOptions, + (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); + assert((client.iamClient.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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 batchserviceModule.v1alpha.BatchServiceClient({ + 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('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.jobPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.jobPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath("projectValue", "locationValue", "jobValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + 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('task', () => { + const fakePath = "/rendered/path/task"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + task_group: "taskGroupValue", + task: "taskValue", + }; + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath("projectValue", "locationValue", "jobValue", "taskGroupValue", "taskValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskName', () => { + const result = client.matchJobFromTaskName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskGroupFromTaskName', () => { + const result = client.matchTaskGroupFromTaskName(fakePath); + assert.strictEqual(result, "taskGroupValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, "taskValue"); + assert((client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('taskGroup', () => { + const fakePath = "/rendered/path/taskGroup"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + task_group: "taskGroupValue", + }; + const client = new batchserviceModule.v1alpha.BatchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.taskGroupPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.taskGroupPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('taskGroupPath', () => { + const result = client.taskGroupPath("projectValue", "locationValue", "jobValue", "taskGroupValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.taskGroupPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromTaskGroupName', () => { + const result = client.matchProjectFromTaskGroupName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromTaskGroupName', () => { + const result = client.matchLocationFromTaskGroupName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchJobFromTaskGroupName', () => { + const result = client.matchJobFromTaskGroupName(fakePath); + assert.strictEqual(result, "jobValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchTaskGroupFromTaskGroupName', () => { + const result = client.matchTaskGroupFromTaskGroupName(fakePath); + assert.strictEqual(result, "taskGroupValue"); + assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/tsconfig.json b/owl-bot-staging/google-cloud-batch/v1alpha/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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-batch/v1alpha/webpack.config.js b/owl-bot-staging/google-cloud-batch/v1alpha/webpack.config.js new file mode 100644 index 00000000000..04a4c53960a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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: 'BatchService', + filename: './batch-service.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 7cd978dad1c5fcd12cd2b18e944be12952f93226 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 4 Jan 2023 02:07:07 +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-batch/v1/.eslintignore | 7 - .../google-cloud-batch/v1/.eslintrc.json | 3 - .../google-cloud-batch/v1/.gitignore | 14 - .../google-cloud-batch/v1/.jsdoc.js | 55 - .../google-cloud-batch/v1/.mocharc.js | 33 - .../google-cloud-batch/v1/.prettierrc.js | 22 - .../google-cloud-batch/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../google-cloud-batch/v1/package.json | 64 - .../protos/google/cloud/batch/v1/batch.proto | 273 --- .../v1/protos/google/cloud/batch/v1/job.proto | 475 ---- .../protos/google/cloud/batch/v1/task.proto | 313 --- .../protos/google/cloud/batch/v1/volume.proto | 76 - .../generated/v1/batch_service.create_job.js | 92 - .../generated/v1/batch_service.delete_job.js | 79 - .../generated/v1/batch_service.get_job.js | 61 - .../generated/v1/batch_service.get_task.js | 61 - .../generated/v1/batch_service.list_jobs.js | 74 - .../generated/v1/batch_service.list_tasks.js | 79 - ...nippet_metadata.google.cloud.batch.v1.json | 299 --- .../google-cloud-batch/v1/src/index.ts | 25 - .../v1/src/v1/batch_service_client.ts | 1743 -------------- .../src/v1/batch_service_client_config.json | 68 - .../v1/src/v1/batch_service_proto_list.json | 6 - .../v1/src/v1/gapic_metadata.json | 91 - .../google-cloud-batch/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_batch_service_v1.ts | 2111 ----------------- .../google-cloud-batch/v1/tsconfig.json | 19 - .../google-cloud-batch/v1/webpack.config.js | 64 - .../google-cloud-batch/v1alpha/.eslintignore | 7 - .../google-cloud-batch/v1alpha/.eslintrc.json | 3 - .../google-cloud-batch/v1alpha/.gitignore | 14 - .../google-cloud-batch/v1alpha/.jsdoc.js | 55 - .../google-cloud-batch/v1alpha/.mocharc.js | 33 - .../google-cloud-batch/v1alpha/.prettierrc.js | 22 - .../google-cloud-batch/v1alpha/README.md | 1 - .../v1alpha/linkinator.config.json | 16 - .../google-cloud-batch/v1alpha/package.json | 64 - .../google/cloud/batch/v1alpha/batch.proto | 273 --- .../google/cloud/batch/v1alpha/job.proto | 580 ----- .../google/cloud/batch/v1alpha/task.proto | 321 --- .../google/cloud/batch/v1alpha/volume.proto | 94 - .../v1alpha/batch_service.create_job.js | 92 - .../v1alpha/batch_service.delete_job.js | 79 - .../v1alpha/batch_service.get_job.js | 61 - .../v1alpha/batch_service.get_task.js | 61 - .../v1alpha/batch_service.list_jobs.js | 74 - .../v1alpha/batch_service.list_tasks.js | 79 - ...t_metadata.google.cloud.batch.v1alpha.json | 299 --- .../google-cloud-batch/v1alpha/src/index.ts | 25 - .../src/v1alpha/batch_service_client.ts | 1743 -------------- .../v1alpha/batch_service_client_config.json | 68 - .../src/v1alpha/batch_service_proto_list.json | 6 - .../v1alpha/src/v1alpha/gapic_metadata.json | 91 - .../v1alpha/src/v1alpha/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1alpha/system-test/install.ts | 49 - .../test/gapic_batch_service_v1alpha.ts | 2111 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - packages/google-cloud-batch/.jsdoc.js | 4 +- packages/google-cloud-batch/.mocharc.js | 2 +- packages/google-cloud-batch/.prettierrc.js | 2 +- .../protos/google/cloud/batch/v1/task.proto | 17 + .../google-cloud-batch/protos/protos.d.ts | 120 +- packages/google-cloud-batch/protos/protos.js | 318 ++- .../google-cloud-batch/protos/protos.json | 23 + .../generated/v1/batch_service.create_job.js | 2 +- .../generated/v1/batch_service.delete_job.js | 2 +- .../generated/v1/batch_service.get_job.js | 2 +- .../generated/v1/batch_service.get_task.js | 2 +- .../generated/v1/batch_service.list_jobs.js | 2 +- .../generated/v1/batch_service.list_tasks.js | 2 +- packages/google-cloud-batch/src/index.ts | 2 +- .../src/v1/batch_service_client.ts | 2 +- packages/google-cloud-batch/src/v1/index.ts | 2 +- .../system-test/fixtures/sample/src/index.js | 2 +- .../system-test/fixtures/sample/src/index.ts | 2 +- .../google-cloud-batch/system-test/install.ts | 2 +- .../test/gapic_batch_service_v1.ts | 2 +- 84 files changed, 492 insertions(+), 12853 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-batch/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-batch/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-batch/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-batch/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_job.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_task.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_tasks.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.gitignore delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/README.md delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/package.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/index.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-batch/v1alpha/webpack.config.js diff --git a/owl-bot-staging/google-cloud-batch/v1/.eslintignore b/owl-bot-staging/google-cloud-batch/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-batch/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-batch/v1/.eslintrc.json b/owl-bot-staging/google-cloud-batch/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-batch/v1/.gitignore b/owl-bot-staging/google-cloud-batch/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-batch/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-batch/v1/.jsdoc.js b/owl-bot-staging/google-cloud-batch/v1/.jsdoc.js deleted file mode 100644 index bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/batch', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-batch/v1/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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-batch/v1/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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-batch/v1/README.md b/owl-bot-staging/google-cloud-batch/v1/README.md deleted file mode 100644 index 15b2fa3f3e4..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Batch: Nodejs Client diff --git a/owl-bot-staging/google-cloud-batch/v1/linkinator.config.json b/owl-bot-staging/google-cloud-batch/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-batch/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-batch/v1/package.json b/owl-bot-staging/google-cloud-batch/v1/package.json deleted file mode 100644 index ca54def4a50..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/batch", - "version": "0.1.0", - "description": "Batch client for Node.js", - "repository": "googleapis/nodejs-batch", - "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 batch", - "batch", - "batch service" - ], - "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-batch/v1/protos/google/cloud/batch/v1/batch.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto deleted file mode 100644 index 1fa330088f6..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,273 +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.batch.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/batch/v1/job.proto"; -import "google/cloud/batch/v1/task.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; -option java_multiple_files = true; -option java_outer_classname = "BatchProto"; -option java_package = "com.google.cloud.batch.v1"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1"; -option ruby_package = "Google::Cloud::Batch::V1"; - -// Google Batch Service. -// The service manages user submitted batch jobs and allocates Google Compute -// Engine VM instances to run the jobs. -service BatchService { - option (google.api.default_host) = "batch.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Create a Job. - rpc CreateJob(CreateJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/jobs" - body: "job" - }; - option (google.api.method_signature) = "parent,job,job_id"; - } - - // Get a Job specified by its resource name. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Delete a Job. - rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.batch.v1.OperationMetadata" - }; - } - - // List all Jobs for a project within a region. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Return a single Task. - rpc GetTask(GetTaskRequest) returns (Task) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/jobs/*/taskGroups/*/tasks/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List Tasks associated with a job. - rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/jobs/*/taskGroups/*}/tasks" - }; - option (google.api.method_signature) = "parent"; - } -} - -// CreateJob Request. -message CreateJobRequest { - // Required. The parent resource name where the Job will be created. - // Pattern: "projects/{project}/locations/{location}" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "batch.googleapis.com/Job" - } - ]; - - // ID used to uniquely identify the Job within its parent scope. - // This field should contain at most 63 characters and must start with - // lowercase characters. - // Only lowercase characters, numbers and '-' are accepted. - // The '-' character cannot be the first or the last one. - // A system generated ID will be used if the field is not set. - // - // The job.name field in the request will be ignored and the created resource - // name of the Job will be "{parent}/jobs/{job_id}". - string job_id = 2; - - // Required. The Job to create. - Job job = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An optional request ID to identify requests. Specify a unique request ID - // so that if you must retry your request, the server will know to ignore - // the request if it has already been completed. The server will guarantee - // that for at least 60 minutes since the first request. - // - // For example, consider a situation where you make an initial request and t - // he request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// GetJob Request. -message GetJobRequest { - // Required. Job name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "batch.googleapis.com/Job" - } - ]; -} - -// DeleteJob Request. -message DeleteJobRequest { - // Job name. - string name = 1; - - // Optional. Reason for this deletion. - string reason = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. An optional request ID to identify requests. Specify a unique request ID - // so that if you must retry your request, the server will know to ignore - // the request if it has already been completed. The server will guarantee - // that for at least 60 minutes after the first request. - // - // For example, consider a situation where you make an initial request and t - // he request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// ListJob Request. -message ListJobsRequest { - // Parent path. - string parent = 1; - - // List filter. - string filter = 4; - - // Page size. - int32 page_size = 2; - - // Page token. - string page_token = 3; -} - -// ListJob Response. -message ListJobsResponse { - // Jobs. - repeated Job jobs = 1; - - // Next page token. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// ListTasks Request. -message ListTasksRequest { - // Required. Name of a TaskGroup from which Tasks are being requested. - // Pattern: - // "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "batch.googleapis.com/TaskGroup" - } - ]; - - // Task filter, null filter matches all Tasks. - // Filter string should be of the format State=TaskStatus.State e.g. - // State=RUNNING - string filter = 2; - - // Page size. - int32 page_size = 3; - - // Page token. - string page_token = 4; -} - -// ListTasks Response. -message ListTasksResponse { - // Tasks. - repeated Task tasks = 1; - - // Next page token. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for a single Task by name. -message GetTaskRequest { - // Required. Task name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "batch.googleapis.com/Task" - } - ]; -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // Output only. The time the operation was created. - google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the operation finished running. - google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server-defined resource path for the target of the operation. - string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the verb executed by the operation. - string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Human-readable status of the operation, if any. - string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. - bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. API version used to start the operation. - string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto deleted file mode 100644 index be86dbf8cad..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,475 +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.batch.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/batch/v1/task.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.batch.v1"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1"; -option ruby_package = "Google::Cloud::Batch::V1"; - -// The Cloud Batch Job description. -message Job { - option (google.api.resource) = { - type: "batch.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - }; - - // Output only. Job name. - // For example: "projects/123456/locations/us-central1/jobs/job01". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system generated unique ID (in UUID4 format) for the Job. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Priority of the Job. - // The valid value range is [0, 100). - // A job with higher priority value is more likely to run earlier if all other - // requirements are satisfied. - int64 priority = 3; - - // Required. TaskGroups in the Job. Only one TaskGroup is supported now. - repeated TaskGroup task_groups = 4 [(google.api.field_behavior) = REQUIRED]; - - // Compute resource allocation for all TaskGroups in the Job. - AllocationPolicy allocation_policy = 7; - - // Labels for the Job. Labels could be user provided or system generated. - // For example, - // "labels": { - // "department": "finance", - // "environment": "test" - // } - // You can assign up to 64 labels. [Google Compute Engine label - // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) - // apply. - // Label names that start with "goog-" or "google-" are reserved. - map labels = 8; - - // Output only. Job status. It is read only for users. - JobStatus status = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. When the Job was created. - google.protobuf.Timestamp create_time = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last time the Job was updated. - google.protobuf.Timestamp update_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Log preservation policy for the Job. - LogsPolicy logs_policy = 13; - - // Notification configurations. - repeated JobNotification notifications = 14; -} - -// LogsPolicy describes how outputs from a Job's Tasks (stdout/stderr) will be -// preserved. -message LogsPolicy { - // The destination (if any) for logs. - enum Destination { - // Logs are not preserved. - DESTINATION_UNSPECIFIED = 0; - - // Logs are streamed to Cloud Logging. - CLOUD_LOGGING = 1; - - // Logs are saved to a file path. - PATH = 2; - } - - // Where logs should be saved. - Destination destination = 1; - - // The path to which logs are saved when the destination = PATH. This can be a - // local file path on the VM, or under the mount point of a Persistent Disk or - // Filestore, or a Cloud Storage path. - string logs_path = 2; -} - -// Job status. -message JobStatus { - // VM instance status. - message InstanceStatus { - // The Compute Engine machine type. - string machine_type = 1; - - // The VM instance provisioning model. - AllocationPolicy.ProvisioningModel provisioning_model = 2; - - // The max number of tasks can be assigned to this instance type. - int64 task_pack = 3; - } - - // Aggregated task status for a TaskGroup. - message TaskGroupStatus { - // Count of task in each state in the TaskGroup. - // The map key is task state name. - map counts = 1; - - // Status of instances allocated for the TaskGroup. - repeated InstanceStatus instances = 2; - } - - // Valid Job states. - enum State { - STATE_UNSPECIFIED = 0; - - // Job is admitted (validated and persisted) and waiting for resources. - QUEUED = 1; - - // Job is scheduled to run as soon as resource allocation is ready. - // The resource allocation may happen at a later time but with a high - // chance to succeed. - SCHEDULED = 2; - - // Resource allocation has been successful. At least one Task in the Job is - // RUNNING. - RUNNING = 3; - - // All Tasks in the Job have finished successfully. - SUCCEEDED = 4; - - // At least one Task in the Job has failed. - FAILED = 5; - - // The Job will be deleted, but has not been deleted yet. Typically this is - // because resources used by the Job are still being cleaned up. - DELETION_IN_PROGRESS = 6; - } - - // Job state - State state = 1; - - // Job status events - repeated StatusEvent status_events = 2; - - // Aggregated task status for each TaskGroup in the Job. - // The map key is TaskGroup ID. - map task_groups = 4; - - // The duration of time that the Job spent in status RUNNING. - google.protobuf.Duration run_duration = 5; -} - -// Notification configurations. -message JobNotification { - // Message details. - // Describe the attribute that a message should have. - // Without specified message attributes, no message will be sent by default. - message Message { - // The message type. - Type type = 1; - - // The new job state. - JobStatus.State new_job_state = 2; - - // The new task state. - TaskStatus.State new_task_state = 3; - } - - // The message type. - enum Type { - // Unspecified. - TYPE_UNSPECIFIED = 0; - - // Notify users that the job state has changed. - JOB_STATE_CHANGED = 1; - - // Notify users that the task state has changed. - TASK_STATE_CHANGED = 2; - } - - // The Pub/Sub topic where notifications like the job state changes - // will be published. This topic exist in the same project as the job - // and billings will be charged to this project. - // If not specified, no Pub/Sub messages will be sent. - // Topic format: `projects/{project}/topics/{topic}`. - string pubsub_topic = 1; - - // The attribute requirements of messages to be sent to this Pub/Sub topic. - // Without this field, no message will be sent. - Message message = 2; -} - -// A Job's resource allocation policy describes when, where, and how compute -// resources should be allocated for the Job. -message AllocationPolicy { - message LocationPolicy { - // A list of allowed location names represented by internal URLs. - // Each location can be a region or a zone. - // Only one region or multiple zones in one region is supported now. - // For example, - // ["regions/us-central1"] allow VMs in any zones in region us-central1. - // ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs - // in zones us-central1-a and us-central1-c. - // All locations end up in different regions would cause errors. - // For example, - // ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", - // "zones/us-west1-a"] contains 2 regions "us-central1" and - // "us-west1". An error is expected in this case. - repeated string allowed_locations = 1; - } - - // A new persistent disk or a local ssd. - // A VM can only have one local SSD setting but multiple local SSD partitions. - // https://cloud.google.com/compute/docs/disks#pdspecs. - // https://cloud.google.com/compute/docs/disks#localssds. - message Disk { - // A data source from which a PD will be created. - oneof data_source { - // Name of a public or custom image used as the data source. - string image = 4; - - // Name of a snapshot used as the data source. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list` - // For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd". - string type = 1; - - // Disk size in GB. - // This field is ignored if `data_source` is `disk` or `image`. - // If `type` is `local-ssd`, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - int64 size_gb = 2; - - // Local SSDs are available through both "SCSI" and "NVMe" interfaces. - // If not indicated, "NVMe" will be the default one for local ssds. - // We only support "SCSI" for persistent disks now. - string disk_interface = 6; - } - - // A new or an existing persistent disk (PD) or a local ssd attached to a VM - // instance. - message AttachedDisk { - oneof attached { - Disk new_disk = 1; - - // Name of an existing PD. - string existing_disk = 2; - } - - // Device name that the guest operating system will see. - // It is used by Runnable.volumes field to mount disks. So please specify - // the device_name if you want Batch to help mount the disk, and it should - // match the device_name field in volumes. - string device_name = 3; - } - - // Accelerator describes Compute Engine accelerators to be attached to the VM. - message Accelerator { - // The accelerator type. For example, "nvidia-tesla-t4". - // See `gcloud compute accelerator-types list`. - string type = 1; - - // The number of accelerators of this type. - int64 count = 2; - - // Deprecated: please use instances[0].install_gpu_drivers instead. - bool install_gpu_drivers = 3 [deprecated = true]; - } - - // InstancePolicy describes an instance type and resources attached to each VM - // created by this InstancePolicy. - message InstancePolicy { - // The Compute Engine machine type. - string machine_type = 2; - - // The minimum CPU platform. - // See - // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. - // Not yet implemented. - string min_cpu_platform = 3; - - // The provisioning model. - ProvisioningModel provisioning_model = 4; - - // The accelerators attached to each VM instance. - repeated Accelerator accelerators = 5; - - // Non-boot disks to be attached for each VM created by this InstancePolicy. - // New disks will be deleted when the VM is deleted. - repeated AttachedDisk disks = 6; - } - - // Either an InstancePolicy or an instance template. - message InstancePolicyOrTemplate { - oneof policy_template { - // InstancePolicy. - InstancePolicy policy = 1; - - // Name of an instance template used to create VMs. - // Named the field as 'instance_template' instead of 'template' to avoid - // c++ keyword conflict. - string instance_template = 2; - } - - // Set this field true if users want Batch to help fetch drivers from a - // third party location and install them for GPUs specified in - // policy.accelerators or instance_template on their behalf. Default is - // false. - bool install_gpu_drivers = 3; - } - - // A network interface. - message NetworkInterface { - // The URL of an existing network resource. - // You can specify the network as a full or partial URL. - // For example, the following are all valid URLs: - // https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} - // projects/{project}/global/networks/{network} - // global/networks/{network} - string network = 1; - - // The URL of an existing subnetwork resource in the network. - // You can specify the subnetwork as a full or partial URL. - // For example, the following are all valid URLs: - // https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork} - // projects/{project}/regions/{region}/subnetworks/{subnetwork} - // regions/{region}/subnetworks/{subnetwork} - string subnetwork = 2; - - // Default is false (with an external IP address). Required if - // no external public IP address is attached to the VM. If no external - // public IP address, additional configuration is required to allow the VM - // to access Google Services. See - // https://cloud.google.com/vpc/docs/configure-private-google-access and - // https://cloud.google.com/nat/docs/gce-example#create-nat for more - // information. - bool no_external_ip_address = 3; - } - - // NetworkPolicy describes VM instance network configurations. - message NetworkPolicy { - // Network configurations. - repeated NetworkInterface network_interfaces = 1; - } - - // Compute Engine VM instance provisioning model. - enum ProvisioningModel { - // Unspecified. - PROVISIONING_MODEL_UNSPECIFIED = 0; - - // Standard VM. - STANDARD = 1; - - // SPOT VM. - SPOT = 2; - - // Preemptible VM (PVM). - // - // Above SPOT VM is the preferable model for preemptible VM instances: the - // old preemptible VM model (indicated by this field) is the older model, - // and has been migrated to use the SPOT model as the underlying technology. - // This old model will still be supported. - PREEMPTIBLE = 3; - } - - // Location where compute resources should be allocated for the Job. - LocationPolicy location = 1; - - // Describe instances that can be created by this AllocationPolicy. - // Only instances[0] is supported now. - repeated InstancePolicyOrTemplate instances = 8; - - // Service account that VMs will run as. - ServiceAccount service_account = 9; - - // Labels applied to all VM instances and other resources - // created by AllocationPolicy. - // Labels could be user provided or system generated. - // You can assign up to 64 labels. [Google Compute Engine label - // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) - // apply. - // Label names that start with "goog-" or "google-" are reserved. - map labels = 6; - - // The network policy. - NetworkPolicy network = 7; -} - -// A TaskGroup contains one or multiple Tasks that share the same -// Runnable but with different runtime parameters. -message TaskGroup { - option (google.api.resource) = { - type: "batch.googleapis.com/TaskGroup" - pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - }; - - // Output only. TaskGroup name. - // The system generates this field based on parent Job name. - // For example: - // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Tasks in the group share the same task spec. - TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; - - // Number of Tasks in the TaskGroup. - // default is 1 - int64 task_count = 4; - - // Max number of tasks that can run in parallel. - // Default to min(task_count, 1000). - int64 parallelism = 5; - - // An array of environment variable mappings, which are passed to Tasks with - // matching indices. If task_environments is used then task_count should - // not be specified in the request (and will be ignored). Task count will be - // the length of task_environments. - // - // Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in - // addition to any environment variables set in task_environments, specifying - // the number of Tasks in the Task's parent TaskGroup, and the specific Task's - // index in the TaskGroup (0 through BATCH_TASK_COUNT - 1). - // - // task_environments supports up to 200 entries. - repeated Environment task_environments = 9; - - // Max number of tasks that can be run on a VM at the same time. - // If not specified, the system will decide a value based on available - // compute resources on a VM and task requirements. - int64 task_count_per_node = 10; - - // When true, Batch will populate a file with a list of all VMs assigned to - // the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path - // of that file. Defaults to false. - bool require_hosts_file = 11; - - // When true, Batch will configure SSH to allow passwordless login between - // VMs running the Batch tasks in the same TaskGroup. - bool permissive_ssh = 12; -} - -// Carries information about a Google Cloud service account. -message ServiceAccount { - // Email address of the service account. If not specified, the default - // Compute Engine service account for the project will be used. If instance - // template is being used, the service account has to be specified in the - // instance template and it has to match the email field here. - string email = 1; -} diff --git a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto deleted file mode 100644 index 1085bfcb083..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,313 +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.batch.v1; - -import "google/api/resource.proto"; -import "google/cloud/batch/v1/volume.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; -option java_multiple_files = true; -option java_outer_classname = "TaskProto"; -option java_package = "com.google.cloud.batch.v1"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1"; -option ruby_package = "Google::Cloud::Batch::V1"; - -// Compute resource requirements -message ComputeResource { - // The milliCPU count. - int64 cpu_milli = 1; - - // Memory in MiB. - int64 memory_mib = 2; - - // Extra boot disk size in MiB for each task. - int64 boot_disk_mib = 4; -} - -// Status event -message StatusEvent { - // Type of the event. - string type = 3; - - // Description of the event. - string description = 1; - - // The time this event occurred. - google.protobuf.Timestamp event_time = 2; - - // Task Execution - TaskExecution task_execution = 4; -} - -// This Task Execution field includes detail information for -// task execution procedures, based on StatusEvent types. -message TaskExecution { - // When task is completed as the status of FAILED or SUCCEEDED, - // exit code is for one task execution result, default is 0 as success. - int32 exit_code = 1; -} - -// Status of a task -message TaskStatus { - // Task states. - enum State { - // unknown state - STATE_UNSPECIFIED = 0; - - // The Task is created and waiting for resources. - PENDING = 1; - - // The Task is assigned to at least one VM. - ASSIGNED = 2; - - // The Task is running. - RUNNING = 3; - - // The Task has failed. - FAILED = 4; - - // The Task has succeeded. - SUCCEEDED = 5; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; -} - -// Runnable describes instructions for executing a specific script or container -// as part of a Task. -message Runnable { - // Container runnable. - message Container { - // The URI to pull the container image from. - string image_uri = 1; - - // Overrides the `CMD` specified in the container. If there is an ENTRYPOINT - // (either in the container image or with the entrypoint field below) then - // commands are appended as arguments to the ENTRYPOINT. - repeated string commands = 2; - - // Overrides the `ENTRYPOINT` specified in the container. - string entrypoint = 3; - - // Volumes to mount (bind mount) from the host machine files or directories - // into the container, formatted to match docker run's --volume option, - // e.g. /foo:/bar, or /foo:/bar:ro - repeated string volumes = 7; - - // Arbitrary additional options to include in the "docker run" command when - // running this container, e.g. "--network host". - string options = 8; - - // If set to true, external network access to and from container will be - // blocked. The container will use the default internal network - // 'goog-internal'. - bool block_external_network = 9; - - // Optional username for logging in to a docker registry. If username - // matches `projects/*/secrets/*/versions/*` then Batch will read the - // username from the Secret Manager. - string username = 10; - - // Optional password for logging in to a docker registry. If password - // matches `projects/*/secrets/*/versions/*` then Batch will read the - // password from the Secret Manager; - string password = 11; - } - - // Script runnable. - message Script { - oneof command { - // Script file path on the host VM. - string path = 1; - - // Shell script text. - string text = 2; - } - } - - // Barrier runnable blocks until all tasks in a taskgroup reach it. - message Barrier { - // Barriers are identified by their index in runnable list. - // Names are not required, but if present should be an identifier. - string name = 1; - } - - // The script or container to run. - oneof executable { - // Container runnable. - Container container = 1; - - // Script runnable. - Script script = 2; - - // Barrier runnable. - Barrier barrier = 6; - } - - // Normally, a non-zero exit status causes the Task to fail. This flag allows - // execution of other Runnables to continue instead. - bool ignore_exit_status = 3; - - // This flag allows a Runnable to continue running in the background while the - // Task executes subsequent Runnables. This is useful to provide services to - // other Runnables (or to provide debugging support tools like SSH servers). - bool background = 4; - - // By default, after a Runnable fails, no further Runnable are executed. This - // flag indicates that this Runnable must be run even if the Task has already - // failed. This is useful for Runnables that copy output files off of the VM - // or for debugging. - // - // The always_run flag does not override the Task's overall max_run_duration. - // If the max_run_duration has expired then no further Runnables will execute, - // not even always_run Runnables. - bool always_run = 5; - - // Environment variables for this Runnable (overrides variables set for the - // whole Task or TaskGroup). - Environment environment = 7; - - // Timeout for this Runnable. - google.protobuf.Duration timeout = 8; -} - -// Spec of a task -message TaskSpec { - // The sequence of scripts or containers to run for this Task. Each Task using - // this TaskSpec executes its list of runnables in order. The Task succeeds if - // all of its runnables either exit with a zero status or any that exit with a - // non-zero status have the ignore_exit_status flag. - // - // Background runnables are killed automatically (if they have not already - // exited) a short time after all foreground runnables have completed. Even - // though this is likely to result in a non-zero exit status for the - // background runnable, these automatic kills are not treated as Task - // failures. - repeated Runnable runnables = 8; - - // ComputeResource requirements. - ComputeResource compute_resource = 3; - - // Maximum duration the task should run. - // The task will be killed and marked as FAILED if over this limit. - google.protobuf.Duration max_run_duration = 4; - - // Maximum number of retries on failures. - // The default, 0, which means never retry. - // The valid value range is [0, 10]. - int32 max_retry_count = 5; - - // Lifecycle management schema when any task in a task group is failed. - // The valid size of lifecycle policies are [0, 10]. - // For each lifecycle policy, when the condition is met, - // the action in that policy will execute. - // If there are multiple policies that the task execution result matches, - // we use the action from the first matched policy. If task execution result - // does not meet with any of the defined lifecycle policy, we consider it as - // the default policy. Default policy means if the exit code is 0, exit task. - // If task ends with non-zero exit code, retry the task with max_retry_count. - repeated LifecyclePolicy lifecycle_policies = 9; - - // Deprecated: please use environment(non-plural) instead. - map environments = 6 [deprecated = true]; - - // Volumes to mount before running Tasks using this TaskSpec. - repeated Volume volumes = 7; - - // Environment variables to set before running the Task. - Environment environment = 10; -} - -// LifecyclePolicy describes how to deal with task failures -// based on different conditions. -message LifecyclePolicy { - // Conditions for actions to deal with task failures. - message ActionCondition { - // Exit codes of a task execution. - // If there are more than 1 exit codes, - // when task executes with any of the exit code in the list, - // the condition is met and the action will be executed. - repeated int32 exit_codes = 1; - } - - // Action on task failures based on different conditions. - enum Action { - // Action unspecified. - ACTION_UNSPECIFIED = 0; - - // Action that tasks in the group will be scheduled to re-execute. - RETRY_TASK = 1; - - // Action that tasks in the group will be stopped immediately. - FAIL_TASK = 2; - } - - // Action to execute when ActionCondition is true. - Action action = 1; - - // Conditions that decide why a task failure is dealt with a specific action. - ActionCondition action_condition = 2; -} - -// A Cloud Batch task. -message Task { - option (google.api.resource) = { - type: "batch.googleapis.com/Task" - pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}" - }; - - // Task name. - // The name is generated from the parent TaskGroup name and 'id' field. - // For example: - // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01/tasks/task01". - string name = 1; - - // Task Status. - TaskStatus status = 2; -} - -// An Environment describes a collection of environment variables to set when -// executing Tasks. -message Environment { - message KMSEnvMap { - // The name of the KMS key that will be used to decrypt the cipher text. - string key_name = 1; - - // The value of the cipherText response from the `encrypt` method. - string cipher_text = 2; - } - - // A map of environment variable names to values. - map variables = 1; - - // A map of environment variable names to Secret Manager secret names. - // The VM will access the named secrets to set the value of each environment - // variable. - map secret_variables = 2; - - // An encrypted JSON dictionary where the key/value pairs correspond to - // environment variable names and their values. - KMSEnvMap encrypted_variables = 3; -} diff --git a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto deleted file mode 100644 index 7b6ebac48fb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +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.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1;batch"; -option java_multiple_files = true; -option java_outer_classname = "VolumeProto"; -option java_package = "com.google.cloud.batch.v1"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1"; -option ruby_package = "Google::Cloud::Batch::V1"; - -// Volume describes a volume and parameters for it to be mounted to a VM. -message Volume { - // The source for the volume. - oneof source { - // A Network File System (NFS) volume. For example, a - // Filestore file share. - NFS nfs = 1; - - // A Google Cloud Storage (GCS) volume. - GCS gcs = 3; - - // Device name of an attached disk volume, which should align with a - // device_name specified by - // job.allocation_policy.instances[0].policy.disks[i].device_name or - // defined by the given instance template in - // job.allocation_policy.instances[0].instance_template. - string device_name = 6; - } - - // The mount path for the volume, e.g. /mnt/disks/share. - string mount_path = 4; - - // For Google Cloud Storage (GCS), mount options are the options supported by - // the gcsfuse tool (https://github.com/GoogleCloudPlatform/gcsfuse). - // For existing persistent disks, mount options provided by the - // mount command (https://man7.org/linux/man-pages/man8/mount.8.html) except - // writing are supported. This is due to restrictions of multi-writer mode - // (https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms). - // For other attached disks and Network File System (NFS), mount options are - // these supported by the mount command - // (https://man7.org/linux/man-pages/man8/mount.8.html). - repeated string mount_options = 5; -} - -// Represents an NFS volume. -message NFS { - // The IP address of the NFS. - string server = 1; - - // Remote source path exported from the NFS, e.g., "/share". - string remote_path = 2; -} - -// Represents a Google Cloud Storage volume. -message GCS { - // Remote path, either a bucket name or a subdirectory of a bucket, e.g.: - // bucket_name, bucket_name/subdirectory/ - string remote_path = 1; -} diff --git a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js deleted file mode 100644 index 4de994b2f73..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.create_job.js +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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, job) { - // [START batch_v1_generated_BatchService_CreateJob_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 where the Job will be created. - * Pattern: "projects/{project}/locations/{location}" - */ - // const parent = 'abc123' - /** - * ID used to uniquely identify the Job within its parent scope. - * This field should contain at most 63 characters and must start with - * lowercase characters. - * Only lowercase characters, numbers and '-' are accepted. - * The '-' character cannot be the first or the last one. - * A system generated ID will be used if the field is not set. - * The job.name field in the request will be ignored and the created resource - * name of the Job will be "{parent}/jobs/{job_id}". - */ - // const jobId = 'abc123' - /** - * Required. The Job to create. - */ - // const job = {} - /** - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - }; - - // Run request - const response = await batchClient.createJob(request); - console.log(response); - } - - callCreateJob(); - // [END batch_v1_generated_BatchService_CreateJob_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-batch/v1/samples/generated/v1/batch_service.delete_job.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.delete_job.js deleted file mode 100644 index e19a6808169..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.delete_job.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batch_v1_generated_BatchService_DeleteJob_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. - */ - /** - * Job name. - */ - // const name = 'abc123' - /** - * Optional. Reason for this deletion. - */ - // const reason = 'abc123' - /** - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callDeleteJob() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await batchClient.deleteJob(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteJob(); - // [END batch_v1_generated_BatchService_DeleteJob_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-batch/v1/samples/generated/v1/batch_service.get_job.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_job.js deleted file mode 100644 index c45a5b7f46d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_job.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batch_v1_generated_BatchService_GetJob_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. Job name. - */ - // const name = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await batchClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END batch_v1_generated_BatchService_GetJob_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-batch/v1/samples/generated/v1/batch_service.get_task.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_task.js deleted file mode 100644 index 12a0c45a2a5..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.get_task.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batch_v1_generated_BatchService_GetTask_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. Task name. - */ - // const name = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callGetTask() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await batchClient.getTask(request); - console.log(response); - } - - callGetTask(); - // [END batch_v1_generated_BatchService_GetTask_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-batch/v1/samples/generated/v1/batch_service.list_jobs.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_jobs.js deleted file mode 100644 index 10807d04141..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_jobs.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batch_v1_generated_BatchService_ListJobs_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. - */ - /** - * Parent path. - */ - // const parent = 'abc123' - /** - * List filter. - */ - // const filter = 'abc123' - /** - * Page size. - */ - // const pageSize = 1234 - /** - * Page token. - */ - // const pageToken = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callListJobs() { - // Construct request - const request = { - }; - - // Run request - const iterable = await batchClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END batch_v1_generated_BatchService_ListJobs_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-batch/v1/samples/generated/v1/batch_service.list_tasks.js b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_tasks.js deleted file mode 100644 index 2c53d7f22ce..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/batch_service.list_tasks.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batch_v1_generated_BatchService_ListTasks_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. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - */ - // const parent = 'abc123' - /** - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - */ - // const filter = 'abc123' - /** - * Page size. - */ - // const pageSize = 1234 - /** - * Page token. - */ - // const pageToken = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callListTasks() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await batchClient.listTasksAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTasks(); - // [END batch_v1_generated_BatchService_ListTasks_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-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json b/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json deleted file mode 100644 index 78e8ef02681..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json +++ /dev/null @@ -1,299 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-batch", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.batch.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "batch_v1_generated_BatchService_CreateJob_async", - "title": "BatchService createJob Sample", - "origin": "API_DEFINITION", - "description": " Create a Job.", - "canonical": true, - "file": "batch_service.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 84, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.batch.v1.BatchService.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job_id", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.batch.v1.Job" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1.Job", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1.BatchServiceClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.batch.v1.BatchService.CreateJob", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1_generated_BatchService_GetJob_async", - "title": "BatchService getJob Sample", - "origin": "API_DEFINITION", - "description": " Get a Job specified by its resource name.", - "canonical": true, - "file": "batch_service.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.batch.v1.BatchService.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1.Job", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1.BatchServiceClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.batch.v1.BatchService.GetJob", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1_generated_BatchService_DeleteJob_async", - "title": "BatchService deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Delete a Job.", - "canonical": true, - "file": "batch_service.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.batch.v1.BatchService.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "reason", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1.BatchServiceClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.batch.v1.BatchService.DeleteJob", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1_generated_BatchService_ListJobs_async", - "title": "BatchService listJobs Sample", - "origin": "API_DEFINITION", - "description": " List all Jobs for a project within a region.", - "canonical": true, - "file": "batch_service.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.batch.v1.BatchService.ListJobs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1.ListJobsResponse", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1.BatchServiceClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.batch.v1.BatchService.ListJobs", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1_generated_BatchService_GetTask_async", - "title": "BatchService getTask Sample", - "origin": "API_DEFINITION", - "description": " Return a single Task.", - "canonical": true, - "file": "batch_service.get_task.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTask", - "fullName": "google.cloud.batch.v1.BatchService.GetTask", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1.Task", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1.BatchServiceClient" - }, - "method": { - "shortName": "GetTask", - "fullName": "google.cloud.batch.v1.BatchService.GetTask", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1_generated_BatchService_ListTasks_async", - "title": "BatchService listTasks Sample", - "origin": "API_DEFINITION", - "description": " List Tasks associated with a job.", - "canonical": true, - "file": "batch_service.list_tasks.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTasks", - "fullName": "google.cloud.batch.v1.BatchService.ListTasks", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1.ListTasksResponse", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1.BatchServiceClient" - }, - "method": { - "shortName": "ListTasks", - "fullName": "google.cloud.batch.v1.BatchService.ListTasks", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1.BatchService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/index.ts b/owl-bot-staging/google-cloud-batch/v1/src/index.ts deleted file mode 100644 index 1026aa0e2b6..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 BatchServiceClient = v1.BatchServiceClient; -type BatchServiceClient = v1.BatchServiceClient; -export {v1, BatchServiceClient}; -export default {v1, BatchServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts deleted file mode 100644 index 64e8c3f492a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1743 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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, IamClient, IamProtos, 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/batch_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './batch_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Google Batch Service. - * The service manages user submitted batch jobs and allocates Google Compute - * Engine VM instances to run the jobs. - * @class - * @memberof v1 - */ -export class BatchServiceClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - batchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of BatchServiceClient. - * - * @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 BatchServiceClient({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 BatchServiceClient; - 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 = { - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}' - ), - taskGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}' - ), - }; - - // 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 = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs'), - listTasks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') - }; - - 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.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/jobs/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/jobs/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/jobs/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{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 deleteJobResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteJobMetadata = protoFilesRoot.lookup( - '.google.cloud.batch.v1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - deleteJob: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteJobResponse.decode.bind(deleteJobResponse), - deleteJobMetadata.decode.bind(deleteJobMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.batch.v1.BatchService', 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.batchServiceStub) { - return this.batchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.batch.v1.BatchService. - this.batchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.batch.v1.BatchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.batch.v1.BatchService, - 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 batchServiceStubMethods = - ['createJob', 'getJob', 'deleteJob', 'listJobs', 'getTask', 'listTasks']; - for (const methodName of batchServiceStubMethods) { - const callPromise = this.batchServiceStub.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.batchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'batch.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 'batch.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 -- - // ------------------- -/** - * Create a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name where the Job will be created. - * Pattern: "projects/{project}/locations/{location}" - * @param {string} request.jobId - * ID used to uniquely identify the Job within its parent scope. - * This field should contain at most 63 characters and must start with - * lowercase characters. - * Only lowercase characters, numbers and '-' are accepted. - * The '-' character cannot be the first or the last one. - * A system generated ID will be used if the field is not set. - * - * The job.name field in the request will be ignored and the created resource - * name of the Job will be "{parent}/jobs/{job_id}". - * @param {google.cloud.batch.v1.Job} request.job - * Required. The Job to create. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 [Job]{@link google.cloud.batch.v1.Job}. - * 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/batch_service.create_job.js - * region_tag:batch_v1_generated_BatchService_CreateJob_async - */ - createJob( - request?: protos.google.cloud.batch.v1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.ICreateJobRequest|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.batch.v1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.batch.v1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.batch.v1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.ICreateJobRequest|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.createJob(request, options, callback); - } -/** - * Get a Job specified by its resource name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Job 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 [Job]{@link google.cloud.batch.v1.Job}. - * 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/batch_service.get_job.js - * region_tag:batch_v1_generated_BatchService_GetJob_async - */ - getJob( - request?: protos.google.cloud.batch.v1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.batch.v1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.batch.v1.IGetJobRequest, - callback: Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.batch.v1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.batch.v1.IJob, - protos.google.cloud.batch.v1.IGetJobRequest|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.getJob(request, options, callback); - } -/** - * Return a single Task. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Task 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 [Task]{@link google.cloud.batch.v1.Task}. - * 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/batch_service.get_task.js - * region_tag:batch_v1_generated_BatchService_GetTask_async - */ - getTask( - request?: protos.google.cloud.batch.v1.IGetTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1.ITask, - protos.google.cloud.batch.v1.IGetTaskRequest|undefined, {}|undefined - ]>; - getTask( - request: protos.google.cloud.batch.v1.IGetTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.batch.v1.ITask, - protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; - getTask( - request: protos.google.cloud.batch.v1.IGetTaskRequest, - callback: Callback< - protos.google.cloud.batch.v1.ITask, - protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; - getTask( - request?: protos.google.cloud.batch.v1.IGetTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.batch.v1.ITask, - protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.batch.v1.ITask, - protos.google.cloud.batch.v1.IGetTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.batch.v1.ITask, - protos.google.cloud.batch.v1.IGetTaskRequest|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.getTask(request, options, callback); - } - -/** - * Delete a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Job name. - * @param {string} [request.reason] - * Optional. Reason for this deletion. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/batch_service.delete_job.js - * region_tag:batch_v1_generated_BatchService_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.batch.v1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.batch.v1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.batch.v1.IDeleteJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.batch.v1.IDeleteJobRequest, - 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.deleteJob(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteJob()`. - * @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/batch_service.delete_job.js - * region_tag:batch_v1_generated_BatchService_DeleteJob_async - */ - async checkDeleteJobProgress(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.deleteJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List all Jobs for a project within a region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Parent path. - * @param {string} request.filter - * List filter. - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Job]{@link google.cloud.batch.v1.Job}. - * 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 `listJobsAsync()` - * 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. - */ - listJobs( - request?: protos.google.cloud.batch.v1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1.IJob[], - protos.google.cloud.batch.v1.IListJobsRequest|null, - protos.google.cloud.batch.v1.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.batch.v1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.batch.v1.IListJobsRequest, - protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1.IJob>): void; - listJobs( - request: protos.google.cloud.batch.v1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.batch.v1.IListJobsRequest, - protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1.IJob>): void; - listJobs( - request?: protos.google.cloud.batch.v1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.batch.v1.IListJobsRequest, - protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1.IJob>, - callback?: PaginationCallback< - protos.google.cloud.batch.v1.IListJobsRequest, - protos.google.cloud.batch.v1.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1.IJob>): - Promise<[ - protos.google.cloud.batch.v1.IJob[], - protos.google.cloud.batch.v1.IListJobsRequest|null, - protos.google.cloud.batch.v1.IListJobsResponse - ]>|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.listJobs(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 - * Parent path. - * @param {string} request.filter - * List filter. - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Job]{@link google.cloud.batch.v1.Job} 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 `listJobsAsync()` - * 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. - */ - listJobsStream( - request?: protos.google.cloud.batch.v1.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listJobs`, 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 - * Parent path. - * @param {string} request.filter - * List filter. - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * 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 - * [Job]{@link google.cloud.batch.v1.Job}. 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/batch_service.list_jobs.js - * region_tag:batch_v1_generated_BatchService_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.batch.v1.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.asyncIterate( - this.innerApiCalls['listJobs'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List Tasks associated with a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - * @param {string} request.filter - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Task]{@link google.cloud.batch.v1.Task}. - * 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 `listTasksAsync()` - * 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. - */ - listTasks( - request?: protos.google.cloud.batch.v1.IListTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1.ITask[], - protos.google.cloud.batch.v1.IListTasksRequest|null, - protos.google.cloud.batch.v1.IListTasksResponse - ]>; - listTasks( - request: protos.google.cloud.batch.v1.IListTasksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.batch.v1.IListTasksRequest, - protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1.ITask>): void; - listTasks( - request: protos.google.cloud.batch.v1.IListTasksRequest, - callback: PaginationCallback< - protos.google.cloud.batch.v1.IListTasksRequest, - protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1.ITask>): void; - listTasks( - request?: protos.google.cloud.batch.v1.IListTasksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.batch.v1.IListTasksRequest, - protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1.ITask>, - callback?: PaginationCallback< - protos.google.cloud.batch.v1.IListTasksRequest, - protos.google.cloud.batch.v1.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1.ITask>): - Promise<[ - protos.google.cloud.batch.v1.ITask[], - protos.google.cloud.batch.v1.IListTasksRequest|null, - protos.google.cloud.batch.v1.IListTasksResponse - ]>|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.listTasks(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. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - * @param {string} request.filter - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Task]{@link google.cloud.batch.v1.Task} 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 `listTasksAsync()` - * 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. - */ - listTasksStream( - request?: protos.google.cloud.batch.v1.IListTasksRequest, - 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['listTasks']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTasks.createStream( - this.innerApiCalls.listTasks as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTasks`, 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. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - * @param {string} request.filter - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * 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 - * [Task]{@link google.cloud.batch.v1.Task}. 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/batch_service.list_tasks.js - * region_tag:batch_v1_generated_BatchService_ListTasks_async - */ - listTasksAsync( - request?: protos.google.cloud.batch.v1.IListTasksRequest, - 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['listTasks']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTasks.asyncIterate( - this.innerApiCalls['listTasks'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions} - * @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/interfaces/CallOptions.html} 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 [Policy]{@link google.iam.v1.Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise { - return this.iamClient.testIamPermissions(request, options, callback); - } - -/** - * 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 job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 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 task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} task_group - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,taskGroup:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - task_group: taskGroup, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the task_group from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task_group. - */ - matchTaskGroupFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task_group; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * Return a fully-qualified taskGroup resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} task_group - * @returns {string} Resource name string. - */ - taskGroupPath(project:string,location:string,job:string,taskGroup:string) { - return this.pathTemplates.taskGroupPathTemplate.render({ - project: project, - location: location, - job: job, - task_group: taskGroup, - }); - } - - /** - * Parse the project from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).project; - } - - /** - * Parse the location from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).location; - } - - /** - * Parse the job from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).job; - } - - /** - * Parse the task_group from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the task_group. - */ - matchTaskGroupFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).task_group; - } - - /** - * 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.batchServiceStub && !this._terminated) { - return this.batchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json deleted file mode 100644 index be602f6e2eb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client_config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "interfaces": { - "google.cloud.batch.v1.BatchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateJob": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteJob": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListJobs": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "GetTask": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListTasks": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json deleted file mode 100644 index d9013a506a2..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/batch/v1/batch.proto", - "../../protos/google/cloud/batch/v1/job.proto", - "../../protos/google/cloud/batch/v1/task.proto", - "../../protos/google/cloud/batch/v1/volume.proto" -] diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 914e910ca19..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.batch.v1", - "libraryPackage": "@google-cloud/batch", - "services": { - "BatchService": { - "clients": { - "grpc": { - "libraryClient": "BatchServiceClient", - "rpcs": { - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "GetJob": { - "methods": [ - "getJob" - ] - }, - "GetTask": { - "methods": [ - "getTask" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - }, - "ListTasks": { - "methods": [ - "listTasks", - "listTasksStream", - "listTasksAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "BatchServiceClient", - "rpcs": { - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "GetJob": { - "methods": [ - "getJob" - ] - }, - "GetTask": { - "methods": [ - "getTask" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - }, - "ListTasks": { - "methods": [ - "listTasks", - "listTasksStream", - "listTasksAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts deleted file mode 100644 index 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 {BatchServiceClient} from './batch_service_client'; diff --git a/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batch = require('@google-cloud/batch'); - -function main() { - const batchServiceClient = new batch.BatchServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 {BatchServiceClient} from '@google-cloud/batch'; - -// check that the client class type name can be used -function doStuffWithBatchServiceClient(client: BatchServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const batchServiceClient = new BatchServiceClient(); - doStuffWithBatchServiceClient(batchServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-batch/v1/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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-batch/v1/test/gapic_batch_service_v1.ts b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts deleted file mode 100644 index c2d04b16459..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,2111 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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 batchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, 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.BatchServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = batchserviceModule.v1.BatchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = batchserviceModule.v1.BatchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = batchserviceModule.v1.BatchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new batchserviceModule.v1.BatchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.batchServiceStub, undefined); - await client.initialize(); - assert(client.batchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.batchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.batchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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('createJob', () => { - it('invokes createJob without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with closed client', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createJob(request), expectedError); - }); - }); - - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with closed client', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getJob(request), expectedError); - }); - }); - - describe('getTask', () => { - it('invokes getTask without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1.Task() - ); - client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); - const [response] = await client.getTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1.Task() - ); - client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTask( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTask(request), expectedError); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask with closed client', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTask(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with call error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with LRO error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteJobProgress without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - 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.checkDeleteJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteJobProgress with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - 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.checkDeleteJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobsStream without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listJobsStream with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.batch.v1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.batch.v1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listTasks', () => { - it('invokes listTasks without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); - const [response] = await client.listTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTasks( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1.ITask[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasksStream without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - ]; - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1.Task[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1.Task) => { - 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.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listTasksStream with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1.Task[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1.Task) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTasks without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1.Task()), - ]; - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.batch.v1.ITask[] = []; - const iterable = client.listTasksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTasks with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTasksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.batch.v1.ITask[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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 batchserviceModule.v1.BatchServiceClient({ - 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('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new batchserviceModule.v1.BatchServiceClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new batchserviceModule.v1.BatchServiceClient({ - 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('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - task_group: "taskGroupValue", - task: "taskValue", - }; - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "taskGroupValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskGroupFromTaskName', () => { - const result = client.matchTaskGroupFromTaskName(fakePath); - assert.strictEqual(result, "taskGroupValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('taskGroup', () => { - const fakePath = "/rendered/path/taskGroup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - task_group: "taskGroupValue", - }; - const client = new batchserviceModule.v1.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskGroupPath', () => { - const result = client.taskGroupPath("projectValue", "locationValue", "jobValue", "taskGroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskGroupName', () => { - const result = client.matchProjectFromTaskGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskGroupName', () => { - const result = client.matchLocationFromTaskGroupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskGroupName', () => { - const result = client.matchJobFromTaskGroupName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskGroupFromTaskGroupName', () => { - const result = client.matchTaskGroupFromTaskGroupName(fakePath); - assert.strictEqual(result, "taskGroupValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-batch/v1/tsconfig.json b/owl-bot-staging/google-cloud-batch/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-batch/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-batch/v1/webpack.config.js b/owl-bot-staging/google-cloud-batch/v1/webpack.config.js deleted file mode 100644 index 04a4c53960a..00000000000 --- a/owl-bot-staging/google-cloud-batch/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: 'BatchService', - filename: './batch-service.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-batch/v1alpha/.eslintignore b/owl-bot-staging/google-cloud-batch/v1alpha/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/.eslintrc.json b/owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/.gitignore b/owl-bot-staging/google-cloud-batch/v1alpha/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/.jsdoc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.jsdoc.js deleted file mode 100644 index b3e5d7c63ae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/batch', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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-batch/v1alpha/README.md b/owl-bot-staging/google-cloud-batch/v1alpha/README.md deleted file mode 100644 index 15b2fa3f3e4..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/README.md +++ /dev/null @@ -1 +0,0 @@ -Batch: Nodejs Client diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/linkinator.config.json b/owl-bot-staging/google-cloud-batch/v1alpha/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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-batch/v1alpha/package.json b/owl-bot-staging/google-cloud-batch/v1alpha/package.json deleted file mode 100644 index ca54def4a50..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/batch", - "version": "0.1.0", - "description": "Batch client for Node.js", - "repository": "googleapis/nodejs-batch", - "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 batch", - "batch", - "batch service" - ], - "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-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto deleted file mode 100644 index cc6dd16a536..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,273 +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.batch.v1alpha; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/batch/v1alpha/job.proto"; -import "google/cloud/batch/v1alpha/task.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; -option java_multiple_files = true; -option java_outer_classname = "BatchProto"; -option java_package = "com.google.cloud.batch.v1alpha"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; -option ruby_package = "Google::Cloud::Batch::V1alpha"; - -// Google Batch Service. -// The service manages user submitted batch jobs and allocates Google Compute -// Engine VM instances to run the jobs. -service BatchService { - option (google.api.default_host) = "batch.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Create a Job. - rpc CreateJob(CreateJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1alpha/{parent=projects/*/locations/*}/jobs" - body: "job" - }; - option (google.api.method_signature) = "parent,job,job_id"; - } - - // Get a Job specified by its resource name. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Delete a Job. - rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1alpha/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.batch.v1alpha.OperationMetadata" - }; - } - - // List all Jobs for a project within a region. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Return a single Task. - rpc GetTask(GetTaskRequest) returns (Task) { - option (google.api.http) = { - get: "/v1alpha/{name=projects/*/locations/*/jobs/*/taskGroups/*/tasks/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List Tasks associated with a job. - rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { - option (google.api.http) = { - get: "/v1alpha/{parent=projects/*/locations/*/jobs/*/taskGroups/*}/tasks" - }; - option (google.api.method_signature) = "parent"; - } -} - -// CreateJob Request. -message CreateJobRequest { - // Required. The parent resource name where the Job will be created. - // Pattern: "projects/{project}/locations/{location}" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "batch.googleapis.com/Job" - } - ]; - - // ID used to uniquely identify the Job within its parent scope. - // This field should contain at most 63 characters and must start with - // lowercase characters. - // Only lowercase characters, numbers and '-' are accepted. - // The '-' character cannot be the first or the last one. - // A system generated ID will be used if the field is not set. - // - // The job.name field in the request will be ignored and the created resource - // name of the Job will be "{parent}/jobs/{job_id}". - string job_id = 2; - - // Required. The Job to create. - Job job = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An optional request ID to identify requests. Specify a unique request ID - // so that if you must retry your request, the server will know to ignore - // the request if it has already been completed. The server will guarantee - // that for at least 60 minutes since the first request. - // - // For example, consider a situation where you make an initial request and t - // he request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// GetJob Request. -message GetJobRequest { - // Required. Job name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "batch.googleapis.com/Job" - } - ]; -} - -// DeleteJob Request. -message DeleteJobRequest { - // Job name. - string name = 1; - - // Optional. Reason for this deletion. - string reason = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. An optional request ID to identify requests. Specify a unique request ID - // so that if you must retry your request, the server will know to ignore - // the request if it has already been completed. The server will guarantee - // that for at least 60 minutes after the first request. - // - // For example, consider a situation where you make an initial request and t - // he request times out. If you make the request again with the same request - // ID, the server can check if original operation with the same request ID - // was received, and if so, will ignore the second request. This prevents - // clients from accidentally creating duplicate commitments. - // - // The request ID must be a valid UUID with the exception that zero UUID is - // not supported (00000000-0000-0000-0000-000000000000). - string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// ListJob Request. -message ListJobsRequest { - // Parent path. - string parent = 1; - - // List filter. - string filter = 4; - - // Page size. - int32 page_size = 2; - - // Page token. - string page_token = 3; -} - -// ListJob Response. -message ListJobsResponse { - // Jobs. - repeated Job jobs = 1; - - // Next page token. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// ListTasks Request. -message ListTasksRequest { - // Required. Name of a TaskGroup from which Tasks are being requested. - // Pattern: - // "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "batch.googleapis.com/TaskGroup" - } - ]; - - // Task filter, null filter matches all Tasks. - // Filter string should be of the format State=TaskStatus.State e.g. - // State=RUNNING - string filter = 2; - - // Page size. - int32 page_size = 3; - - // Page token. - string page_token = 4; -} - -// ListTasks Response. -message ListTasksResponse { - // Tasks. - repeated Task tasks = 1; - - // Next page token. - string next_page_token = 2; - - // Locations that could not be reached. - repeated string unreachable = 3; -} - -// Request for a single Task by name. -message GetTaskRequest { - // Required. Task name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "batch.googleapis.com/Task" - } - ]; -} - -// Represents the metadata of the long-running operation. -message OperationMetadata { - // Output only. The time the operation was created. - google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time the operation finished running. - google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Server-defined resource path for the target of the operation. - string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the verb executed by the operation. - string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Human-readable status of the operation, if any. - string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Identifies whether the user has requested cancellation - // of the operation. Operations that have successfully been cancelled - // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. - bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. API version used to start the operation. - string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto deleted file mode 100644 index 9cde8514acd..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,580 +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.batch.v1alpha; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/batch/v1alpha/task.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.batch.v1alpha"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; -option ruby_package = "Google::Cloud::Batch::V1alpha"; - -// The Cloud Batch Job description. -message Job { - option (google.api.resource) = { - type: "batch.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - }; - - // The order that TaskGroups are scheduled relative to each other. - // - // Not yet implemented. - enum SchedulingPolicy { - // Unspecified. - SCHEDULING_POLICY_UNSPECIFIED = 0; - - // Run all TaskGroups as soon as possible. - AS_SOON_AS_POSSIBLE = 1; - } - - // Output only. Job name. - // For example: "projects/123456/locations/us-central1/jobs/job01". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A system generated unique ID (in UUID4 format) for the Job. - string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Priority of the Job. - // The valid value range is [0, 100). - // A job with higher priority value is more likely to run earlier if all other - // requirements are satisfied. - int64 priority = 3; - - // Required. TaskGroups in the Job. Only one TaskGroup is supported now. - repeated TaskGroup task_groups = 4 [(google.api.field_behavior) = REQUIRED]; - - // Scheduling policy for TaskGroups in the job. - SchedulingPolicy scheduling_policy = 5; - - // At least one of the dependencies must be satisfied before the Job is - // scheduled to run. - // Only one JobDependency is supported now. - // Not yet implemented. - repeated JobDependency dependencies = 6; - - // Compute resource allocation for all TaskGroups in the Job. - AllocationPolicy allocation_policy = 7; - - // Labels for the Job. Labels could be user provided or system generated. - // For example, - // "labels": { - // "department": "finance", - // "environment": "test" - // } - // You can assign up to 64 labels. [Google Compute Engine label - // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) - // apply. - // Label names that start with "goog-" or "google-" are reserved. - map labels = 8; - - // Output only. Job status. It is read only for users. - JobStatus status = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Deprecated: please use notifications instead. - JobNotification notification = 10 [deprecated = true]; - - // Output only. When the Job was created. - google.protobuf.Timestamp create_time = 11 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The last time the Job was updated. - google.protobuf.Timestamp update_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Log preservation policy for the Job. - LogsPolicy logs_policy = 13; - - // Notification configurations. - repeated JobNotification notifications = 14; -} - -// LogsPolicy describes how outputs from a Job's Tasks (stdout/stderr) will be -// preserved. -message LogsPolicy { - // The destination (if any) for logs. - enum Destination { - // Logs are not preserved. - DESTINATION_UNSPECIFIED = 0; - - // Logs are streamed to Cloud Logging. - CLOUD_LOGGING = 1; - - // Logs are saved to a file path. - PATH = 2; - } - - // Where logs should be saved. - Destination destination = 1; - - // The path to which logs are saved when the destination = PATH. This can be a - // local file path on the VM, or under the mount point of a Persistent Disk or - // Filestore, or a Cloud Storage path. - string logs_path = 2; -} - -// JobDependency describes the state of other Jobs that the start of this Job -// depends on. -// All dependent Jobs must have been submitted in the same region. -message JobDependency { - // Dependency type. - enum Type { - // Unspecified. - TYPE_UNSPECIFIED = 0; - - // The dependent Job has succeeded. - SUCCEEDED = 1; - - // The dependent Job has failed. - FAILED = 2; - - // SUCCEEDED or FAILED. - FINISHED = 3; - } - - // Each item maps a Job name to a Type. - // All items must be satisfied for the JobDependency to be satisfied (the AND - // operation). - // Once a condition for one item becomes true, it won't go back to false - // even the dependent Job state changes again. - map items = 1; -} - -// Job status. -message JobStatus { - // VM instance status. - message InstanceStatus { - // The Compute Engine machine type. - string machine_type = 1; - - // The VM instance provisioning model. - AllocationPolicy.ProvisioningModel provisioning_model = 2; - - // The max number of tasks can be assigned to this instance type. - int64 task_pack = 3; - } - - // Aggregated task status for a TaskGroup. - message TaskGroupStatus { - // Count of task in each state in the TaskGroup. - // The map key is task state name. - map counts = 1; - - // Status of instances allocated for the TaskGroup. - repeated InstanceStatus instances = 2; - } - - // Valid Job states. - enum State { - STATE_UNSPECIFIED = 0; - - // Job is admitted (validated and persisted) and waiting for resources. - QUEUED = 1; - - // Job is scheduled to run as soon as resource allocation is ready. - // The resource allocation may happen at a later time but with a high - // chance to succeed. - SCHEDULED = 2; - - // Resource allocation has been successful. At least one Task in the Job is - // RUNNING. - RUNNING = 3; - - // All Tasks in the Job have finished successfully. - SUCCEEDED = 4; - - // At least one Task in the Job has failed. - FAILED = 5; - - // The Job will be deleted, but has not been deleted yet. Typically this is - // because resources used by the Job are still being cleaned up. - DELETION_IN_PROGRESS = 6; - } - - // Job state - State state = 1; - - // Job status events - repeated StatusEvent status_events = 2; - - // Aggregated task status for each TaskGroup in the Job. - // The map key is TaskGroup ID. - map task_groups = 4; - - // The duration of time that the Job spent in status RUNNING. - google.protobuf.Duration run_duration = 5; -} - -// Notification configurations. -message JobNotification { - // Message details. - // Describe the attribute that a message should have. - // Without specified message attributes, no message will be sent by default. - message Message { - // The message type. - Type type = 1; - - // The new job state. - JobStatus.State new_job_state = 2; - - // The new task state. - TaskStatus.State new_task_state = 3; - } - - // The message type. - enum Type { - // Unspecified. - TYPE_UNSPECIFIED = 0; - - // Notify users that the job state has changed. - JOB_STATE_CHANGED = 1; - - // Notify users that the task state has changed. - TASK_STATE_CHANGED = 2; - } - - // The Pub/Sub topic where notifications like the job state changes - // will be published. This topic exist in the same project as the job - // and billings will be charged to this project. - // If not specified, no Pub/Sub messages will be sent. - // Topic format: `projects/{project}/topics/{topic}`. - string pubsub_topic = 1; - - // The attribute requirements of messages to be sent to this Pub/Sub topic. - // Without this field, no message will be sent. - Message message = 2; -} - -// A Job's resource allocation policy describes when, where, and how compute -// resources should be allocated for the Job. -message AllocationPolicy { - message LocationPolicy { - // A list of allowed location names represented by internal URLs. - // Each location can be a region or a zone. - // Only one region or multiple zones in one region is supported now. - // For example, - // ["regions/us-central1"] allow VMs in any zones in region us-central1. - // ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs - // in zones us-central1-a and us-central1-c. - // All locations end up in different regions would cause errors. - // For example, - // ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", - // "zones/us-west1-a"] contains 2 regions "us-central1" and - // "us-west1". An error is expected in this case. - repeated string allowed_locations = 1; - - // A list of denied location names. - // - // Not yet implemented. - repeated string denied_locations = 2; - } - - // A new persistent disk or a local ssd. - // A VM can only have one local SSD setting but multiple local SSD partitions. - // https://cloud.google.com/compute/docs/disks#pdspecs. - // https://cloud.google.com/compute/docs/disks#localssds. - message Disk { - // A data source from which a PD will be created. - oneof data_source { - // Name of a public or custom image used as the data source. - string image = 4; - - // Name of a snapshot used as the data source. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list` - // For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd". - string type = 1; - - // Disk size in GB. - // This field is ignored if `data_source` is `disk` or `image`. - // If `type` is `local-ssd`, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - int64 size_gb = 2; - - // Local SSDs are available through both "SCSI" and "NVMe" interfaces. - // If not indicated, "NVMe" will be the default one for local ssds. - // We only support "SCSI" for persistent disks now. - string disk_interface = 6; - } - - // A new or an existing persistent disk (PD) or a local ssd attached to a VM - // instance. - message AttachedDisk { - oneof attached { - Disk new_disk = 1; - - // Name of an existing PD. - string existing_disk = 2; - } - - // Device name that the guest operating system will see. - // It is used by Runnable.volumes field to mount disks. So please specify - // the device_name if you want Batch to help mount the disk, and it should - // match the device_name field in volumes. - string device_name = 3; - } - - // Accelerator describes Compute Engine accelerators to be attached to the VM. - message Accelerator { - // The accelerator type. For example, "nvidia-tesla-t4". - // See `gcloud compute accelerator-types list`. - string type = 1; - - // The number of accelerators of this type. - int64 count = 2; - - // Deprecated: please use instances[0].install_gpu_drivers instead. - bool install_gpu_drivers = 3 [deprecated = true]; - } - - // InstancePolicy describes an instance type and resources attached to each VM - // created by this InstancePolicy. - message InstancePolicy { - // Deprecated: please use machine_type instead. - repeated string allowed_machine_types = 1 [deprecated = true]; - - // The Compute Engine machine type. - string machine_type = 2; - - // The minimum CPU platform. - // See - // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. - // Not yet implemented. - string min_cpu_platform = 3; - - // The provisioning model. - ProvisioningModel provisioning_model = 4; - - // The accelerators attached to each VM instance. - repeated Accelerator accelerators = 5; - - // Book disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - Disk boot_disk = 8; - - // Non-boot disks to be attached for each VM created by this InstancePolicy. - // New disks will be deleted when the VM is deleted. - repeated AttachedDisk disks = 6; - - // If specified, VMs will be allocated only inside the matching reservation. - string reservation = 7; - } - - // Either an InstancePolicy or an instance template. - message InstancePolicyOrTemplate { - oneof policy_template { - // InstancePolicy. - InstancePolicy policy = 1; - - // Name of an instance template used to create VMs. - // Named the field as 'instance_template' instead of 'template' to avoid - // c++ keyword conflict. - string instance_template = 2; - } - - // Set this field true if users want Batch to help fetch drivers from a - // third party location and install them for GPUs specified in - // policy.accelerators or instance_template on their behalf. Default is - // false. - bool install_gpu_drivers = 3; - } - - // A network interface. - message NetworkInterface { - // The URL of an existing network resource. - // You can specify the network as a full or partial URL. - // For example, the following are all valid URLs: - // https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} - // projects/{project}/global/networks/{network} - // global/networks/{network} - string network = 1; - - // The URL of an existing subnetwork resource in the network. - // You can specify the subnetwork as a full or partial URL. - // For example, the following are all valid URLs: - // https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork} - // projects/{project}/regions/{region}/subnetworks/{subnetwork} - // regions/{region}/subnetworks/{subnetwork} - string subnetwork = 2; - - // Default is false (with an external IP address). Required if - // no external public IP address is attached to the VM. If no external - // public IP address, additional configuration is required to allow the VM - // to access Google Services. See - // https://cloud.google.com/vpc/docs/configure-private-google-access and - // https://cloud.google.com/nat/docs/gce-example#create-nat for more - // information. - bool no_external_ip_address = 3; - } - - // NetworkPolicy describes VM instance network configurations. - message NetworkPolicy { - // Network configurations. - repeated NetworkInterface network_interfaces = 1; - } - - // Compute Engine VM instance provisioning model. - enum ProvisioningModel { - // Unspecified. - PROVISIONING_MODEL_UNSPECIFIED = 0; - - // Standard VM. - STANDARD = 1; - - // SPOT VM. - SPOT = 2; - - // Preemptible VM (PVM). - // - // Above SPOT VM is the preferable model for preemptible VM instances: the - // old preemptible VM model (indicated by this field) is the older model, - // and has been migrated to use the SPOT model as the underlying technology. - // This old model will still be supported. - PREEMPTIBLE = 3; - } - - // Location where compute resources should be allocated for the Job. - LocationPolicy location = 1; - - // Deprecated: please use instances[0].policy instead. - InstancePolicy instance = 2 [deprecated = true]; - - // Describe instances that can be created by this AllocationPolicy. - // Only instances[0] is supported now. - repeated InstancePolicyOrTemplate instances = 8; - - // Deprecated: please use instances[0].template instead. - repeated string instance_templates = 3 [deprecated = true]; - - // Deprecated: please use instances[0].policy.provisioning_model instead. - repeated ProvisioningModel provisioning_models = 4 [deprecated = true]; - - // Deprecated: please use service_account instead. - string service_account_email = 5 [deprecated = true]; - - // Service account that VMs will run as. - ServiceAccount service_account = 9; - - // Labels applied to all VM instances and other resources - // created by AllocationPolicy. - // Labels could be user provided or system generated. - // You can assign up to 64 labels. [Google Compute Engine label - // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) - // apply. - // Label names that start with "goog-" or "google-" are reserved. - map labels = 6; - - // The network policy. - NetworkPolicy network = 7; -} - -// A TaskGroup contains one or multiple Tasks that share the same -// Runnable but with different runtime parameters. -message TaskGroup { - option (google.api.resource) = { - type: "batch.googleapis.com/TaskGroup" - pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - }; - - // How Tasks in the TaskGroup should be scheduled relative to each other. - enum SchedulingPolicy { - // Unspecified. - SCHEDULING_POLICY_UNSPECIFIED = 0; - - // Run Tasks as soon as resources are available. - AS_SOON_AS_POSSIBLE = 1; - } - - // Output only. TaskGroup name. - // The system generates this field based on parent Job name. - // For example: - // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Tasks in the group share the same task spec. - TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; - - // Number of Tasks in the TaskGroup. - // default is 1 - int64 task_count = 4; - - // Max number of tasks that can run in parallel. - // Default to min(task_count, 1000). - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - SchedulingPolicy scheduling_policy = 6; - - // Compute resource allocation for the TaskGroup. - // If specified, it overrides resources in Job. - AllocationPolicy allocation_policy = 7; - - // Labels for the TaskGroup. - // Labels could be user provided or system generated. - // You can assign up to 64 labels. [Google Compute Engine label - // restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) - // apply. - // Label names that start with "goog-" or "google-" are reserved. - map labels = 8; - - // An array of environment variable mappings, which are passed to Tasks with - // matching indices. If task_environments is used then task_count should - // not be specified in the request (and will be ignored). Task count will be - // the length of task_environments. - // - // Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in - // addition to any environment variables set in task_environments, specifying - // the number of Tasks in the Task's parent TaskGroup, and the specific Task's - // index in the TaskGroup (0 through BATCH_TASK_COUNT - 1). - // - // task_environments supports up to 200 entries. - repeated Environment task_environments = 9; - - // Max number of tasks that can be run on a VM at the same time. - // If not specified, the system will decide a value based on available - // compute resources on a VM and task requirements. - int64 task_count_per_node = 10; - - // When true, Batch will populate a file with a list of all VMs assigned to - // the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path - // of that file. Defaults to false. - bool require_hosts_file = 11; - - // When true, Batch will configure SSH to allow passwordless login between - // VMs running the Batch tasks in the same TaskGroup. - bool permissive_ssh = 12; -} - -// Carries information about a Google Cloud service account. -message ServiceAccount { - // Email address of the service account. If not specified, the default - // Compute Engine service account for the project will be used. If instance - // template is being used, the service account has to be specified in the - // instance template and it has to match the email field here. - string email = 1; - - // List of scopes to be enabled for this service account on the VM, in - // addition to the cloud-platform API scope that will be added by default. - repeated string scopes = 2; -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto deleted file mode 100644 index a28545ad495..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,321 +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.batch.v1alpha; - -import "google/api/resource.proto"; -import "google/cloud/batch/v1alpha/volume.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; -option java_multiple_files = true; -option java_outer_classname = "TaskProto"; -option java_package = "com.google.cloud.batch.v1alpha"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; -option ruby_package = "Google::Cloud::Batch::V1alpha"; - -// Compute resource requirements -message ComputeResource { - // The milliCPU count. - int64 cpu_milli = 1; - - // Memory in MiB. - int64 memory_mib = 2; - - // The GPU count. - // - // Not yet implemented. - int64 gpu_count = 3; - - // Extra boot disk size in MiB for each task. - int64 boot_disk_mib = 4; -} - -// Status event -message StatusEvent { - // Type of the event. - string type = 3; - - // Description of the event. - string description = 1; - - // The time this event occurred. - google.protobuf.Timestamp event_time = 2; - - // Task Execution - TaskExecution task_execution = 4; -} - -// This Task Execution field includes detail information for -// task execution procedures, based on StatusEvent types. -message TaskExecution { - // When task is completed as the status of FAILED or SUCCEEDED, - // exit code is for one task execution result, default is 0 as success. - int32 exit_code = 1; -} - -// Status of a task -message TaskStatus { - // Task states. - enum State { - // unknown state - STATE_UNSPECIFIED = 0; - - // The Task is created and waiting for resources. - PENDING = 1; - - // The Task is assigned to at least one VM. - ASSIGNED = 2; - - // The Task is running. - RUNNING = 3; - - // The Task has failed. - FAILED = 4; - - // The Task has succeeded. - SUCCEEDED = 5; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; -} - -// Runnable describes instructions for executing a specific script or container -// as part of a Task. -message Runnable { - // Container runnable. - message Container { - // The URI to pull the container image from. - string image_uri = 1; - - // Overrides the `CMD` specified in the container. If there is an ENTRYPOINT - // (either in the container image or with the entrypoint field below) then - // commands are appended as arguments to the ENTRYPOINT. - repeated string commands = 2; - - // Overrides the `ENTRYPOINT` specified in the container. - string entrypoint = 3; - - // Volumes to mount (bind mount) from the host machine files or directories - // into the container, formatted to match docker run's --volume option, - // e.g. /foo:/bar, or /foo:/bar:ro - repeated string volumes = 7; - - // Arbitrary additional options to include in the "docker run" command when - // running this container, e.g. "--network host". - string options = 8; - - // If set to true, external network access to and from container will be - // blocked. The container will use the default internal network - // 'goog-internal'. - bool block_external_network = 9; - - // Optional username for logging in to a docker registry. If username - // matches `projects/*/secrets/*/versions/*` then Batch will read the - // username from the Secret Manager. - string username = 10; - - // Optional password for logging in to a docker registry. If password - // matches `projects/*/secrets/*/versions/*` then Batch will read the - // password from the Secret Manager; - string password = 11; - } - - // Script runnable. - message Script { - oneof command { - // Script file path on the host VM. - string path = 1; - - // Shell script text. - string text = 2; - } - } - - // Barrier runnable blocks until all tasks in a taskgroup reach it. - message Barrier { - // Barriers are identified by their index in runnable list. - // Names are not required, but if present should be an identifier. - string name = 1; - } - - // The script or container to run. - oneof executable { - // Container runnable. - Container container = 1; - - // Script runnable. - Script script = 2; - - // Barrier runnable. - Barrier barrier = 6; - } - - // Normally, a non-zero exit status causes the Task to fail. This flag allows - // execution of other Runnables to continue instead. - bool ignore_exit_status = 3; - - // This flag allows a Runnable to continue running in the background while the - // Task executes subsequent Runnables. This is useful to provide services to - // other Runnables (or to provide debugging support tools like SSH servers). - bool background = 4; - - // By default, after a Runnable fails, no further Runnable are executed. This - // flag indicates that this Runnable must be run even if the Task has already - // failed. This is useful for Runnables that copy output files off of the VM - // or for debugging. - // - // The always_run flag does not override the Task's overall max_run_duration. - // If the max_run_duration has expired then no further Runnables will execute, - // not even always_run Runnables. - bool always_run = 5; - - // Environment variables for this Runnable (overrides variables set for the - // whole Task or TaskGroup). - Environment environment = 7; - - // Timeout for this Runnable. - google.protobuf.Duration timeout = 8; - - // Labels for this Runnable. - map labels = 9; -} - -// Spec of a task -message TaskSpec { - // The sequence of scripts or containers to run for this Task. Each Task using - // this TaskSpec executes its list of runnables in order. The Task succeeds if - // all of its runnables either exit with a zero status or any that exit with a - // non-zero status have the ignore_exit_status flag. - // - // Background runnables are killed automatically (if they have not already - // exited) a short time after all foreground runnables have completed. Even - // though this is likely to result in a non-zero exit status for the - // background runnable, these automatic kills are not treated as Task - // failures. - repeated Runnable runnables = 8; - - // ComputeResource requirements. - ComputeResource compute_resource = 3; - - // Maximum duration the task should run. - // The task will be killed and marked as FAILED if over this limit. - google.protobuf.Duration max_run_duration = 4; - - // Maximum number of retries on failures. - // The default, 0, which means never retry. - // The valid value range is [0, 10]. - int32 max_retry_count = 5; - - // Lifecycle management schema when any task in a task group is failed. - // The valid size of lifecycle policies are [0, 10]. - // For each lifecycle policy, when the condition is met, - // the action in that policy will execute. - // If there are multiple policies that the task execution result matches, - // we use the action from the first matched policy. If task execution result - // does not meet with any of the defined lifecycle policy, we consider it as - // the default policy. Default policy means if the exit code is 0, exit task. - // If task ends with non-zero exit code, retry the task with max_retry_count. - repeated LifecyclePolicy lifecycle_policies = 9; - - // Deprecated: please use environment(non-plural) instead. - map environments = 6 [deprecated = true]; - - // Volumes to mount before running Tasks using this TaskSpec. - repeated Volume volumes = 7; - - // Environment variables to set before running the Task. - Environment environment = 10; -} - -// LifecyclePolicy describes how to deal with task failures -// based on different conditions. -message LifecyclePolicy { - // Conditions for actions to deal with task failures. - message ActionCondition { - // Exit codes of a task execution. - // If there are more than 1 exit codes, - // when task executes with any of the exit code in the list, - // the condition is met and the action will be executed. - repeated int32 exit_codes = 1; - } - - // Action on task failures based on different conditions. - enum Action { - // Action unspecified. - ACTION_UNSPECIFIED = 0; - - // Action that tasks in the group will be scheduled to re-execute. - RETRY_TASK = 1; - - // Action that tasks in the group will be stopped immediately. - FAIL_TASK = 2; - } - - // Action to execute when ActionCondition is true. - Action action = 1; - - // Conditions that decide why a task failure is dealt with a specific action. - ActionCondition action_condition = 2; -} - -// A Cloud Batch task. -message Task { - option (google.api.resource) = { - type: "batch.googleapis.com/Task" - pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}" - }; - - // Task name. - // The name is generated from the parent TaskGroup name and 'id' field. - // For example: - // "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01/tasks/task01". - string name = 1; - - // Task Status. - TaskStatus status = 2; -} - -// An Environment describes a collection of environment variables to set when -// executing Tasks. -message Environment { - message KMSEnvMap { - // The name of the KMS key that will be used to decrypt the cipher text. - string key_name = 1; - - // The value of the cipherText response from the `encrypt` method. - string cipher_text = 2; - } - - // A map of environment variable names to values. - map variables = 1; - - // A map of environment variable names to Secret Manager secret names. - // The VM will access the named secrets to set the value of each environment - // variable. - map secret_variables = 2; - - // An encrypted JSON dictionary where the key/value pairs correspond to - // environment variable names and their values. - KMSEnvMap encrypted_variables = 3; -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto deleted file mode 100644 index 4112d2363a6..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +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.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "google.golang.org/genproto/googleapis/cloud/batch/v1alpha;batch"; -option java_multiple_files = true; -option java_outer_classname = "VolumeProto"; -option java_package = "com.google.cloud.batch.v1alpha"; -option objc_class_prefix = "GCB"; -option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; -option ruby_package = "Google::Cloud::Batch::V1alpha"; - -// Volume describes a volume and parameters for it to be mounted to a VM. -message Volume { - // The source for the volume. - oneof source { - // A Network File System (NFS) volume. For example, a - // Filestore file share. - NFS nfs = 1; - - // Deprecated: please use device_name instead. - PD pd = 2 [deprecated = true]; - - // A Google Cloud Storage (GCS) volume. - GCS gcs = 3; - - // Device name of an attached disk volume, which should align with a - // device_name specified by - // job.allocation_policy.instances[0].policy.disks[i].device_name or - // defined by the given instance template in - // job.allocation_policy.instances[0].instance_template. - string device_name = 6; - } - - // The mount path for the volume, e.g. /mnt/disks/share. - string mount_path = 4; - - // For Google Cloud Storage (GCS), mount options are the options supported by - // the gcsfuse tool (https://github.com/GoogleCloudPlatform/gcsfuse). - // For existing persistent disks, mount options provided by the - // mount command (https://man7.org/linux/man-pages/man8/mount.8.html) except - // writing are supported. This is due to restrictions of multi-writer mode - // (https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms). - // For other attached disks and Network File System (NFS), mount options are - // these supported by the mount command - // (https://man7.org/linux/man-pages/man8/mount.8.html). - repeated string mount_options = 5; -} - -// Represents an NFS volume. -message NFS { - // The IP address of the NFS. - string server = 1; - - // Remote source path exported from the NFS, e.g., "/share". - string remote_path = 2; -} - -// Deprecated: please use device_name instead. -message PD { - // PD disk name, e.g. pd-1. - string disk = 1; - - // PD device name, e.g. persistent-disk-1. - string device = 2; - - // Whether this is an existing PD. Default is false. If false, i.e., new - // PD, we will format it into ext4 and mount to the given path. If true, i.e., - // existing PD, it should be in ext4 format and we will mount it to the given - // path. - bool existing = 3 [deprecated = true]; -} - -// Represents a Google Cloud Storage volume. -message GCS { - // Remote path, either a bucket name or a subdirectory of a bucket, e.g.: - // bucket_name, bucket_name/subdirectory/ - string remote_path = 1; -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js deleted file mode 100644 index 8207e50d060..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.create_job.js +++ /dev/null @@ -1,92 +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, job) { - // [START batch_v1alpha_generated_BatchService_CreateJob_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 where the Job will be created. - * Pattern: "projects/{project}/locations/{location}" - */ - // const parent = 'abc123' - /** - * ID used to uniquely identify the Job within its parent scope. - * This field should contain at most 63 characters and must start with - * lowercase characters. - * Only lowercase characters, numbers and '-' are accepted. - * The '-' character cannot be the first or the last one. - * A system generated ID will be used if the field is not set. - * The job.name field in the request will be ignored and the created resource - * name of the Job will be "{parent}/jobs/{job_id}". - */ - // const jobId = 'abc123' - /** - * Required. The Job to create. - */ - // const job = {} - /** - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - }; - - // Run request - const response = await batchClient.createJob(request); - console.log(response); - } - - callCreateJob(); - // [END batch_v1alpha_generated_BatchService_CreateJob_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-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.js deleted file mode 100644 index bb942a135b8..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.delete_job.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() { - // [START batch_v1alpha_generated_BatchService_DeleteJob_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. - */ - /** - * Job name. - */ - // const name = 'abc123' - /** - * Optional. Reason for this deletion. - */ - // const reason = 'abc123' - /** - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - */ - // const requestId = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callDeleteJob() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await batchClient.deleteJob(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteJob(); - // [END batch_v1alpha_generated_BatchService_DeleteJob_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-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.js deleted file mode 100644 index dcb65219962..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_job.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 batch_v1alpha_generated_BatchService_GetJob_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. Job name. - */ - // const name = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await batchClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END batch_v1alpha_generated_BatchService_GetJob_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-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.js deleted file mode 100644 index 7e6c762eec6..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.get_task.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 batch_v1alpha_generated_BatchService_GetTask_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. Task name. - */ - // const name = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callGetTask() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await batchClient.getTask(request); - console.log(response); - } - - callGetTask(); - // [END batch_v1alpha_generated_BatchService_GetTask_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-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js deleted file mode 100644 index 7526e461b9c..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.js +++ /dev/null @@ -1,74 +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 batch_v1alpha_generated_BatchService_ListJobs_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. - */ - /** - * Parent path. - */ - // const parent = 'abc123' - /** - * List filter. - */ - // const filter = 'abc123' - /** - * Page size. - */ - // const pageSize = 1234 - /** - * Page token. - */ - // const pageToken = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callListJobs() { - // Construct request - const request = { - }; - - // Run request - const iterable = await batchClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END batch_v1alpha_generated_BatchService_ListJobs_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-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js deleted file mode 100644 index b58fc1eee54..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.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 batch_v1alpha_generated_BatchService_ListTasks_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. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - */ - // const parent = 'abc123' - /** - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - */ - // const filter = 'abc123' - /** - * Page size. - */ - // const pageSize = 1234 - /** - * Page token. - */ - // const pageToken = 'abc123' - - // Imports the Batch library - const {BatchServiceClient} = require('@google-cloud/batch').v1alpha; - - // Instantiates a client - const batchClient = new BatchServiceClient(); - - async function callListTasks() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await batchClient.listTasksAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTasks(); - // [END batch_v1alpha_generated_BatchService_ListTasks_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-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json deleted file mode 100644 index d2276b2647b..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ /dev/null @@ -1,299 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-batch", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.batch.v1alpha", - "version": "v1alpha" - } - ] - }, - "snippets": [ - { - "regionTag": "batch_v1alpha_generated_BatchService_CreateJob_async", - "title": "BatchService createJob Sample", - "origin": "API_DEFINITION", - "description": " Create a Job.", - "canonical": true, - "file": "batch_service.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 84, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.batch.v1alpha.BatchService.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job_id", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.batch.v1alpha.Job" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1alpha.Job", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.batch.v1alpha.BatchService.CreateJob", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1alpha.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1alpha_generated_BatchService_GetJob_async", - "title": "BatchService getJob Sample", - "origin": "API_DEFINITION", - "description": " Get a Job specified by its resource name.", - "canonical": true, - "file": "batch_service.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.batch.v1alpha.BatchService.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1alpha.Job", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.batch.v1alpha.BatchService.GetJob", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1alpha.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1alpha_generated_BatchService_DeleteJob_async", - "title": "BatchService deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Delete a Job.", - "canonical": true, - "file": "batch_service.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.batch.v1alpha.BatchService.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "reason", - "type": "TYPE_STRING" - }, - { - "name": "request_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.batch.v1alpha.BatchService.DeleteJob", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1alpha.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1alpha_generated_BatchService_ListJobs_async", - "title": "BatchService listJobs Sample", - "origin": "API_DEFINITION", - "description": " List all Jobs for a project within a region.", - "canonical": true, - "file": "batch_service.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.batch.v1alpha.BatchService.ListJobs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1alpha.ListJobsResponse", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.batch.v1alpha.BatchService.ListJobs", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1alpha.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1alpha_generated_BatchService_GetTask_async", - "title": "BatchService getTask Sample", - "origin": "API_DEFINITION", - "description": " Return a single Task.", - "canonical": true, - "file": "batch_service.get_task.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTask", - "fullName": "google.cloud.batch.v1alpha.BatchService.GetTask", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1alpha.Task", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" - }, - "method": { - "shortName": "GetTask", - "fullName": "google.cloud.batch.v1alpha.BatchService.GetTask", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1alpha.BatchService" - } - } - } - }, - { - "regionTag": "batch_v1alpha_generated_BatchService_ListTasks_async", - "title": "BatchService listTasks Sample", - "origin": "API_DEFINITION", - "description": " List Tasks associated with a job.", - "canonical": true, - "file": "batch_service.list_tasks.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTasks", - "fullName": "google.cloud.batch.v1alpha.BatchService.ListTasks", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.batch.v1alpha.ListTasksResponse", - "client": { - "shortName": "BatchServiceClient", - "fullName": "google.cloud.batch.v1alpha.BatchServiceClient" - }, - "method": { - "shortName": "ListTasks", - "fullName": "google.cloud.batch.v1alpha.BatchService.ListTasks", - "service": { - "shortName": "BatchService", - "fullName": "google.cloud.batch.v1alpha.BatchService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/index.ts b/owl-bot-staging/google-cloud-batch/v1alpha/src/index.ts deleted file mode 100644 index 69f087aa775..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 v1alpha from './v1alpha'; -const BatchServiceClient = v1alpha.BatchServiceClient; -type BatchServiceClient = v1alpha.BatchServiceClient; -export {v1alpha, BatchServiceClient}; -export default {v1alpha, BatchServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts deleted file mode 100644 index 1503d22686d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1743 +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, IamClient, IamProtos, 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/v1alpha/batch_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './batch_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Google Batch Service. - * The service manages user submitted batch jobs and allocates Google Compute - * Engine VM instances to run the jobs. - * @class - * @memberof v1alpha - */ -export class BatchServiceClient { - 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}; - iamClient: IamClient; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - batchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of BatchServiceClient. - * - * @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 BatchServiceClient({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 BatchServiceClient; - 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - - 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 = { - jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task}' - ), - taskGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}' - ), - }; - - // 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 = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs'), - listTasks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') - }; - - 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: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1alpha/{resource=projects/*/locations/*/jobs/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const deleteJobResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteJobMetadata = protoFilesRoot.lookup( - '.google.cloud.batch.v1alpha.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - deleteJob: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteJobResponse.decode.bind(deleteJobResponse), - deleteJobMetadata.decode.bind(deleteJobMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.batch.v1alpha.BatchService', 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.batchServiceStub) { - return this.batchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.batch.v1alpha.BatchService. - this.batchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.batch.v1alpha.BatchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.batch.v1alpha.BatchService, - 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 batchServiceStubMethods = - ['createJob', 'getJob', 'deleteJob', 'listJobs', 'getTask', 'listTasks']; - for (const methodName of batchServiceStubMethods) { - const callPromise = this.batchServiceStub.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.batchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'batch.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 'batch.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 -- - // ------------------- -/** - * Create a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name where the Job will be created. - * Pattern: "projects/{project}/locations/{location}" - * @param {string} request.jobId - * ID used to uniquely identify the Job within its parent scope. - * This field should contain at most 63 characters and must start with - * lowercase characters. - * Only lowercase characters, numbers and '-' are accepted. - * The '-' character cannot be the first or the last one. - * A system generated ID will be used if the field is not set. - * - * The job.name field in the request will be ignored and the created resource - * name of the Job will be "{parent}/jobs/{job_id}". - * @param {google.cloud.batch.v1alpha.Job} request.job - * Required. The Job to create. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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 [Job]{@link google.cloud.batch.v1alpha.Job}. - * 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/v1alpha/batch_service.create_job.js - * region_tag:batch_v1alpha_generated_BatchService_CreateJob_async - */ - createJob( - request?: protos.google.cloud.batch.v1alpha.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.ICreateJobRequest|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.batch.v1alpha.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.batch.v1alpha.ICreateJobRequest, - callback: Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.batch.v1alpha.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.ICreateJobRequest|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.createJob(request, options, callback); - } -/** - * Get a Job specified by its resource name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Job 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 [Job]{@link google.cloud.batch.v1alpha.Job}. - * 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/v1alpha/batch_service.get_job.js - * region_tag:batch_v1alpha_generated_BatchService_GetJob_async - */ - getJob( - request?: protos.google.cloud.batch.v1alpha.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.batch.v1alpha.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.batch.v1alpha.IGetJobRequest, - callback: Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.batch.v1alpha.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.batch.v1alpha.IJob, - protos.google.cloud.batch.v1alpha.IGetJobRequest|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.getJob(request, options, callback); - } -/** - * Return a single Task. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Task 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 [Task]{@link google.cloud.batch.v1alpha.Task}. - * 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/v1alpha/batch_service.get_task.js - * region_tag:batch_v1alpha_generated_BatchService_GetTask_async - */ - getTask( - request?: protos.google.cloud.batch.v1alpha.IGetTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1alpha.ITask, - protos.google.cloud.batch.v1alpha.IGetTaskRequest|undefined, {}|undefined - ]>; - getTask( - request: protos.google.cloud.batch.v1alpha.IGetTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.batch.v1alpha.ITask, - protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; - getTask( - request: protos.google.cloud.batch.v1alpha.IGetTaskRequest, - callback: Callback< - protos.google.cloud.batch.v1alpha.ITask, - protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; - getTask( - request?: protos.google.cloud.batch.v1alpha.IGetTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.batch.v1alpha.ITask, - protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.batch.v1alpha.ITask, - protos.google.cloud.batch.v1alpha.IGetTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.batch.v1alpha.ITask, - protos.google.cloud.batch.v1alpha.IGetTaskRequest|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.getTask(request, options, callback); - } - -/** - * Delete a Job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Job name. - * @param {string} [request.reason] - * Optional. Reason for this deletion. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @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/v1alpha/batch_service.delete_job.js - * region_tag:batch_v1alpha_generated_BatchService_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.batch.v1alpha.IDeleteJobRequest, - 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.deleteJob(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteJob()`. - * @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/v1alpha/batch_service.delete_job.js - * region_tag:batch_v1alpha_generated_BatchService_DeleteJob_async - */ - async checkDeleteJobProgress(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.deleteJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * List all Jobs for a project within a region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Parent path. - * @param {string} request.filter - * List filter. - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Job]{@link google.cloud.batch.v1alpha.Job}. - * 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 `listJobsAsync()` - * 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. - */ - listJobs( - request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1alpha.IJob[], - protos.google.cloud.batch.v1alpha.IListJobsRequest|null, - protos.google.cloud.batch.v1alpha.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.batch.v1alpha.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.batch.v1alpha.IListJobsRequest, - protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1alpha.IJob>): void; - listJobs( - request: protos.google.cloud.batch.v1alpha.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.batch.v1alpha.IListJobsRequest, - protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1alpha.IJob>): void; - listJobs( - request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.batch.v1alpha.IListJobsRequest, - protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1alpha.IJob>, - callback?: PaginationCallback< - protos.google.cloud.batch.v1alpha.IListJobsRequest, - protos.google.cloud.batch.v1alpha.IListJobsResponse|null|undefined, - protos.google.cloud.batch.v1alpha.IJob>): - Promise<[ - protos.google.cloud.batch.v1alpha.IJob[], - protos.google.cloud.batch.v1alpha.IListJobsRequest|null, - protos.google.cloud.batch.v1alpha.IListJobsResponse - ]>|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.listJobs(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 - * Parent path. - * @param {string} request.filter - * List filter. - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Job]{@link google.cloud.batch.v1alpha.Job} 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 `listJobsAsync()` - * 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. - */ - listJobsStream( - request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listJobs`, 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 - * Parent path. - * @param {string} request.filter - * List filter. - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * 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 - * [Job]{@link google.cloud.batch.v1alpha.Job}. 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/v1alpha/batch_service.list_jobs.js - * region_tag:batch_v1alpha_generated_BatchService_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.batch.v1alpha.IListJobsRequest, - 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['listJobs']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listJobs.asyncIterate( - this.innerApiCalls['listJobs'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * List Tasks associated with a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - * @param {string} request.filter - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Task]{@link google.cloud.batch.v1alpha.Task}. - * 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 `listTasksAsync()` - * 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. - */ - listTasks( - request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.batch.v1alpha.ITask[], - protos.google.cloud.batch.v1alpha.IListTasksRequest|null, - protos.google.cloud.batch.v1alpha.IListTasksResponse - ]>; - listTasks( - request: protos.google.cloud.batch.v1alpha.IListTasksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.batch.v1alpha.IListTasksRequest, - protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1alpha.ITask>): void; - listTasks( - request: protos.google.cloud.batch.v1alpha.IListTasksRequest, - callback: PaginationCallback< - protos.google.cloud.batch.v1alpha.IListTasksRequest, - protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1alpha.ITask>): void; - listTasks( - request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.batch.v1alpha.IListTasksRequest, - protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1alpha.ITask>, - callback?: PaginationCallback< - protos.google.cloud.batch.v1alpha.IListTasksRequest, - protos.google.cloud.batch.v1alpha.IListTasksResponse|null|undefined, - protos.google.cloud.batch.v1alpha.ITask>): - Promise<[ - protos.google.cloud.batch.v1alpha.ITask[], - protos.google.cloud.batch.v1alpha.IListTasksRequest|null, - protos.google.cloud.batch.v1alpha.IListTasksResponse - ]>|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.listTasks(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. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - * @param {string} request.filter - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * Page token. - * @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 [Task]{@link google.cloud.batch.v1alpha.Task} 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 `listTasksAsync()` - * 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. - */ - listTasksStream( - request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, - 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['listTasks']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTasks.createStream( - this.innerApiCalls.listTasks as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTasks`, 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. Name of a TaskGroup from which Tasks are being requested. - * Pattern: - * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" - * @param {string} request.filter - * Task filter, null filter matches all Tasks. - * Filter string should be of the format State=TaskStatus.State e.g. - * State=RUNNING - * @param {number} request.pageSize - * Page size. - * @param {string} request.pageToken - * 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 - * [Task]{@link google.cloud.batch.v1alpha.Task}. 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/v1alpha/batch_service.list_tasks.js - * region_tag:batch_v1alpha_generated_BatchService_ListTasks_async - */ - listTasksAsync( - request?: protos.google.cloud.batch.v1alpha.IListTasksRequest, - 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['listTasks']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTasks.asyncIterate( - this.innerApiCalls['listTasks'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions} - * @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/interfaces/CallOptions.html} 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 [Policy]{@link google.iam.v1.Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - getIamPolicy( - request: IamProtos.google.iam.v1.GetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise { - return this.iamClient.getIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - setIamPolicy( - request: IamProtos.google.iam.v1.SetIamPolicyRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.Policy, - IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, - {} | null | undefined - > - ):Promise { - return this.iamClient.setIamPolicy(request, options, callback); - } - -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ - testIamPermissions( - request: IamProtos.google.iam.v1.TestIamPermissionsRequest, - options?: - | gax.CallOptions - | Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - >, - callback?: Callback< - IamProtos.google.iam.v1.TestIamPermissionsResponse, - IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, - {} | null | undefined - > - ):Promise { - return this.iamClient.testIamPermissions(request, options, callback); - } - -/** - * 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 job resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @returns {string} Resource name string. - */ - jobPath(project:string,location:string,job:string) { - return this.pathTemplates.jobPathTemplate.render({ - project: project, - location: location, - job: job, - }); - } - - /** - * Parse the project from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the project. - */ - matchProjectFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).project; - } - - /** - * Parse the location from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the location. - */ - matchLocationFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).location; - } - - /** - * Parse the job from Job resource. - * - * @param {string} jobName - * A fully-qualified path representing Job resource. - * @returns {string} A string representing the job. - */ - matchJobFromJobName(jobName: string) { - return this.pathTemplates.jobPathTemplate.match(jobName).job; - } - - /** - * 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 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 task resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} task_group - * @param {string} task - * @returns {string} Resource name string. - */ - taskPath(project:string,location:string,job:string,taskGroup:string,task:string) { - return this.pathTemplates.taskPathTemplate.render({ - project: project, - location: location, - job: job, - task_group: taskGroup, - task: task, - }); - } - - /** - * Parse the project from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).project; - } - - /** - * Parse the location from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).location; - } - - /** - * Parse the job from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).job; - } - - /** - * Parse the task_group from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task_group. - */ - matchTaskGroupFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task_group; - } - - /** - * Parse the task from Task resource. - * - * @param {string} taskName - * A fully-qualified path representing Task resource. - * @returns {string} A string representing the task. - */ - matchTaskFromTaskName(taskName: string) { - return this.pathTemplates.taskPathTemplate.match(taskName).task; - } - - /** - * Return a fully-qualified taskGroup resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} job - * @param {string} task_group - * @returns {string} Resource name string. - */ - taskGroupPath(project:string,location:string,job:string,taskGroup:string) { - return this.pathTemplates.taskGroupPathTemplate.render({ - project: project, - location: location, - job: job, - task_group: taskGroup, - }); - } - - /** - * Parse the project from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the project. - */ - matchProjectFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).project; - } - - /** - * Parse the location from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the location. - */ - matchLocationFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).location; - } - - /** - * Parse the job from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the job. - */ - matchJobFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).job; - } - - /** - * Parse the task_group from TaskGroup resource. - * - * @param {string} taskGroupName - * A fully-qualified path representing TaskGroup resource. - * @returns {string} A string representing the task_group. - */ - matchTaskGroupFromTaskGroupName(taskGroupName: string) { - return this.pathTemplates.taskGroupPathTemplate.match(taskGroupName).task_group; - } - - /** - * 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.batchServiceStub && !this._terminated) { - return this.batchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.iamClient.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json deleted file mode 100644 index b8f623ace5a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client_config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "interfaces": { - "google.cloud.batch.v1alpha.BatchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateJob": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteJob": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListJobs": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "GetTask": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListTasks": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json deleted file mode 100644 index 82136a8b22d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_proto_list.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "../../protos/google/cloud/batch/v1alpha/batch.proto", - "../../protos/google/cloud/batch/v1alpha/job.proto", - "../../protos/google/cloud/batch/v1alpha/task.proto", - "../../protos/google/cloud/batch/v1alpha/volume.proto" -] diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json deleted file mode 100644 index 3de59b0c964..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/gapic_metadata.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.batch.v1alpha", - "libraryPackage": "@google-cloud/batch", - "services": { - "BatchService": { - "clients": { - "grpc": { - "libraryClient": "BatchServiceClient", - "rpcs": { - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "GetJob": { - "methods": [ - "getJob" - ] - }, - "GetTask": { - "methods": [ - "getTask" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - }, - "ListTasks": { - "methods": [ - "listTasks", - "listTasksStream", - "listTasksAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "BatchServiceClient", - "rpcs": { - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "GetJob": { - "methods": [ - "getJob" - ] - }, - "GetTask": { - "methods": [ - "getTask" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - }, - "ListTasks": { - "methods": [ - "listTasks", - "listTasksStream", - "listTasksAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/index.ts b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/index.ts deleted file mode 100644 index 0f129526252..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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 {BatchServiceClient} from './batch_service_client'; diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 230aacd757b..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 batch = require('@google-cloud/batch'); - -function main() { - const batchServiceClient = new batch.BatchServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index a09668ae84d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 {BatchServiceClient} from '@google-cloud/batch'; - -// check that the client class type name can be used -function doStuffWithBatchServiceClient(client: BatchServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const batchServiceClient = new BatchServiceClient(); - doStuffWithBatchServiceClient(batchServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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-batch/v1alpha/test/gapic_batch_service_v1alpha.ts b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts deleted file mode 100644 index a4660b3c6e5..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,2111 +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 batchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, IamProtos, 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('v1alpha.BatchServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = batchserviceModule.v1alpha.BatchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = batchserviceModule.v1alpha.BatchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = batchserviceModule.v1alpha.BatchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.batchServiceStub, undefined); - await client.initialize(); - assert(client.batchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.batchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.batchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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('createJob', () => { - it('invokes createJob without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.Job() - ); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with closed client', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createJob(request), expectedError); - }); - }); - - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with closed client', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getJob(request), expectedError); - }); - }); - - describe('getTask', () => { - it('invokes getTask without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.Task() - ); - client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); - const [response] = await client.getTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.Task() - ); - client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTask( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTask(request), expectedError); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getTask with closed client', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTask(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with call error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with LRO error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteJobProgress without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - 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.checkDeleteJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteJobProgress with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - 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.checkDeleteJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobsStream without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1alpha.Job[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1alpha.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listJobsStream with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1alpha.Job[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1alpha.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.batch.v1alpha.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.batch.v1alpha.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listTasks', () => { - it('invokes listTasks without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); - const [response] = await client.listTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTasks( - request, - (err?: Error|null, result?: protos.google.cloud.batch.v1alpha.ITask[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasksStream without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - ]; - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1alpha.Task[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1alpha.Task) => { - 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.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listTasksStream with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.batch.v1alpha.Task[] = []; - stream.on('data', (response: protos.google.cloud.batch.v1alpha.Task) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTasks without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - generateSampleMessage(new protos.google.cloud.batch.v1alpha.Task()), - ]; - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.batch.v1alpha.ITask[] = []; - const iterable = client.listTasksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listTasks with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.batch.v1alpha.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.batch.v1alpha.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTasksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.batch.v1alpha.ITask[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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 batchserviceModule.v1alpha.BatchServiceClient({ - 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('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - 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('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - task_group: "taskGroupValue", - task: "taskValue", - }; - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "jobValue", "taskGroupValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskName', () => { - const result = client.matchJobFromTaskName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskGroupFromTaskName', () => { - const result = client.matchTaskGroupFromTaskName(fakePath); - assert.strictEqual(result, "taskGroupValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('taskGroup', () => { - const fakePath = "/rendered/path/taskGroup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - task_group: "taskGroupValue", - }; - const client = new batchserviceModule.v1alpha.BatchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.taskGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskGroupPath', () => { - const result = client.taskGroupPath("projectValue", "locationValue", "jobValue", "taskGroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskGroupName', () => { - const result = client.matchProjectFromTaskGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskGroupName', () => { - const result = client.matchLocationFromTaskGroupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromTaskGroupName', () => { - const result = client.matchJobFromTaskGroupName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskGroupFromTaskGroupName', () => { - const result = client.matchTaskGroupFromTaskGroupName(fakePath); - assert.strictEqual(result, "taskGroupValue"); - assert((client.pathTemplates.taskGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-batch/v1alpha/tsconfig.json b/owl-bot-staging/google-cloud-batch/v1alpha/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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-batch/v1alpha/webpack.config.js b/owl-bot-staging/google-cloud-batch/v1alpha/webpack.config.js deleted file mode 100644 index 04a4c53960a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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: 'BatchService', - filename: './batch-service.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-batch/.jsdoc.js b/packages/google-cloud-batch/.jsdoc.js index b3e5d7c63ae..bbbfb44aa99 100644 --- a/packages/google-cloud-batch/.jsdoc.js +++ b/packages/google-cloud-batch/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2022 Google LLC', + copyright: 'Copyright 2023 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/batch', diff --git a/packages/google-cloud-batch/.mocharc.js b/packages/google-cloud-batch/.mocharc.js index cdb7b752160..49e7e228701 100644 --- a/packages/google-cloud-batch/.mocharc.js +++ b/packages/google-cloud-batch/.mocharc.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/.prettierrc.js b/packages/google-cloud-batch/.prettierrc.js index d546a4ad546..1e6cec783e4 100644 --- a/packages/google-cloud-batch/.prettierrc.js +++ b/packages/google-cloud-batch/.prettierrc.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/protos/google/cloud/batch/v1/task.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1/task.proto index 3c6251b94ed..1085bfcb083 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1/task.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1/task.proto @@ -291,6 +291,23 @@ message Task { // An Environment describes a collection of environment variables to set when // executing Tasks. message Environment { + message KMSEnvMap { + // The name of the KMS key that will be used to decrypt the cipher text. + string key_name = 1; + + // The value of the cipherText response from the `encrypt` method. + string cipher_text = 2; + } + // A map of environment variable names to values. map variables = 1; + + // A map of environment variable names to Secret Manager secret names. + // The VM will access the named secrets to set the value of each environment + // variable. + map secret_variables = 2; + + // An encrypted JSON dictionary where the key/value pairs correspond to + // environment variable names and their values. + KMSEnvMap encrypted_variables = 3; } diff --git a/packages/google-cloud-batch/protos/protos.d.ts b/packages/google-cloud-batch/protos/protos.d.ts index fb3a014beed..161f4005520 100644 --- a/packages/google-cloud-batch/protos/protos.d.ts +++ b/packages/google-cloud-batch/protos/protos.d.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -4638,6 +4638,12 @@ export namespace google { /** Environment variables */ variables?: ({ [k: string]: string }|null); + + /** Environment secretVariables */ + secretVariables?: ({ [k: string]: string }|null); + + /** Environment encryptedVariables */ + encryptedVariables?: (google.cloud.batch.v1.Environment.IKMSEnvMap|null); } /** Represents an Environment. */ @@ -4652,6 +4658,12 @@ export namespace google { /** Environment variables. */ public variables: { [k: string]: string }; + /** Environment secretVariables. */ + public secretVariables: { [k: string]: string }; + + /** Environment encryptedVariables. */ + public encryptedVariables?: (google.cloud.batch.v1.Environment.IKMSEnvMap|null); + /** * Creates a new Environment instance using the specified properties. * @param [properties] Properties to set @@ -4730,6 +4742,112 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace Environment { + + /** Properties of a KMSEnvMap. */ + interface IKMSEnvMap { + + /** KMSEnvMap keyName */ + keyName?: (string|null); + + /** KMSEnvMap cipherText */ + cipherText?: (string|null); + } + + /** Represents a KMSEnvMap. */ + class KMSEnvMap implements IKMSEnvMap { + + /** + * Constructs a new KMSEnvMap. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.batch.v1.Environment.IKMSEnvMap); + + /** KMSEnvMap keyName. */ + public keyName: string; + + /** KMSEnvMap cipherText. */ + public cipherText: string; + + /** + * Creates a new KMSEnvMap instance using the specified properties. + * @param [properties] Properties to set + * @returns KMSEnvMap instance + */ + public static create(properties?: google.cloud.batch.v1.Environment.IKMSEnvMap): google.cloud.batch.v1.Environment.KMSEnvMap; + + /** + * Encodes the specified KMSEnvMap message. Does not implicitly {@link google.cloud.batch.v1.Environment.KMSEnvMap.verify|verify} messages. + * @param message KMSEnvMap message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.batch.v1.Environment.IKMSEnvMap, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified KMSEnvMap message, length delimited. Does not implicitly {@link google.cloud.batch.v1.Environment.KMSEnvMap.verify|verify} messages. + * @param message KMSEnvMap message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.batch.v1.Environment.IKMSEnvMap, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a KMSEnvMap message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns KMSEnvMap + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.batch.v1.Environment.KMSEnvMap; + + /** + * Decodes a KMSEnvMap message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns KMSEnvMap + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.batch.v1.Environment.KMSEnvMap; + + /** + * Verifies a KMSEnvMap message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a KMSEnvMap message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns KMSEnvMap + */ + public static fromObject(object: { [k: string]: any }): google.cloud.batch.v1.Environment.KMSEnvMap; + + /** + * Creates a plain object from a KMSEnvMap message. Also converts values to other types if specified. + * @param message KMSEnvMap + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.batch.v1.Environment.KMSEnvMap, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this KMSEnvMap to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for KMSEnvMap + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a Volume. */ interface IVolume { diff --git a/packages/google-cloud-batch/protos/protos.js b/packages/google-cloud-batch/protos/protos.js index c76914c6e78..fd3fecdc0b7 100644 --- a/packages/google-cloud-batch/protos/protos.js +++ b/packages/google-cloud-batch/protos/protos.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11956,6 +11956,8 @@ * @memberof google.cloud.batch.v1 * @interface IEnvironment * @property {Object.|null} [variables] Environment variables + * @property {Object.|null} [secretVariables] Environment secretVariables + * @property {google.cloud.batch.v1.Environment.IKMSEnvMap|null} [encryptedVariables] Environment encryptedVariables */ /** @@ -11968,6 +11970,7 @@ */ function Environment(properties) { this.variables = {}; + this.secretVariables = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -11982,6 +11985,22 @@ */ Environment.prototype.variables = $util.emptyObject; + /** + * Environment secretVariables. + * @member {Object.} secretVariables + * @memberof google.cloud.batch.v1.Environment + * @instance + */ + Environment.prototype.secretVariables = $util.emptyObject; + + /** + * Environment encryptedVariables. + * @member {google.cloud.batch.v1.Environment.IKMSEnvMap|null|undefined} encryptedVariables + * @memberof google.cloud.batch.v1.Environment + * @instance + */ + Environment.prototype.encryptedVariables = null; + /** * Creates a new Environment instance using the specified properties. * @function create @@ -12009,6 +12028,11 @@ if (message.variables != null && Object.hasOwnProperty.call(message, "variables")) for (var keys = Object.keys(message.variables), i = 0; i < keys.length; ++i) writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.variables[keys[i]]).ldelim(); + if (message.secretVariables != null && Object.hasOwnProperty.call(message, "secretVariables")) + for (var keys = Object.keys(message.secretVariables), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.secretVariables[keys[i]]).ldelim(); + if (message.encryptedVariables != null && Object.hasOwnProperty.call(message, "encryptedVariables")) + $root.google.cloud.batch.v1.Environment.KMSEnvMap.encode(message.encryptedVariables, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -12066,6 +12090,33 @@ message.variables[key] = value; break; } + case 2: { + if (message.secretVariables === $util.emptyObject) + message.secretVariables = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.secretVariables[key] = value; + break; + } + case 3: { + message.encryptedVariables = $root.google.cloud.batch.v1.Environment.KMSEnvMap.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -12109,6 +12160,19 @@ if (!$util.isString(message.variables[key[i]])) return "variables: string{k:string} expected"; } + if (message.secretVariables != null && message.hasOwnProperty("secretVariables")) { + if (!$util.isObject(message.secretVariables)) + return "secretVariables: object expected"; + var key = Object.keys(message.secretVariables); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.secretVariables[key[i]])) + return "secretVariables: string{k:string} expected"; + } + if (message.encryptedVariables != null && message.hasOwnProperty("encryptedVariables")) { + var error = $root.google.cloud.batch.v1.Environment.KMSEnvMap.verify(message.encryptedVariables); + if (error) + return "encryptedVariables." + error; + } return null; }; @@ -12131,6 +12195,18 @@ for (var keys = Object.keys(object.variables), i = 0; i < keys.length; ++i) message.variables[keys[i]] = String(object.variables[keys[i]]); } + if (object.secretVariables) { + if (typeof object.secretVariables !== "object") + throw TypeError(".google.cloud.batch.v1.Environment.secretVariables: object expected"); + message.secretVariables = {}; + for (var keys = Object.keys(object.secretVariables), i = 0; i < keys.length; ++i) + message.secretVariables[keys[i]] = String(object.secretVariables[keys[i]]); + } + if (object.encryptedVariables != null) { + if (typeof object.encryptedVariables !== "object") + throw TypeError(".google.cloud.batch.v1.Environment.encryptedVariables: object expected"); + message.encryptedVariables = $root.google.cloud.batch.v1.Environment.KMSEnvMap.fromObject(object.encryptedVariables); + } return message; }; @@ -12147,14 +12223,25 @@ if (!options) options = {}; var object = {}; - if (options.objects || options.defaults) + if (options.objects || options.defaults) { object.variables = {}; + object.secretVariables = {}; + } + if (options.defaults) + object.encryptedVariables = null; var keys2; if (message.variables && (keys2 = Object.keys(message.variables)).length) { object.variables = {}; for (var j = 0; j < keys2.length; ++j) object.variables[keys2[j]] = message.variables[keys2[j]]; } + if (message.secretVariables && (keys2 = Object.keys(message.secretVariables)).length) { + object.secretVariables = {}; + for (var j = 0; j < keys2.length; ++j) + object.secretVariables[keys2[j]] = message.secretVariables[keys2[j]]; + } + if (message.encryptedVariables != null && message.hasOwnProperty("encryptedVariables")) + object.encryptedVariables = $root.google.cloud.batch.v1.Environment.KMSEnvMap.toObject(message.encryptedVariables, options); return object; }; @@ -12184,6 +12271,233 @@ return typeUrlPrefix + "/google.cloud.batch.v1.Environment"; }; + Environment.KMSEnvMap = (function() { + + /** + * Properties of a KMSEnvMap. + * @memberof google.cloud.batch.v1.Environment + * @interface IKMSEnvMap + * @property {string|null} [keyName] KMSEnvMap keyName + * @property {string|null} [cipherText] KMSEnvMap cipherText + */ + + /** + * Constructs a new KMSEnvMap. + * @memberof google.cloud.batch.v1.Environment + * @classdesc Represents a KMSEnvMap. + * @implements IKMSEnvMap + * @constructor + * @param {google.cloud.batch.v1.Environment.IKMSEnvMap=} [properties] Properties to set + */ + function KMSEnvMap(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * KMSEnvMap keyName. + * @member {string} keyName + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @instance + */ + KMSEnvMap.prototype.keyName = ""; + + /** + * KMSEnvMap cipherText. + * @member {string} cipherText + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @instance + */ + KMSEnvMap.prototype.cipherText = ""; + + /** + * Creates a new KMSEnvMap instance using the specified properties. + * @function create + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {google.cloud.batch.v1.Environment.IKMSEnvMap=} [properties] Properties to set + * @returns {google.cloud.batch.v1.Environment.KMSEnvMap} KMSEnvMap instance + */ + KMSEnvMap.create = function create(properties) { + return new KMSEnvMap(properties); + }; + + /** + * Encodes the specified KMSEnvMap message. Does not implicitly {@link google.cloud.batch.v1.Environment.KMSEnvMap.verify|verify} messages. + * @function encode + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {google.cloud.batch.v1.Environment.IKMSEnvMap} message KMSEnvMap message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KMSEnvMap.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.keyName != null && Object.hasOwnProperty.call(message, "keyName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.keyName); + if (message.cipherText != null && Object.hasOwnProperty.call(message, "cipherText")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.cipherText); + return writer; + }; + + /** + * Encodes the specified KMSEnvMap message, length delimited. Does not implicitly {@link google.cloud.batch.v1.Environment.KMSEnvMap.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {google.cloud.batch.v1.Environment.IKMSEnvMap} message KMSEnvMap message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KMSEnvMap.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KMSEnvMap message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.batch.v1.Environment.KMSEnvMap} KMSEnvMap + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KMSEnvMap.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.batch.v1.Environment.KMSEnvMap(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.keyName = reader.string(); + break; + } + case 2: { + message.cipherText = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KMSEnvMap message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.batch.v1.Environment.KMSEnvMap} KMSEnvMap + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KMSEnvMap.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KMSEnvMap message. + * @function verify + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KMSEnvMap.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.keyName != null && message.hasOwnProperty("keyName")) + if (!$util.isString(message.keyName)) + return "keyName: string expected"; + if (message.cipherText != null && message.hasOwnProperty("cipherText")) + if (!$util.isString(message.cipherText)) + return "cipherText: string expected"; + return null; + }; + + /** + * Creates a KMSEnvMap message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.batch.v1.Environment.KMSEnvMap} KMSEnvMap + */ + KMSEnvMap.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.batch.v1.Environment.KMSEnvMap) + return object; + var message = new $root.google.cloud.batch.v1.Environment.KMSEnvMap(); + if (object.keyName != null) + message.keyName = String(object.keyName); + if (object.cipherText != null) + message.cipherText = String(object.cipherText); + return message; + }; + + /** + * Creates a plain object from a KMSEnvMap message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {google.cloud.batch.v1.Environment.KMSEnvMap} message KMSEnvMap + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KMSEnvMap.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.keyName = ""; + object.cipherText = ""; + } + if (message.keyName != null && message.hasOwnProperty("keyName")) + object.keyName = message.keyName; + if (message.cipherText != null && message.hasOwnProperty("cipherText")) + object.cipherText = message.cipherText; + return object; + }; + + /** + * Converts this KMSEnvMap to JSON. + * @function toJSON + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @instance + * @returns {Object.} JSON object + */ + KMSEnvMap.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for KMSEnvMap + * @function getTypeUrl + * @memberof google.cloud.batch.v1.Environment.KMSEnvMap + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + KMSEnvMap.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.batch.v1.Environment.KMSEnvMap"; + }; + + return KMSEnvMap; + })(); + return Environment; })(); diff --git a/packages/google-cloud-batch/protos/protos.json b/packages/google-cloud-batch/protos/protos.json index d3eb48b0b32..c0d282a92ee 100644 --- a/packages/google-cloud-batch/protos/protos.json +++ b/packages/google-cloud-batch/protos/protos.json @@ -1076,6 +1076,29 @@ "keyType": "string", "type": "string", "id": 1 + }, + "secretVariables": { + "keyType": "string", + "type": "string", + "id": 2 + }, + "encryptedVariables": { + "type": "KMSEnvMap", + "id": 3 + } + }, + "nested": { + "KMSEnvMap": { + "fields": { + "keyName": { + "type": "string", + "id": 1 + }, + "cipherText": { + "type": "string", + "id": 2 + } + } } } }, diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js index 92cc56148bd..4de994b2f73 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js index f5a679f29c2..e19a6808169 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js index f00f7476d5f..c45a5b7f46d 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js index f77cf86c93d..12a0c45a2a5 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js index 87522e36db6..10807d04141 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js index bafcb06548a..2c53d7f22ce 100644 --- a/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js +++ b/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/src/index.ts b/packages/google-cloud-batch/src/index.ts index cabf816af03..b359fb00ae5 100644 --- a/packages/google-cloud-batch/src/index.ts +++ b/packages/google-cloud-batch/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/src/v1/batch_service_client.ts b/packages/google-cloud-batch/src/v1/batch_service_client.ts index ad9412d0771..7011f4b7da8 100644 --- a/packages/google-cloud-batch/src/v1/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1/batch_service_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/src/v1/index.ts b/packages/google-cloud-batch/src/v1/index.ts index 0f129526252..20125bdd61d 100644 --- a/packages/google-cloud-batch/src/v1/index.ts +++ b/packages/google-cloud-batch/src/v1/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/system-test/fixtures/sample/src/index.js b/packages/google-cloud-batch/system-test/fixtures/sample/src/index.js index 2e35c26c93d..b29a8bdc32f 100644 --- a/packages/google-cloud-batch/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-batch/system-test/fixtures/sample/src/index.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-batch/system-test/fixtures/sample/src/index.ts index a09668ae84d..a704285f484 100644 --- a/packages/google-cloud-batch/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-batch/system-test/fixtures/sample/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/system-test/install.ts b/packages/google-cloud-batch/system-test/install.ts index 6dd1eaadafa..f61fe236476 100644 --- a/packages/google-cloud-batch/system-test/install.ts +++ b/packages/google-cloud-batch/system-test/install.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-batch/test/gapic_batch_service_v1.ts b/packages/google-cloud-batch/test/gapic_batch_service_v1.ts index efe552ed992..288cfa0933d 100644 --- a/packages/google-cloud-batch/test/gapic_batch_service_v1.ts +++ b/packages/google-cloud-batch/test/gapic_batch_service_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.