From 9a9f6732246c5b59bd05202911f7373852519d61 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 17 Apr 2023 19:52:51 +0000 Subject: [PATCH 01/13] feat: add TaskStatus's new terminated state UNEXECUTED feat: add scheduling_policy IN_ORDER enum to support sequential task executions docs: update comments on boot disk fields for clearer usage scope feat: add support for placement policies docs: update block_external_network field comment to reduce confusion docs: update disk and network field comment for better readability docs: fix `book disk` typo docs: Update reservation field API doc PiperOrigin-RevId: 524883955 Source-Link: https://github.com/googleapis/googleapis/commit/0830aaf0eaf5ef3615cb2f9c4ef81c73c319e1a7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/a294b7e89acf09c4801b672d36aa171f9bd69403 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJhMjk0YjdlODlhY2YwOWM0ODAxYjY3MmQzNmFhMTcxZjliZDY5NDAzIn0= --- .../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 | 270 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 506 +++++ .../protos/google/cloud/batch/v1/task.proto | 333 +++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../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 | 270 +++ .../google/cloud/batch/v1alpha/job.proto | 655 ++++++ .../google/cloud/batch/v1alpha/task.proto | 355 ++++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12143 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..d4f03a0df2e --- /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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..91b43dd9dc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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 + // the 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 + // the 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..4bed626c1ac --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,506 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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. + // For example, the following are all valid URLs: + // (1) Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // (2) Specify the image version: + // projects/{project}/global/images/{image_version} + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // "batch-debian": use Batch Debian images. + // "batch-centos": use Batch CentOS images. + // "batch-cos": use Batch Container-Optimized images. + 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, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // 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; + } + + // 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; + + // 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/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..62e982976c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,333 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..8447d992c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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..de0c6885153 --- /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 + * the 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..6e2ad9b9488 --- /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 + * the 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..8c8493c6038 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 + * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 + * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..f70983ca35f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,1835 @@ +// 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, 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('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..d4f03a0df2e --- /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..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..33cccba15f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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 + // the 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 + // the 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..c4a2201cfbc --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,655 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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; + + // The resource usage of the job. + ResourceUsage resource_usage = 6; +} + +// ResourceUsage describes the resource usage of the job. +message ResourceUsage { + // The CPU core hours that the job consumes. + double core_hours = 1; +} + +// 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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 consume only the specified reservation. + // If not specified (default), VMs will consume any applicable 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. + AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; + } + + // 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. + 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..c7db752b26a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,355 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; + + // The resource usage of the task. + TaskResourceUsage resource_usage = 3; +} + +// TaskResourceUsage describes the resource usage of the task. +message TaskResourceUsage { + // The CPU core hours the task consumes based on task requirement and run + // time. + double core_hours = 1; +} + +// 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..5b3d72a7e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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..1ca515333b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..3458538cfae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..92c74b3b847 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..83c71aecb81 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..b94896ae5ee --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..efaa5a22b2d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..0395a498ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 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..201402b028c --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 + * {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..b8c39b803c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,1835 @@ +// 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, 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('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 e7c2f12005059d4515a5fb06ef0eef2ec3c86f4f Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 17 Apr 2023 19:57:53 +0000 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 | 270 --- .../v1/protos/google/cloud/batch/v1/job.proto | 506 ----- .../protos/google/cloud/batch/v1/task.proto | 333 --- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../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 | 270 --- .../google/cloud/batch/v1alpha/job.proto | 655 ------ .../google/cloud/batch/v1alpha/task.proto | 355 ---- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../google/cloud/batch/v1alpha/job.proto | 75 +- .../google/cloud/batch/v1alpha/task.proto | 10 +- .../google-cloud-batch/protos/protos.d.ts | 115 +- packages/google-cloud-batch/protos/protos.js | 293 +++ .../google-cloud-batch/protos/protos.json | 22 +- ...nippet_metadata.google.cloud.batch.v1.json | 2 +- ...t_metadata.google.cloud.batch.v1alpha.json | 2 +- .../src/v1alpha/batch_service_client.ts | 9 - 72 files changed, 494 insertions(+), 12177 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 d4f03a0df2e..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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 91b43dd9dc3..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 - // the 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 - // the 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 4bed626c1ac..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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. - // For example, the following are all valid URLs: - // (1) Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // (2) Specify the image version: - // projects/{project}/global/images/{image_version} - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // "batch-debian": use Batch Debian images. - // "batch-centos": use Batch CentOS images. - // "batch-cos": use Batch Container-Optimized images. - 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, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // 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; - } - - // 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; - - // 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/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 62e982976c5..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 8447d992c48..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 de0c6885153..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 - * the 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 6e2ad9b9488..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 - * the 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 8c8493c6038..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 - * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 - * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 f70983ca35f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,1835 +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, 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('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 d4f03a0df2e..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 bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 33cccba15f2..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 - // the 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 - // the 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 c4a2201cfbc..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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; - - // The resource usage of the job. - ResourceUsage resource_usage = 6; -} - -// ResourceUsage describes the resource usage of the job. -message ResourceUsage { - // The CPU core hours that the job consumes. - double core_hours = 1; -} - -// 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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 consume only the specified reservation. - // If not specified (default), VMs will consume any applicable 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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. - // - // Tasks might be executed in parallel depending on parallelism and - // task_count values. - AS_SOON_AS_POSSIBLE = 1; - - // Run Tasks sequentially with increased task index. - // - // Not yet implemented. - IN_ORDER = 2; - } - - // 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - // The default value is AS_SOON_AS_POSSIBLE. - 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 c7db752b26a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; - - // The resource usage of the task. - TaskResourceUsage resource_usage = 3; -} - -// TaskResourceUsage describes the resource usage of the task. -message TaskResourceUsage { - // The CPU core hours the task consumes based on task requirement and run - // time. - double core_hours = 1; -} - -// 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 5b3d72a7e80..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 1ca515333b0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 3458538cfae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 92c74b3b847..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 83c71aecb81..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 b94896ae5ee..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 efaa5a22b2d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 0395a498ffb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 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 201402b028c..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 - * {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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 ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 b8c39b803c0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,1835 +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, 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('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/protos/google/cloud/batch/v1alpha/job.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/job.proto index 9dc6dc85fbe..c4a2201cfbc 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/job.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/job.proto @@ -284,12 +284,14 @@ message JobNotification { 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", @@ -305,25 +307,29 @@ message AllocationPolicy { // 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and // 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. // For example, the following are all valid URLs: - // (1) Specify the image by its family name: + // + // * Specify the image by its family name: // projects/{project}/global/images/family/{image_family} - // (2) Specify the image version: + // * Specify the image version: // projects/{project}/global/images/{image_version} + // // You can also use Batch customized image in short names. // The following image values are supported for a boot disk: - // "batch-debian": use Batch Debian images. - // "batch-centos": use Batch CentOS images. - // "batch-cos": use Batch Container-Optimized images. + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. string image = 4; // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. string snapshot = 5; } @@ -334,6 +340,7 @@ message AllocationPolicy { string type = 1; // Disk size in GB. + // // For persistent disk, this field is ignored if `data_source` is `image` or // `snapshot`. // For local SSD, size_gb should be a multiple of 375GB, @@ -391,7 +398,7 @@ message AllocationPolicy { // The minimum CPU platform. // See - // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. + // https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform. // Not yet implemented. string min_cpu_platform = 3; @@ -401,15 +408,17 @@ message AllocationPolicy { // 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 to be created and attached to each VM by this InstancePolicy. // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. 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. + // If specified, VMs will consume only the specified reservation. + // If not specified (default), VMs will consume any applicable reservation. string reservation = 7; } @@ -436,18 +445,22 @@ message AllocationPolicy { 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} + // + // * 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} + // + // * 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 @@ -466,6 +479,23 @@ message AllocationPolicy { repeated NetworkInterface network_interfaces = 1; } + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + // Compute Engine VM instance provisioning model. enum ProvisioningModel { // Unspecified. @@ -519,6 +549,9 @@ message AllocationPolicy { // The network policy. NetworkPolicy network = 7; + + // The placement policy. + PlacementPolicy placement = 10; } // A TaskGroup contains one or multiple Tasks that share the same @@ -535,7 +568,15 @@ message TaskGroup { SCHEDULING_POLICY_UNSPECIFIED = 0; // Run Tasks as soon as resources are available. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; } // Output only. TaskGroup name. @@ -548,14 +589,16 @@ message TaskGroup { TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; // Number of Tasks in the TaskGroup. - // default is 1 + // Default is 1. int64 task_count = 4; // Max number of tasks that can run in parallel. // Default to min(task_count, 1000). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. int64 parallelism = 5; // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. SchedulingPolicy scheduling_policy = 6; // Compute resource allocation for the TaskGroup. diff --git a/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/task.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/task.proto index b31bd9eda59..c7db752b26a 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/task.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/task.proto @@ -77,7 +77,7 @@ message TaskExecution { message TaskStatus { // Task states. enum State { - // unknown state + // Unknown state. STATE_UNSPECIFIED = 0; // The Task is created and waiting for resources. @@ -94,6 +94,9 @@ message TaskStatus { // The Task has succeeded. SUCCEEDED = 5; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; } // Task state @@ -139,8 +142,9 @@ message Runnable { 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'. + // blocked, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. bool block_external_network = 9; // Optional username for logging in to a docker registry. If username diff --git a/packages/google-cloud-batch/protos/protos.d.ts b/packages/google-cloud-batch/protos/protos.d.ts index d71a32d652a..b1abfe3dc1c 100644 --- a/packages/google-cloud-batch/protos/protos.d.ts +++ b/packages/google-cloud-batch/protos/protos.d.ts @@ -7455,6 +7455,9 @@ export namespace google { /** AllocationPolicy network */ network?: (google.cloud.batch.v1alpha.AllocationPolicy.INetworkPolicy|null); + + /** AllocationPolicy placement */ + placement?: (google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy|null); } /** Represents an AllocationPolicy. */ @@ -7493,6 +7496,9 @@ export namespace google { /** AllocationPolicy network. */ public network?: (google.cloud.batch.v1alpha.AllocationPolicy.INetworkPolicy|null); + /** AllocationPolicy placement. */ + public placement?: (google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy|null); + /** * Creates a new AllocationPolicy instance using the specified properties. * @param [properties] Properties to set @@ -8478,6 +8484,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a PlacementPolicy. */ + interface IPlacementPolicy { + + /** PlacementPolicy collocation */ + collocation?: (string|null); + + /** PlacementPolicy maxDistance */ + maxDistance?: (number|Long|string|null); + } + + /** Represents a PlacementPolicy. */ + class PlacementPolicy implements IPlacementPolicy { + + /** + * Constructs a new PlacementPolicy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy); + + /** PlacementPolicy collocation. */ + public collocation: string; + + /** PlacementPolicy maxDistance. */ + public maxDistance: (number|Long|string); + + /** + * Creates a new PlacementPolicy instance using the specified properties. + * @param [properties] Properties to set + * @returns PlacementPolicy instance + */ + public static create(properties?: google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy): google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy; + + /** + * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @param message PlacementPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @param message PlacementPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PlacementPolicy + * @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.v1alpha.AllocationPolicy.PlacementPolicy; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PlacementPolicy + * @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.v1alpha.AllocationPolicy.PlacementPolicy; + + /** + * Verifies a PlacementPolicy 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 PlacementPolicy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PlacementPolicy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy; + + /** + * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. + * @param message PlacementPolicy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PlacementPolicy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PlacementPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** ProvisioningModel enum. */ enum ProvisioningModel { PROVISIONING_MODEL_UNSPECIFIED = 0, @@ -8649,7 +8758,8 @@ export namespace google { /** SchedulingPolicy enum. */ enum SchedulingPolicy { SCHEDULING_POLICY_UNSPECIFIED = 0, - AS_SOON_AS_POSSIBLE = 1 + AS_SOON_AS_POSSIBLE = 1, + IN_ORDER = 2 } } @@ -9207,7 +9317,8 @@ export namespace google { ASSIGNED = 2, RUNNING = 3, FAILED = 4, - SUCCEEDED = 5 + SUCCEEDED = 5, + UNEXECUTED = 6 } } diff --git a/packages/google-cloud-batch/protos/protos.js b/packages/google-cloud-batch/protos/protos.js index b47b7031c1c..bb358839568 100644 --- a/packages/google-cloud-batch/protos/protos.js +++ b/packages/google-cloud-batch/protos/protos.js @@ -19009,6 +19009,7 @@ case 3: case 4: case 5: + case 6: break; } return null; @@ -19113,6 +19114,10 @@ case 5: message.newTaskState = 5; break; + case "UNEXECUTED": + case 6: + message.newTaskState = 6; + break; } return message; }; @@ -19207,6 +19212,7 @@ * @property {google.cloud.batch.v1alpha.IServiceAccount|null} [serviceAccount] AllocationPolicy serviceAccount * @property {Object.|null} [labels] AllocationPolicy labels * @property {google.cloud.batch.v1alpha.AllocationPolicy.INetworkPolicy|null} [network] AllocationPolicy network + * @property {google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy|null} [placement] AllocationPolicy placement */ /** @@ -19300,6 +19306,14 @@ */ AllocationPolicy.prototype.network = null; + /** + * AllocationPolicy placement. + * @member {google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy|null|undefined} placement + * @memberof google.cloud.batch.v1alpha.AllocationPolicy + * @instance + */ + AllocationPolicy.prototype.placement = null; + /** * Creates a new AllocationPolicy instance using the specified properties. * @function create @@ -19349,6 +19363,8 @@ $root.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate.encode(message.instances[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) $root.google.cloud.batch.v1alpha.ServiceAccount.encode(message.serviceAccount, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.encode(message.placement, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -19449,6 +19465,10 @@ message.network = $root.google.cloud.batch.v1alpha.AllocationPolicy.NetworkPolicy.decode(reader, reader.uint32()); break; } + case 10: { + message.placement = $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -19545,6 +19565,11 @@ if (error) return "network." + error; } + if (message.placement != null && message.hasOwnProperty("placement")) { + var error = $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.verify(message.placement); + if (error) + return "placement." + error; + } return null; }; @@ -19635,6 +19660,11 @@ throw TypeError(".google.cloud.batch.v1alpha.AllocationPolicy.network: object expected"); message.network = $root.google.cloud.batch.v1alpha.AllocationPolicy.NetworkPolicy.fromObject(object.network); } + if (object.placement != null) { + if (typeof object.placement !== "object") + throw TypeError(".google.cloud.batch.v1alpha.AllocationPolicy.placement: object expected"); + message.placement = $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.fromObject(object.placement); + } return message; }; @@ -19664,6 +19694,7 @@ object.serviceAccountEmail = ""; object.network = null; object.serviceAccount = null; + object.placement = null; } if (message.location != null && message.hasOwnProperty("location")) object.location = $root.google.cloud.batch.v1alpha.AllocationPolicy.LocationPolicy.toObject(message.location, options); @@ -19696,6 +19727,8 @@ } if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) object.serviceAccount = $root.google.cloud.batch.v1alpha.ServiceAccount.toObject(message.serviceAccount, options); + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.toObject(message.placement, options); return object; }; @@ -22076,6 +22109,247 @@ return NetworkPolicy; })(); + AllocationPolicy.PlacementPolicy = (function() { + + /** + * Properties of a PlacementPolicy. + * @memberof google.cloud.batch.v1alpha.AllocationPolicy + * @interface IPlacementPolicy + * @property {string|null} [collocation] PlacementPolicy collocation + * @property {number|Long|null} [maxDistance] PlacementPolicy maxDistance + */ + + /** + * Constructs a new PlacementPolicy. + * @memberof google.cloud.batch.v1alpha.AllocationPolicy + * @classdesc Represents a PlacementPolicy. + * @implements IPlacementPolicy + * @constructor + * @param {google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set + */ + function PlacementPolicy(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]]; + } + + /** + * PlacementPolicy collocation. + * @member {string} collocation + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @instance + */ + PlacementPolicy.prototype.collocation = ""; + + /** + * PlacementPolicy maxDistance. + * @member {number|Long} maxDistance + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @instance + */ + PlacementPolicy.prototype.maxDistance = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PlacementPolicy instance using the specified properties. + * @function create + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set + * @returns {google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy} PlacementPolicy instance + */ + PlacementPolicy.create = function create(properties) { + return new PlacementPolicy(properties); + }; + + /** + * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @function encode + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlacementPolicy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.collocation != null && Object.hasOwnProperty.call(message, "collocation")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.collocation); + if (message.maxDistance != null && Object.hasOwnProperty.call(message, "maxDistance")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.maxDistance); + return writer; + }; + + /** + * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1alpha.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlacementPolicy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy} PlacementPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlacementPolicy.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.v1alpha.AllocationPolicy.PlacementPolicy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.collocation = reader.string(); + break; + } + case 2: { + message.maxDistance = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy} PlacementPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlacementPolicy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PlacementPolicy message. + * @function verify + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PlacementPolicy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.collocation != null && message.hasOwnProperty("collocation")) + if (!$util.isString(message.collocation)) + return "collocation: string expected"; + if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) + if (!$util.isInteger(message.maxDistance) && !(message.maxDistance && $util.isInteger(message.maxDistance.low) && $util.isInteger(message.maxDistance.high))) + return "maxDistance: integer|Long expected"; + return null; + }; + + /** + * Creates a PlacementPolicy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy} PlacementPolicy + */ + PlacementPolicy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy) + return object; + var message = new $root.google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy(); + if (object.collocation != null) + message.collocation = String(object.collocation); + if (object.maxDistance != null) + if ($util.Long) + (message.maxDistance = $util.Long.fromValue(object.maxDistance)).unsigned = false; + else if (typeof object.maxDistance === "string") + message.maxDistance = parseInt(object.maxDistance, 10); + else if (typeof object.maxDistance === "number") + message.maxDistance = object.maxDistance; + else if (typeof object.maxDistance === "object") + message.maxDistance = new $util.LongBits(object.maxDistance.low >>> 0, object.maxDistance.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy} message PlacementPolicy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PlacementPolicy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.collocation = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.maxDistance = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.maxDistance = options.longs === String ? "0" : 0; + } + if (message.collocation != null && message.hasOwnProperty("collocation")) + object.collocation = message.collocation; + if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) + if (typeof message.maxDistance === "number") + object.maxDistance = options.longs === String ? String(message.maxDistance) : message.maxDistance; + else + object.maxDistance = options.longs === String ? $util.Long.prototype.toString.call(message.maxDistance) : options.longs === Number ? new $util.LongBits(message.maxDistance.low >>> 0, message.maxDistance.high >>> 0).toNumber() : message.maxDistance; + return object; + }; + + /** + * Converts this PlacementPolicy to JSON. + * @function toJSON + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @instance + * @returns {Object.} JSON object + */ + PlacementPolicy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PlacementPolicy + * @function getTypeUrl + * @memberof google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PlacementPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.batch.v1alpha.AllocationPolicy.PlacementPolicy"; + }; + + return PlacementPolicy; + })(); + /** * ProvisioningModel enum. * @name google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel @@ -22423,6 +22697,7 @@ return "schedulingPolicy: enum value expected"; case 0: case 1: + case 2: break; } if (message.allocationPolicy != null && message.hasOwnProperty("allocationPolicy")) { @@ -22511,6 +22786,10 @@ case 1: message.schedulingPolicy = 1; break; + case "IN_ORDER": + case 2: + message.schedulingPolicy = 2; + break; } if (object.allocationPolicy != null) { if (typeof object.allocationPolicy !== "object") @@ -22663,11 +22942,13 @@ * @enum {number} * @property {number} SCHEDULING_POLICY_UNSPECIFIED=0 SCHEDULING_POLICY_UNSPECIFIED value * @property {number} AS_SOON_AS_POSSIBLE=1 AS_SOON_AS_POSSIBLE value + * @property {number} IN_ORDER=2 IN_ORDER value */ TaskGroup.SchedulingPolicy = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "SCHEDULING_POLICY_UNSPECIFIED"] = 0; values[valuesById[1] = "AS_SOON_AS_POSSIBLE"] = 1; + values[valuesById[2] = "IN_ORDER"] = 2; return values; })(); @@ -23463,6 +23744,7 @@ case 3: case 4: case 5: + case 6: break; } return null; @@ -23525,6 +23807,10 @@ case 5: message.taskState = 5; break; + case "UNEXECUTED": + case 6: + message.taskState = 6; + break; } return message; }; @@ -23969,6 +24255,7 @@ case 3: case 4: case 5: + case 6: break; } if (message.statusEvents != null && message.hasOwnProperty("statusEvents")) { @@ -24031,6 +24318,10 @@ case 5: message.state = 5; break; + case "UNEXECUTED": + case 6: + message.state = 6; + break; } if (object.statusEvents) { if (!Array.isArray(object.statusEvents)) @@ -24117,6 +24408,7 @@ * @property {number} RUNNING=3 RUNNING value * @property {number} FAILED=4 FAILED value * @property {number} SUCCEEDED=5 SUCCEEDED value + * @property {number} UNEXECUTED=6 UNEXECUTED value */ TaskStatus.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -24126,6 +24418,7 @@ values[valuesById[3] = "RUNNING"] = 3; values[valuesById[4] = "FAILED"] = 4; values[valuesById[5] = "SUCCEEDED"] = 5; + values[valuesById[6] = "UNEXECUTED"] = 6; return values; })(); diff --git a/packages/google-cloud-batch/protos/protos.json b/packages/google-cloud-batch/protos/protos.json index 14e79ce555f..ce7eefc7b94 100644 --- a/packages/google-cloud-batch/protos/protos.json +++ b/packages/google-cloud-batch/protos/protos.json @@ -1830,6 +1830,10 @@ "network": { "type": "NetworkPolicy", "id": 7 + }, + "placement": { + "type": "PlacementPolicy", + "id": 10 } }, "nested": { @@ -2013,6 +2017,18 @@ } } }, + "PlacementPolicy": { + "fields": { + "collocation": { + "type": "string", + "id": 1 + }, + "maxDistance": { + "type": "int64", + "id": 2 + } + } + }, "ProvisioningModel": { "values": { "PROVISIONING_MODEL_UNSPECIFIED": 0, @@ -2086,7 +2102,8 @@ "SchedulingPolicy": { "values": { "SCHEDULING_POLICY_UNSPECIFIED": 0, - "AS_SOON_AS_POSSIBLE": 1 + "AS_SOON_AS_POSSIBLE": 1, + "IN_ORDER": 2 } } } @@ -2180,7 +2197,8 @@ "ASSIGNED": 2, "RUNNING": 3, "FAILED": 4, - "SUCCEEDED": 5 + "SUCCEEDED": 5, + "UNEXECUTED": 6 } } } diff --git a/packages/google-cloud-batch/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json b/packages/google-cloud-batch/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json index f954cff303d..ddf569bdb95 100644 --- a/packages/google-cloud-batch/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json +++ b/packages/google-cloud-batch/samples/generated/v1/snippet_metadata.google.cloud.batch.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-batch", - "version": "0.7.0", + "version": "0.7.1", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json b/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json index 0d928f0bee9..4f7ee3e4e84 100644 --- a/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ b/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-batch", - "version": "0.7.0", + "version": "0.7.1", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts index 98c9f553c5a..5a624512545 100644 --- a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts @@ -242,15 +242,6 @@ export class BatchServiceClient { selector: 'google.cloud.location.Locations.ListLocations', get: '/v1alpha/{name=projects/*}/locations', }, - { - 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/*}', From df750ca801ead33e48f51107d44f2885a73b2b2a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 10 May 2023 03:27:30 +0000 Subject: [PATCH 03/13] feat: support order_by in ListJobs and ListTasks requests --- feat: add support for placement policies --- feat: per-Runnable labels PiperOrigin-RevId: 530747589 Source-Link: https://github.com/googleapis/googleapis/commit/d944931a7ef52d980ee57af4308f1eff85468de6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/96b4871e5bb966512145d4199563e16e6e3d3baa Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI5NmI0ODcxZTViYjk2NjUxMjE0NWQ0MTk5NTYzZTE2ZTZlM2QzYmFhIn0= --- .../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 | 270 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 539 +++++ .../protos/google/cloud/batch/v1/task.proto | 340 +++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../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 | 270 +++ .../google/cloud/batch/v1alpha/job.proto | 655 ++++++ .../google/cloud/batch/v1alpha/task.proto | 355 ++++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12183 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..d4f03a0df2e --- /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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..91b43dd9dc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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 + // the 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 + // the 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..32e1fc416d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,539 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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; + } + + // 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + 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; + + // 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/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..b89ba09d0a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,340 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..8447d992c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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..de0c6885153 --- /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 + * the 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..6e2ad9b9488 --- /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 + * the 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..e993318bbc4 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 + * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 + * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..f70983ca35f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,1835 @@ +// 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, 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('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..d4f03a0df2e --- /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..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..33cccba15f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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 + // the 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 + // the 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..c4a2201cfbc --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,655 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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; + + // The resource usage of the job. + ResourceUsage resource_usage = 6; +} + +// ResourceUsage describes the resource usage of the job. +message ResourceUsage { + // The CPU core hours that the job consumes. + double core_hours = 1; +} + +// 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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 consume only the specified reservation. + // If not specified (default), VMs will consume any applicable 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. + AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; + } + + // 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. + 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..c7db752b26a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,355 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; + + // The resource usage of the task. + TaskResourceUsage resource_usage = 3; +} + +// TaskResourceUsage describes the resource usage of the task. +message TaskResourceUsage { + // The CPU core hours the task consumes based on task requirement and run + // time. + double core_hours = 1; +} + +// 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..5b3d72a7e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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..1ca515333b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..3458538cfae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..92c74b3b847 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..83c71aecb81 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..b94896ae5ee --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..efaa5a22b2d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..0395a498ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 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..201402b028c --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 + * {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..b8c39b803c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,1835 @@ +// 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, 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('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 92ab660a2cae2497c1c382d41295a497c3d54dfb Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 10 May 2023 03:33:28 +0000 Subject: [PATCH 04/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 | 270 --- .../v1/protos/google/cloud/batch/v1/job.proto | 539 ----- .../protos/google/cloud/batch/v1/task.proto | 340 --- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../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 | 270 --- .../google/cloud/batch/v1alpha/job.proto | 655 ------ .../google/cloud/batch/v1alpha/task.proto | 355 ---- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../protos/google/cloud/batch/v1/job.proto | 63 +- .../protos/google/cloud/batch/v1/task.proto | 13 +- .../google-cloud-batch/protos/protos.d.ts | 118 +- packages/google-cloud-batch/protos/protos.js | 347 +++- .../google-cloud-batch/protos/protos.json | 24 +- .../src/v1/batch_service_client.ts | 9 - 70 files changed, 544 insertions(+), 12213 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 d4f03a0df2e..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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 91b43dd9dc3..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 - // the 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 - // the 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 32e1fc416d2..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,539 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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; - } - - // 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - 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; - - // 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/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 b89ba09d0a1..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 8447d992c48..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 de0c6885153..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 - * the 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 6e2ad9b9488..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 - * the 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 e993318bbc4..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 - * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 - * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 f70983ca35f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,1835 +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, 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('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 d4f03a0df2e..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 bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 33cccba15f2..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 - // the 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 - // the 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 c4a2201cfbc..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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; - - // The resource usage of the job. - ResourceUsage resource_usage = 6; -} - -// ResourceUsage describes the resource usage of the job. -message ResourceUsage { - // The CPU core hours that the job consumes. - double core_hours = 1; -} - -// 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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 consume only the specified reservation. - // If not specified (default), VMs will consume any applicable 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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. - // - // Tasks might be executed in parallel depending on parallelism and - // task_count values. - AS_SOON_AS_POSSIBLE = 1; - - // Run Tasks sequentially with increased task index. - // - // Not yet implemented. - IN_ORDER = 2; - } - - // 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - // The default value is AS_SOON_AS_POSSIBLE. - 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 c7db752b26a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; - - // The resource usage of the task. - TaskResourceUsage resource_usage = 3; -} - -// TaskResourceUsage describes the resource usage of the task. -message TaskResourceUsage { - // The CPU core hours the task consumes based on task requirement and run - // time. - double core_hours = 1; -} - -// 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 5b3d72a7e80..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 1ca515333b0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 3458538cfae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 92c74b3b847..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 83c71aecb81..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 b94896ae5ee..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 efaa5a22b2d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 0395a498ffb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 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 201402b028c..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 - * {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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 ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 b8c39b803c0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,1835 +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, 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('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/protos/google/cloud/batch/v1/job.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto index 4bed626c1ac..32e1fc416d2 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto @@ -225,12 +225,14 @@ message JobNotification { 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", @@ -241,25 +243,29 @@ message AllocationPolicy { // 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and // 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. // For example, the following are all valid URLs: - // (1) Specify the image by its family name: + // + // * Specify the image by its family name: // projects/{project}/global/images/family/{image_family} - // (2) Specify the image version: + // * Specify the image version: // projects/{project}/global/images/{image_version} + // // You can also use Batch customized image in short names. // The following image values are supported for a boot disk: - // "batch-debian": use Batch Debian images. - // "batch-centos": use Batch CentOS images. - // "batch-cos": use Batch Container-Optimized images. + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. string image = 4; // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. string snapshot = 5; } @@ -270,6 +276,7 @@ message AllocationPolicy { string type = 1; // Disk size in GB. + // // For persistent disk, this field is ignored if `data_source` is `image` or // `snapshot`. // For local SSD, size_gb should be a multiple of 375GB, @@ -324,7 +331,7 @@ message AllocationPolicy { // The minimum CPU platform. // See - // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. + // https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform. // Not yet implemented. string min_cpu_platform = 3; @@ -334,8 +341,9 @@ message AllocationPolicy { // 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 to be created and attached to each VM by this InstancePolicy. // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. Disk boot_disk = 8; // Non-boot disks to be attached for each VM created by this InstancePolicy. @@ -366,18 +374,22 @@ message AllocationPolicy { 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} + // + // * 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} + // + // * 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 @@ -396,6 +408,23 @@ message AllocationPolicy { repeated NetworkInterface network_interfaces = 1; } + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + // Compute Engine VM instance provisioning model. enum ProvisioningModel { // Unspecified. @@ -437,6 +466,9 @@ message AllocationPolicy { // The network policy. NetworkPolicy network = 7; + + // The placement policy. + PlacementPolicy placement = 10; } // A TaskGroup contains one or multiple Tasks that share the same @@ -457,11 +489,12 @@ message TaskGroup { TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; // Number of Tasks in the TaskGroup. - // default is 1 + // Default is 1. int64 task_count = 4; // Max number of tasks that can run in parallel. // Default to min(task_count, 1000). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. int64 parallelism = 5; // An array of environment variable mappings, which are passed to Tasks with 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 62e982976c5..b89ba09d0a1 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 @@ -72,7 +72,7 @@ message TaskExecution { message TaskStatus { // Task states. enum State { - // unknown state + // Unknown state. STATE_UNSPECIFIED = 0; // The Task is created and waiting for resources. @@ -89,6 +89,9 @@ message TaskStatus { // The Task has succeeded. SUCCEEDED = 5; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; } // Task state @@ -124,8 +127,9 @@ message Runnable { 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'. + // blocked, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. bool block_external_network = 9; // Optional username for logging in to a docker registry. If username @@ -208,6 +212,9 @@ message Runnable { // Timeout for this Runnable. google.protobuf.Duration timeout = 8; + + // Labels for this Runnable. + map labels = 9; } // Spec of a task diff --git a/packages/google-cloud-batch/protos/protos.d.ts b/packages/google-cloud-batch/protos/protos.d.ts index b1abfe3dc1c..ec3f7ba4c25 100644 --- a/packages/google-cloud-batch/protos/protos.d.ts +++ b/packages/google-cloud-batch/protos/protos.d.ts @@ -2031,6 +2031,9 @@ export namespace google { /** AllocationPolicy network */ network?: (google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null); + + /** AllocationPolicy placement */ + placement?: (google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null); } /** Represents an AllocationPolicy. */ @@ -2057,6 +2060,9 @@ export namespace google { /** AllocationPolicy network. */ public network?: (google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null); + /** AllocationPolicy placement. */ + public placement?: (google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null); + /** * Creates a new AllocationPolicy instance using the specified properties. * @param [properties] Properties to set @@ -3024,6 +3030,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a PlacementPolicy. */ + interface IPlacementPolicy { + + /** PlacementPolicy collocation */ + collocation?: (string|null); + + /** PlacementPolicy maxDistance */ + maxDistance?: (number|Long|string|null); + } + + /** Represents a PlacementPolicy. */ + class PlacementPolicy implements IPlacementPolicy { + + /** + * Constructs a new PlacementPolicy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy); + + /** PlacementPolicy collocation. */ + public collocation: string; + + /** PlacementPolicy maxDistance. */ + public maxDistance: (number|Long|string); + + /** + * Creates a new PlacementPolicy instance using the specified properties. + * @param [properties] Properties to set + * @returns PlacementPolicy instance + */ + public static create(properties?: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy): google.cloud.batch.v1.AllocationPolicy.PlacementPolicy; + + /** + * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @param message PlacementPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @param message PlacementPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PlacementPolicy + * @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.AllocationPolicy.PlacementPolicy; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PlacementPolicy + * @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.AllocationPolicy.PlacementPolicy; + + /** + * Verifies a PlacementPolicy 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 PlacementPolicy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PlacementPolicy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.batch.v1.AllocationPolicy.PlacementPolicy; + + /** + * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. + * @param message PlacementPolicy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.batch.v1.AllocationPolicy.PlacementPolicy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PlacementPolicy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PlacementPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** ProvisioningModel enum. */ enum ProvisioningModel { PROVISIONING_MODEL_UNSPECIFIED = 0, @@ -3714,7 +3823,8 @@ export namespace google { ASSIGNED = 2, RUNNING = 3, FAILED = 4, - SUCCEEDED = 5 + SUCCEEDED = 5, + UNEXECUTED = 6 } } @@ -3744,6 +3854,9 @@ export namespace google { /** Runnable timeout */ timeout?: (google.protobuf.IDuration|null); + + /** Runnable labels */ + labels?: ({ [k: string]: string }|null); } /** Represents a Runnable. */ @@ -3779,6 +3892,9 @@ export namespace google { /** Runnable timeout. */ public timeout?: (google.protobuf.IDuration|null); + /** Runnable labels. */ + public labels: { [k: string]: string }; + /** Runnable executable. */ public executable?: ("container"|"script"|"barrier"); diff --git a/packages/google-cloud-batch/protos/protos.js b/packages/google-cloud-batch/protos/protos.js index bb358839568..62110fa6321 100644 --- a/packages/google-cloud-batch/protos/protos.js +++ b/packages/google-cloud-batch/protos/protos.js @@ -4974,6 +4974,7 @@ case 3: case 4: case 5: + case 6: break; } return null; @@ -5078,6 +5079,10 @@ case 5: message.newTaskState = 5; break; + case "UNEXECUTED": + case 6: + message.newTaskState = 6; + break; } return message; }; @@ -5168,6 +5173,7 @@ * @property {google.cloud.batch.v1.IServiceAccount|null} [serviceAccount] AllocationPolicy serviceAccount * @property {Object.|null} [labels] AllocationPolicy labels * @property {google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null} [network] AllocationPolicy network + * @property {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null} [placement] AllocationPolicy placement */ /** @@ -5227,6 +5233,14 @@ */ AllocationPolicy.prototype.network = null; + /** + * AllocationPolicy placement. + * @member {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null|undefined} placement + * @memberof google.cloud.batch.v1.AllocationPolicy + * @instance + */ + AllocationPolicy.prototype.placement = null; + /** * Creates a new AllocationPolicy instance using the specified properties. * @function create @@ -5263,6 +5277,8 @@ $root.google.cloud.batch.v1.AllocationPolicy.InstancePolicyOrTemplate.encode(message.instances[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) $root.google.cloud.batch.v1.ServiceAccount.encode(message.serviceAccount, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.encode(message.placement, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -5338,6 +5354,10 @@ message.network = $root.google.cloud.batch.v1.AllocationPolicy.NetworkPolicy.decode(reader, reader.uint32()); break; } + case 10: { + message.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -5405,6 +5425,11 @@ if (error) return "network." + error; } + if (message.placement != null && message.hasOwnProperty("placement")) { + var error = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify(message.placement); + if (error) + return "placement." + error; + } return null; }; @@ -5452,6 +5477,11 @@ throw TypeError(".google.cloud.batch.v1.AllocationPolicy.network: object expected"); message.network = $root.google.cloud.batch.v1.AllocationPolicy.NetworkPolicy.fromObject(object.network); } + if (object.placement != null) { + if (typeof object.placement !== "object") + throw TypeError(".google.cloud.batch.v1.AllocationPolicy.placement: object expected"); + message.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.fromObject(object.placement); + } return message; }; @@ -5476,6 +5506,7 @@ object.location = null; object.network = null; object.serviceAccount = null; + object.placement = null; } if (message.location != null && message.hasOwnProperty("location")) object.location = $root.google.cloud.batch.v1.AllocationPolicy.LocationPolicy.toObject(message.location, options); @@ -5494,6 +5525,8 @@ } if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) object.serviceAccount = $root.google.cloud.batch.v1.ServiceAccount.toObject(message.serviceAccount, options); + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.toObject(message.placement, options); return object; }; @@ -7772,6 +7805,247 @@ return NetworkPolicy; })(); + AllocationPolicy.PlacementPolicy = (function() { + + /** + * Properties of a PlacementPolicy. + * @memberof google.cloud.batch.v1.AllocationPolicy + * @interface IPlacementPolicy + * @property {string|null} [collocation] PlacementPolicy collocation + * @property {number|Long|null} [maxDistance] PlacementPolicy maxDistance + */ + + /** + * Constructs a new PlacementPolicy. + * @memberof google.cloud.batch.v1.AllocationPolicy + * @classdesc Represents a PlacementPolicy. + * @implements IPlacementPolicy + * @constructor + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set + */ + function PlacementPolicy(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]]; + } + + /** + * PlacementPolicy collocation. + * @member {string} collocation + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @instance + */ + PlacementPolicy.prototype.collocation = ""; + + /** + * PlacementPolicy maxDistance. + * @member {number|Long} maxDistance + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @instance + */ + PlacementPolicy.prototype.maxDistance = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PlacementPolicy instance using the specified properties. + * @function create + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set + * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy instance + */ + PlacementPolicy.create = function create(properties) { + return new PlacementPolicy(properties); + }; + + /** + * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @function encode + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlacementPolicy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.collocation != null && Object.hasOwnProperty.call(message, "collocation")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.collocation); + if (message.maxDistance != null && Object.hasOwnProperty.call(message, "maxDistance")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.maxDistance); + return writer; + }; + + /** + * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlacementPolicy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @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.AllocationPolicy.PlacementPolicy} PlacementPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlacementPolicy.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.AllocationPolicy.PlacementPolicy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.collocation = reader.string(); + break; + } + case 2: { + message.maxDistance = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlacementPolicy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PlacementPolicy message. + * @function verify + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PlacementPolicy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.collocation != null && message.hasOwnProperty("collocation")) + if (!$util.isString(message.collocation)) + return "collocation: string expected"; + if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) + if (!$util.isInteger(message.maxDistance) && !(message.maxDistance && $util.isInteger(message.maxDistance.low) && $util.isInteger(message.maxDistance.high))) + return "maxDistance: integer|Long expected"; + return null; + }; + + /** + * Creates a PlacementPolicy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy + */ + PlacementPolicy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy) + return object; + var message = new $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy(); + if (object.collocation != null) + message.collocation = String(object.collocation); + if (object.maxDistance != null) + if ($util.Long) + (message.maxDistance = $util.Long.fromValue(object.maxDistance)).unsigned = false; + else if (typeof object.maxDistance === "string") + message.maxDistance = parseInt(object.maxDistance, 10); + else if (typeof object.maxDistance === "number") + message.maxDistance = object.maxDistance; + else if (typeof object.maxDistance === "object") + message.maxDistance = new $util.LongBits(object.maxDistance.low >>> 0, object.maxDistance.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} message PlacementPolicy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PlacementPolicy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.collocation = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.maxDistance = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.maxDistance = options.longs === String ? "0" : 0; + } + if (message.collocation != null && message.hasOwnProperty("collocation")) + object.collocation = message.collocation; + if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) + if (typeof message.maxDistance === "number") + object.maxDistance = options.longs === String ? String(message.maxDistance) : message.maxDistance; + else + object.maxDistance = options.longs === String ? $util.Long.prototype.toString.call(message.maxDistance) : options.longs === Number ? new $util.LongBits(message.maxDistance.low >>> 0, message.maxDistance.high >>> 0).toNumber() : message.maxDistance; + return object; + }; + + /** + * Converts this PlacementPolicy to JSON. + * @function toJSON + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @instance + * @returns {Object.} JSON object + */ + PlacementPolicy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PlacementPolicy + * @function getTypeUrl + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PlacementPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.batch.v1.AllocationPolicy.PlacementPolicy"; + }; + + return PlacementPolicy; + })(); + /** * ProvisioningModel enum. * @name google.cloud.batch.v1.AllocationPolicy.ProvisioningModel @@ -8979,6 +9253,7 @@ case 3: case 4: case 5: + case 6: break; } return null; @@ -9041,6 +9316,10 @@ case 5: message.taskState = 5; break; + case "UNEXECUTED": + case 6: + message.taskState = 6; + break; } return message; }; @@ -9470,6 +9749,7 @@ case 3: case 4: case 5: + case 6: break; } if (message.statusEvents != null && message.hasOwnProperty("statusEvents")) { @@ -9527,6 +9807,10 @@ case 5: message.state = 5; break; + case "UNEXECUTED": + case 6: + message.state = 6; + break; } if (object.statusEvents) { if (!Array.isArray(object.statusEvents)) @@ -9604,6 +9888,7 @@ * @property {number} RUNNING=3 RUNNING value * @property {number} FAILED=4 FAILED value * @property {number} SUCCEEDED=5 SUCCEEDED value + * @property {number} UNEXECUTED=6 UNEXECUTED value */ TaskStatus.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -9613,6 +9898,7 @@ values[valuesById[3] = "RUNNING"] = 3; values[valuesById[4] = "FAILED"] = 4; values[valuesById[5] = "SUCCEEDED"] = 5; + values[valuesById[6] = "UNEXECUTED"] = 6; return values; })(); @@ -9633,6 +9919,7 @@ * @property {boolean|null} [alwaysRun] Runnable alwaysRun * @property {google.cloud.batch.v1.IEnvironment|null} [environment] Runnable environment * @property {google.protobuf.IDuration|null} [timeout] Runnable timeout + * @property {Object.|null} [labels] Runnable labels */ /** @@ -9644,6 +9931,7 @@ * @param {google.cloud.batch.v1.IRunnable=} [properties] Properties to set */ function Runnable(properties) { + this.labels = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -9714,6 +10002,14 @@ */ Runnable.prototype.timeout = null; + /** + * Runnable labels. + * @member {Object.} labels + * @memberof google.cloud.batch.v1.Runnable + * @instance + */ + Runnable.prototype.labels = $util.emptyObject; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -9768,6 +10064,9 @@ $root.google.cloud.batch.v1.Environment.encode(message.environment, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.timeout != null && Object.hasOwnProperty.call(message, "timeout")) $root.google.protobuf.Duration.encode(message.timeout, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); return writer; }; @@ -9798,7 +10097,7 @@ Runnable.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.Runnable(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.batch.v1.Runnable(), key, value; while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -9834,6 +10133,29 @@ message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 9: { + if (message.labels === $util.emptyObject) + message.labels = {}; + 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.labels[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -9917,6 +10239,14 @@ if (error) return "timeout." + error; } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } return null; }; @@ -9963,6 +10293,13 @@ throw TypeError(".google.cloud.batch.v1.Runnable.timeout: object expected"); message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.batch.v1.Runnable.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } return message; }; @@ -9979,6 +10316,8 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.labels = {}; if (options.defaults) { object.ignoreExitStatus = false; object.background = false; @@ -10011,6 +10350,12 @@ object.environment = $root.google.cloud.batch.v1.Environment.toObject(message.environment, options); if (message.timeout != null && message.hasOwnProperty("timeout")) object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } return object; }; diff --git a/packages/google-cloud-batch/protos/protos.json b/packages/google-cloud-batch/protos/protos.json index ce7eefc7b94..8dea07a8a1f 100644 --- a/packages/google-cloud-batch/protos/protos.json +++ b/packages/google-cloud-batch/protos/protos.json @@ -576,6 +576,10 @@ "network": { "type": "NetworkPolicy", "id": 7 + }, + "placement": { + "type": "PlacementPolicy", + "id": 10 } }, "nested": { @@ -742,6 +746,18 @@ } } }, + "PlacementPolicy": { + "fields": { + "collocation": { + "type": "string", + "id": 1 + }, + "maxDistance": { + "type": "int64", + "id": 2 + } + } + }, "ProvisioningModel": { "values": { "PROVISIONING_MODEL_UNSPECIFIED": 0, @@ -880,7 +896,8 @@ "ASSIGNED": 2, "RUNNING": 3, "FAILED": 4, - "SUCCEEDED": 5 + "SUCCEEDED": 5, + "UNEXECUTED": 6 } } } @@ -927,6 +944,11 @@ "timeout": { "type": "google.protobuf.Duration", "id": 8 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 9 } }, "nested": { 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 da3aed8764e..8f3744ff68a 100644 --- a/packages/google-cloud-batch/src/v1/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1/batch_service_client.ts @@ -242,15 +242,6 @@ export class BatchServiceClient { selector: 'google.cloud.location.Locations.ListLocations', get: '/v1/{name=projects/*}/locations', }, - { - 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/*}', From b4e0746332b3263b92b9bc88af138241386731e3 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 11 May 2023 20:53:16 +0000 Subject: [PATCH 05/13] feat: support order_by in ListJobs and ListTasks requests (#21) PiperOrigin-RevId: 530949397 Source-Link: https://github.com/googleapis/googleapis-gen/commit/50f5709c916294a900be0e7f515dca39aa2ba71c Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI1MGY1NzA5YzkxNjI5NGE5MDBiZTBlN2Y1MTVkY2EzOWFhMmJhNzFjIn0= --- .../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 | 270 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 539 +++++ .../protos/google/cloud/batch/v1/task.proto | 340 +++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../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 | 278 +++ .../google/cloud/batch/v1alpha/job.proto | 655 ++++++ .../google/cloud/batch/v1alpha/task.proto | 355 ++++ .../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 | 79 + .../v1alpha/batch_service.list_tasks.js | 84 + ...t_metadata.google.cloud.batch.v1alpha.json | 307 +++ .../google-cloud-batch/v1alpha/src/index.ts | 25 + .../src/v1alpha/batch_service_client.ts | 1615 +++++++++++++++ .../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 | 1835 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12227 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..d4f03a0df2e --- /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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..91b43dd9dc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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 + // the 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 + // the 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..32e1fc416d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,539 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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; + } + + // 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + 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; + + // 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/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..b89ba09d0a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,340 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..8447d992c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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..de0c6885153 --- /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 + * the 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..6e2ad9b9488 --- /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 + * the 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..e993318bbc4 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 + * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 + * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..f70983ca35f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,1835 @@ +// 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, 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('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..d4f03a0df2e --- /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..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..c654d9c2596 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,278 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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 + // the 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 + // the 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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..c4a2201cfbc --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,655 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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; + + // The resource usage of the job. + ResourceUsage resource_usage = 6; +} + +// ResourceUsage describes the resource usage of the job. +message ResourceUsage { + // The CPU core hours that the job consumes. + double core_hours = 1; +} + +// 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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 consume only the specified reservation. + // If not specified (default), VMs will consume any applicable 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. + AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; + } + + // 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. + 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..c7db752b26a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,355 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; + + // The resource usage of the task. + TaskResourceUsage resource_usage = 3; +} + +// TaskResourceUsage describes the resource usage of the task. +message TaskResourceUsage { + // The CPU core hours the task consumes based on task requirement and run + // time. + double core_hours = 1; +} + +// 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..5b3d72a7e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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..1ca515333b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..3458538cfae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..92c74b3b847 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..83c71aecb81 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..16709131898 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..c3268d24c57 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js @@ -0,0 +1,84 @@ +// 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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..6821e36d3ec --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -0,0 +1,307 @@ +{ + "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": 71, + "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": "order_by", + "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": 76, + "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": "order_by", + "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..0395a498ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 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..95249c396ee --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1615 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * the 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..b8c39b803c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,1835 @@ +// 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, 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('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 a29384966994e2a08f4d0a5654b143e88f8f9943 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 11 May 2023 20:59:20 +0000 Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 | 270 --- .../v1/protos/google/cloud/batch/v1/job.proto | 539 ----- .../protos/google/cloud/batch/v1/task.proto | 340 --- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../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 | 278 --- .../google/cloud/batch/v1alpha/job.proto | 655 ------ .../google/cloud/batch/v1alpha/task.proto | 355 ---- .../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 | 79 - .../v1alpha/batch_service.list_tasks.js | 84 - ...t_metadata.google.cloud.batch.v1alpha.json | 307 --- .../google-cloud-batch/v1alpha/src/index.ts | 25 - .../src/v1alpha/batch_service_client.ts | 1615 --------------- .../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 | 1835 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../google/cloud/batch/v1alpha/batch.proto | 8 + .../google-cloud-batch/protos/protos.d.ts | 12 + packages/google-cloud-batch/protos/protos.js | 46 + .../google-cloud-batch/protos/protos.json | 8 + .../v1alpha/batch_service.list_jobs.js | 5 + .../v1alpha/batch_service.list_tasks.js | 5 + ...t_metadata.google.cloud.batch.v1alpha.json | 12 +- .../src/v1alpha/batch_service_client.ts | 18 + 72 files changed, 112 insertions(+), 12229 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 d4f03a0df2e..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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 91b43dd9dc3..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 - // the 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 - // the 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 32e1fc416d2..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,539 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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; - } - - // 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - 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; - - // 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/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 b89ba09d0a1..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 8447d992c48..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 de0c6885153..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 - * the 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 6e2ad9b9488..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 - * the 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 e993318bbc4..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 - * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 - * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 f70983ca35f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,1835 +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, 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('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 d4f03a0df2e..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 bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 c654d9c2596..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 - // the 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 - // the 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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 c4a2201cfbc..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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; - - // The resource usage of the job. - ResourceUsage resource_usage = 6; -} - -// ResourceUsage describes the resource usage of the job. -message ResourceUsage { - // The CPU core hours that the job consumes. - double core_hours = 1; -} - -// 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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 consume only the specified reservation. - // If not specified (default), VMs will consume any applicable 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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. - // - // Tasks might be executed in parallel depending on parallelism and - // task_count values. - AS_SOON_AS_POSSIBLE = 1; - - // Run Tasks sequentially with increased task index. - // - // Not yet implemented. - IN_ORDER = 2; - } - - // 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - // The default value is AS_SOON_AS_POSSIBLE. - 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 c7db752b26a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; - - // The resource usage of the task. - TaskResourceUsage resource_usage = 3; -} - -// TaskResourceUsage describes the resource usage of the task. -message TaskResourceUsage { - // The CPU core hours the task consumes based on task requirement and run - // time. - double core_hours = 1; -} - -// 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 5b3d72a7e80..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 1ca515333b0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 3458538cfae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 92c74b3b847..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 83c71aecb81..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 16709131898..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 c3268d24c57..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js +++ /dev/null @@ -1,84 +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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 6821e36d3ec..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ /dev/null @@ -1,307 +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": 71, - "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": "order_by", - "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": 76, - "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": "order_by", - "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 0395a498ffb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 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 95249c396ee..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1615 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * the 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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 ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 b8c39b803c0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,1835 +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, 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('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/protos/google/cloud/batch/v1alpha/batch.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/batch.proto index 33cccba15f2..c654d9c2596 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/batch.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1alpha/batch.proto @@ -177,6 +177,10 @@ message ListJobsRequest { // List filter. string filter = 4; + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + // Page size. int32 page_size = 2; @@ -211,6 +215,10 @@ message ListTasksRequest { // State=RUNNING string filter = 2; + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + // Page size. int32 page_size = 3; diff --git a/packages/google-cloud-batch/protos/protos.d.ts b/packages/google-cloud-batch/protos/protos.d.ts index ec3f7ba4c25..4c91ccc8898 100644 --- a/packages/google-cloud-batch/protos/protos.d.ts +++ b/packages/google-cloud-batch/protos/protos.d.ts @@ -5796,6 +5796,9 @@ export namespace google { /** ListJobsRequest filter */ filter?: (string|null); + /** ListJobsRequest orderBy */ + orderBy?: (string|null); + /** ListJobsRequest pageSize */ pageSize?: (number|null); @@ -5818,6 +5821,9 @@ export namespace google { /** ListJobsRequest filter. */ public filter: string; + /** ListJobsRequest orderBy. */ + public orderBy: string; + /** ListJobsRequest pageSize. */ public pageSize: number; @@ -6020,6 +6026,9 @@ export namespace google { /** ListTasksRequest filter */ filter?: (string|null); + /** ListTasksRequest orderBy */ + orderBy?: (string|null); + /** ListTasksRequest pageSize */ pageSize?: (number|null); @@ -6042,6 +6051,9 @@ export namespace google { /** ListTasksRequest filter. */ public filter: string; + /** ListTasksRequest orderBy. */ + public orderBy: string; + /** ListTasksRequest pageSize. */ public pageSize: number; diff --git a/packages/google-cloud-batch/protos/protos.js b/packages/google-cloud-batch/protos/protos.js index 62110fa6321..057cb5df633 100644 --- a/packages/google-cloud-batch/protos/protos.js +++ b/packages/google-cloud-batch/protos/protos.js @@ -14773,6 +14773,7 @@ * @interface IListJobsRequest * @property {string|null} [parent] ListJobsRequest parent * @property {string|null} [filter] ListJobsRequest filter + * @property {string|null} [orderBy] ListJobsRequest orderBy * @property {number|null} [pageSize] ListJobsRequest pageSize * @property {string|null} [pageToken] ListJobsRequest pageToken */ @@ -14808,6 +14809,14 @@ */ ListJobsRequest.prototype.filter = ""; + /** + * ListJobsRequest orderBy. + * @member {string} orderBy + * @memberof google.cloud.batch.v1alpha.ListJobsRequest + * @instance + */ + ListJobsRequest.prototype.orderBy = ""; + /** * ListJobsRequest pageSize. * @member {number} pageSize @@ -14856,6 +14865,8 @@ writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.orderBy); return writer; }; @@ -14898,6 +14909,10 @@ message.filter = reader.string(); break; } + case 5: { + message.orderBy = reader.string(); + break; + } case 2: { message.pageSize = reader.int32(); break; @@ -14947,6 +14962,9 @@ if (message.filter != null && message.hasOwnProperty("filter")) if (!$util.isString(message.filter)) return "filter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; if (message.pageSize != null && message.hasOwnProperty("pageSize")) if (!$util.isInteger(message.pageSize)) return "pageSize: integer expected"; @@ -14972,6 +14990,8 @@ message.parent = String(object.parent); if (object.filter != null) message.filter = String(object.filter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); if (object.pageSize != null) message.pageSize = object.pageSize | 0; if (object.pageToken != null) @@ -14997,6 +15017,7 @@ object.pageSize = 0; object.pageToken = ""; object.filter = ""; + object.orderBy = ""; } if (message.parent != null && message.hasOwnProperty("parent")) object.parent = message.parent; @@ -15006,6 +15027,8 @@ object.pageToken = message.pageToken; if (message.filter != null && message.hasOwnProperty("filter")) object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; return object; }; @@ -15334,6 +15357,7 @@ * @interface IListTasksRequest * @property {string|null} [parent] ListTasksRequest parent * @property {string|null} [filter] ListTasksRequest filter + * @property {string|null} [orderBy] ListTasksRequest orderBy * @property {number|null} [pageSize] ListTasksRequest pageSize * @property {string|null} [pageToken] ListTasksRequest pageToken */ @@ -15369,6 +15393,14 @@ */ ListTasksRequest.prototype.filter = ""; + /** + * ListTasksRequest orderBy. + * @member {string} orderBy + * @memberof google.cloud.batch.v1alpha.ListTasksRequest + * @instance + */ + ListTasksRequest.prototype.orderBy = ""; + /** * ListTasksRequest pageSize. * @member {number} pageSize @@ -15417,6 +15449,8 @@ writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.orderBy); return writer; }; @@ -15459,6 +15493,10 @@ message.filter = reader.string(); break; } + case 5: { + message.orderBy = reader.string(); + break; + } case 3: { message.pageSize = reader.int32(); break; @@ -15508,6 +15546,9 @@ if (message.filter != null && message.hasOwnProperty("filter")) if (!$util.isString(message.filter)) return "filter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; if (message.pageSize != null && message.hasOwnProperty("pageSize")) if (!$util.isInteger(message.pageSize)) return "pageSize: integer expected"; @@ -15533,6 +15574,8 @@ message.parent = String(object.parent); if (object.filter != null) message.filter = String(object.filter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); if (object.pageSize != null) message.pageSize = object.pageSize | 0; if (object.pageToken != null) @@ -15558,6 +15601,7 @@ object.filter = ""; object.pageSize = 0; object.pageToken = ""; + object.orderBy = ""; } if (message.parent != null && message.hasOwnProperty("parent")) object.parent = message.parent; @@ -15567,6 +15611,8 @@ object.pageSize = message.pageSize; if (message.pageToken != null && message.hasOwnProperty("pageToken")) object.pageToken = message.pageToken; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; return object; }; diff --git a/packages/google-cloud-batch/protos/protos.json b/packages/google-cloud-batch/protos/protos.json index 8dea07a8a1f..986b1da644a 100644 --- a/packages/google-cloud-batch/protos/protos.json +++ b/packages/google-cloud-batch/protos/protos.json @@ -1409,6 +1409,10 @@ "type": "string", "id": 4 }, + "orderBy": { + "type": "string", + "id": 5 + }, "pageSize": { "type": "int32", "id": 2 @@ -1451,6 +1455,10 @@ "type": "string", "id": 2 }, + "orderBy": { + "type": "string", + "id": 5 + }, "pageSize": { "type": "int32", "id": 3 diff --git a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js index b94896ae5ee..16709131898 100644 --- a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js +++ b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js @@ -36,6 +36,11 @@ function main() { * List filter. */ // const filter = 'abc123' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = 'abc123' /** * Page size. */ diff --git a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js index efaa5a22b2d..c3268d24c57 100644 --- a/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js +++ b/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js @@ -40,6 +40,11 @@ function main(parent) { * State=RUNNING */ // const filter = 'abc123' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = 'abc123' /** * Page size. */ diff --git a/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json b/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json index 4f7ee3e4e84..d509031beef 100644 --- a/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ b/packages/google-cloud-batch/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -162,7 +162,7 @@ "segments": [ { "start": 25, - "end": 66, + "end": 71, "type": "FULL" } ], @@ -179,6 +179,10 @@ "name": "filter", "type": "TYPE_STRING" }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, { "name": "page_size", "type": "TYPE_INT32" @@ -254,7 +258,7 @@ "segments": [ { "start": 25, - "end": 71, + "end": 76, "type": "FULL" } ], @@ -271,6 +275,10 @@ "name": "filter", "type": "TYPE_STRING" }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, { "name": "page_size", "type": "TYPE_INT32" diff --git a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts index 5a624512545..1b4844c7178 100644 --- a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts @@ -854,6 +854,9 @@ export class BatchServiceClient { * Parent path. * @param {string} request.filter * List filter. + * @param {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". * @param {number} request.pageSize * Page size. * @param {string} request.pageToken @@ -948,6 +951,9 @@ export class BatchServiceClient { * Parent path. * @param {string} request.filter * List filter. + * @param {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". * @param {number} request.pageSize * Page size. * @param {string} request.pageToken @@ -996,6 +1002,9 @@ export class BatchServiceClient { * Parent path. * @param {string} request.filter * List filter. + * @param {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". * @param {number} request.pageSize * Page size. * @param {string} request.pageToken @@ -1047,6 +1056,9 @@ export class BatchServiceClient { * Task filter, null filter matches all Tasks. * Filter string should be of the format State=TaskStatus.State e.g. * State=RUNNING + * @param {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". * @param {number} request.pageSize * Page size. * @param {string} request.pageToken @@ -1145,6 +1157,9 @@ export class BatchServiceClient { * Task filter, null filter matches all Tasks. * Filter string should be of the format State=TaskStatus.State e.g. * State=RUNNING + * @param {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". * @param {number} request.pageSize * Page size. * @param {string} request.pageToken @@ -1197,6 +1212,9 @@ export class BatchServiceClient { * Task filter, null filter matches all Tasks. * Filter string should be of the format State=TaskStatus.State e.g. * State=RUNNING + * @param {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". * @param {number} request.pageSize * Page size. * @param {string} request.pageToken From 276382324cfbcd209be6e5c05401521f65013dcd Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 11 May 2023 23:59:03 +0000 Subject: [PATCH 07/13] feat: support order_by in ListJobs and ListTasks requests --- feat: add support for placement policies --- feat: per-Runnable labels PiperOrigin-RevId: 531181280 Source-Link: https://github.com/googleapis/googleapis/commit/284507839ffb401e0e1f2a4288178ecc511ca584 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f09a853ad8080cfefdfc61b6434d762c8bfd6eb7 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJmMDlhODUzYWQ4MDgwY2ZlZmRmYzYxYjY0MzRkNzYyYzhiZmQ2ZWI3In0= --- .../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 | 270 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 506 +++++ .../protos/google/cloud/batch/v1/task.proto | 333 +++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../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 | 278 +++ .../google/cloud/batch/v1alpha/job.proto | 655 ++++++ .../google/cloud/batch/v1alpha/task.proto | 355 ++++ .../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 | 79 + .../v1alpha/batch_service.list_tasks.js | 84 + ...t_metadata.google.cloud.batch.v1alpha.json | 307 +++ .../google-cloud-batch/v1alpha/src/index.ts | 25 + .../src/v1alpha/batch_service_client.ts | 1615 +++++++++++++++ .../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 | 1835 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12187 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..d4f03a0df2e --- /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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..91b43dd9dc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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 + // the 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 + // the 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..4bed626c1ac --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,506 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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. + // For example, the following are all valid URLs: + // (1) Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // (2) Specify the image version: + // projects/{project}/global/images/{image_version} + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // "batch-debian": use Batch Debian images. + // "batch-centos": use Batch CentOS images. + // "batch-cos": use Batch Container-Optimized images. + 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, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // 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; + } + + // 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; + + // 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/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..62e982976c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,333 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..8447d992c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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..de0c6885153 --- /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 + * the 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..6e2ad9b9488 --- /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 + * the 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..8c8493c6038 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 + * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 + * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..f70983ca35f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,1835 @@ +// 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, 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('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..d4f03a0df2e --- /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..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..c654d9c2596 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,278 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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 + // the 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 + // the 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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..c4a2201cfbc --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,655 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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; + + // The resource usage of the job. + ResourceUsage resource_usage = 6; +} + +// ResourceUsage describes the resource usage of the job. +message ResourceUsage { + // The CPU core hours that the job consumes. + double core_hours = 1; +} + +// 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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 consume only the specified reservation. + // If not specified (default), VMs will consume any applicable 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. + AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; + } + + // 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. + 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..c7db752b26a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,355 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; + + // The resource usage of the task. + TaskResourceUsage resource_usage = 3; +} + +// TaskResourceUsage describes the resource usage of the task. +message TaskResourceUsage { + // The CPU core hours the task consumes based on task requirement and run + // time. + double core_hours = 1; +} + +// 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..5b3d72a7e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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..1ca515333b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..3458538cfae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..92c74b3b847 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..83c71aecb81 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..16709131898 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..c3268d24c57 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js @@ -0,0 +1,84 @@ +// 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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..6821e36d3ec --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -0,0 +1,307 @@ +{ + "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": 71, + "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": "order_by", + "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": 76, + "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": "order_by", + "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..0395a498ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 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..95249c396ee --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1615 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * the 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..b8c39b803c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,1835 @@ +// 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, 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('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 418f4830253d367d8b371f1ed0355f1e534d4013 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 12 May 2023 00:05:09 +0000 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 | 270 --- .../v1/protos/google/cloud/batch/v1/job.proto | 506 ----- .../protos/google/cloud/batch/v1/task.proto | 333 --- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../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 | 278 --- .../google/cloud/batch/v1alpha/job.proto | 655 ------ .../google/cloud/batch/v1alpha/task.proto | 355 ---- .../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 | 79 - .../v1alpha/batch_service.list_tasks.js | 84 - ...t_metadata.google.cloud.batch.v1alpha.json | 307 --- .../google-cloud-batch/v1alpha/src/index.ts | 25 - .../src/v1alpha/batch_service_client.ts | 1615 --------------- .../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 | 1835 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../protos/google/cloud/batch/v1/job.proto | 63 +- .../protos/google/cloud/batch/v1/task.proto | 13 +- .../google-cloud-batch/protos/protos.d.ts | 118 +- packages/google-cloud-batch/protos/protos.js | 347 +--- .../google-cloud-batch/protos/protos.json | 24 +- .../src/v1/batch_service_client.ts | 9 + 70 files changed, 30 insertions(+), 12731 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 d4f03a0df2e..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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 91b43dd9dc3..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 - // the 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 - // the 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 4bed626c1ac..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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. - // For example, the following are all valid URLs: - // (1) Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // (2) Specify the image version: - // projects/{project}/global/images/{image_version} - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // "batch-debian": use Batch Debian images. - // "batch-centos": use Batch CentOS images. - // "batch-cos": use Batch Container-Optimized images. - 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, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // 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; - } - - // 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; - - // 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/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 62e982976c5..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 8447d992c48..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 de0c6885153..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 - * the 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 6e2ad9b9488..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 - * the 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 8c8493c6038..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 - * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 - * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 f70983ca35f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,1835 +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, 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('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 d4f03a0df2e..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 bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 c654d9c2596..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 - // the 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 - // the 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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 c4a2201cfbc..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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; - - // The resource usage of the job. - ResourceUsage resource_usage = 6; -} - -// ResourceUsage describes the resource usage of the job. -message ResourceUsage { - // The CPU core hours that the job consumes. - double core_hours = 1; -} - -// 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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 consume only the specified reservation. - // If not specified (default), VMs will consume any applicable 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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. - // - // Tasks might be executed in parallel depending on parallelism and - // task_count values. - AS_SOON_AS_POSSIBLE = 1; - - // Run Tasks sequentially with increased task index. - // - // Not yet implemented. - IN_ORDER = 2; - } - - // 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - // The default value is AS_SOON_AS_POSSIBLE. - 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 c7db752b26a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; - - // The resource usage of the task. - TaskResourceUsage resource_usage = 3; -} - -// TaskResourceUsage describes the resource usage of the task. -message TaskResourceUsage { - // The CPU core hours the task consumes based on task requirement and run - // time. - double core_hours = 1; -} - -// 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 5b3d72a7e80..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 1ca515333b0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 3458538cfae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 92c74b3b847..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 83c71aecb81..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 16709131898..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 c3268d24c57..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js +++ /dev/null @@ -1,84 +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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 6821e36d3ec..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ /dev/null @@ -1,307 +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": 71, - "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": "order_by", - "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": 76, - "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": "order_by", - "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 0395a498ffb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 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 95249c396ee..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1615 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * the 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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 ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 b8c39b803c0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,1835 +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, 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('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/protos/google/cloud/batch/v1/job.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto index 32e1fc416d2..4bed626c1ac 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto @@ -225,14 +225,12 @@ message JobNotification { 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", @@ -243,29 +241,25 @@ message AllocationPolicy { // A new persistent disk or a local ssd. // A VM can only have one local SSD setting but multiple local SSD partitions. - // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. // For example, the following are all valid URLs: - // - // * Specify the image by its family name: + // (1) Specify the image by its family name: // projects/{project}/global/images/family/{image_family} - // * Specify the image version: + // (2) Specify the image version: // projects/{project}/global/images/{image_version} - // // You can also use Batch customized image in short names. // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. + // "batch-debian": use Batch Debian images. + // "batch-centos": use Batch CentOS images. + // "batch-cos": use Batch Container-Optimized images. string image = 4; // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. string snapshot = 5; } @@ -276,7 +270,6 @@ message AllocationPolicy { string type = 1; // Disk size in GB. - // // For persistent disk, this field is ignored if `data_source` is `image` or // `snapshot`. // For local SSD, size_gb should be a multiple of 375GB, @@ -331,7 +324,7 @@ message AllocationPolicy { // The minimum CPU platform. // See - // https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform. + // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. // Not yet implemented. string min_cpu_platform = 3; @@ -341,9 +334,8 @@ message AllocationPolicy { // The accelerators attached to each VM instance. repeated Accelerator accelerators = 5; - // Boot disk to be created and attached to each VM by this InstancePolicy. + // Book disk to be created and attached to each VM by this InstancePolicy. // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. Disk boot_disk = 8; // Non-boot disks to be attached for each VM created by this InstancePolicy. @@ -374,22 +366,18 @@ message AllocationPolicy { 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} + // 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} + // 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 @@ -408,23 +396,6 @@ message AllocationPolicy { repeated NetworkInterface network_interfaces = 1; } - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - // Compute Engine VM instance provisioning model. enum ProvisioningModel { // Unspecified. @@ -466,9 +437,6 @@ message AllocationPolicy { // The network policy. NetworkPolicy network = 7; - - // The placement policy. - PlacementPolicy placement = 10; } // A TaskGroup contains one or multiple Tasks that share the same @@ -489,12 +457,11 @@ message TaskGroup { TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; // Number of Tasks in the TaskGroup. - // Default is 1. + // default is 1 int64 task_count = 4; // Max number of tasks that can run in parallel. // Default to min(task_count, 1000). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. int64 parallelism = 5; // An array of environment variable mappings, which are passed to Tasks with 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 b89ba09d0a1..62e982976c5 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 @@ -72,7 +72,7 @@ message TaskExecution { message TaskStatus { // Task states. enum State { - // Unknown state. + // unknown state STATE_UNSPECIFIED = 0; // The Task is created and waiting for resources. @@ -89,9 +89,6 @@ message TaskStatus { // The Task has succeeded. SUCCEEDED = 5; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; } // Task state @@ -127,9 +124,8 @@ message Runnable { string options = 8; // If set to true, external network access to and from container will be - // blocked, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. + // 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 @@ -212,9 +208,6 @@ message Runnable { // Timeout for this Runnable. google.protobuf.Duration timeout = 8; - - // Labels for this Runnable. - map labels = 9; } // Spec of a task diff --git a/packages/google-cloud-batch/protos/protos.d.ts b/packages/google-cloud-batch/protos/protos.d.ts index 4c91ccc8898..d3666ea5f61 100644 --- a/packages/google-cloud-batch/protos/protos.d.ts +++ b/packages/google-cloud-batch/protos/protos.d.ts @@ -2031,9 +2031,6 @@ export namespace google { /** AllocationPolicy network */ network?: (google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null); - - /** AllocationPolicy placement */ - placement?: (google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null); } /** Represents an AllocationPolicy. */ @@ -2060,9 +2057,6 @@ export namespace google { /** AllocationPolicy network. */ public network?: (google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null); - /** AllocationPolicy placement. */ - public placement?: (google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null); - /** * Creates a new AllocationPolicy instance using the specified properties. * @param [properties] Properties to set @@ -3030,109 +3024,6 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Properties of a PlacementPolicy. */ - interface IPlacementPolicy { - - /** PlacementPolicy collocation */ - collocation?: (string|null); - - /** PlacementPolicy maxDistance */ - maxDistance?: (number|Long|string|null); - } - - /** Represents a PlacementPolicy. */ - class PlacementPolicy implements IPlacementPolicy { - - /** - * Constructs a new PlacementPolicy. - * @param [properties] Properties to set - */ - constructor(properties?: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy); - - /** PlacementPolicy collocation. */ - public collocation: string; - - /** PlacementPolicy maxDistance. */ - public maxDistance: (number|Long|string); - - /** - * Creates a new PlacementPolicy instance using the specified properties. - * @param [properties] Properties to set - * @returns PlacementPolicy instance - */ - public static create(properties?: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy): google.cloud.batch.v1.AllocationPolicy.PlacementPolicy; - - /** - * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. - * @param message PlacementPolicy message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. - * @param message PlacementPolicy message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a PlacementPolicy message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns PlacementPolicy - * @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.AllocationPolicy.PlacementPolicy; - - /** - * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns PlacementPolicy - * @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.AllocationPolicy.PlacementPolicy; - - /** - * Verifies a PlacementPolicy 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 PlacementPolicy message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns PlacementPolicy - */ - public static fromObject(object: { [k: string]: any }): google.cloud.batch.v1.AllocationPolicy.PlacementPolicy; - - /** - * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. - * @param message PlacementPolicy - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.cloud.batch.v1.AllocationPolicy.PlacementPolicy, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this PlacementPolicy to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - - /** - * Gets the default type url for PlacementPolicy - * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns The default type url - */ - public static getTypeUrl(typeUrlPrefix?: string): string; - } - /** ProvisioningModel enum. */ enum ProvisioningModel { PROVISIONING_MODEL_UNSPECIFIED = 0, @@ -3823,8 +3714,7 @@ export namespace google { ASSIGNED = 2, RUNNING = 3, FAILED = 4, - SUCCEEDED = 5, - UNEXECUTED = 6 + SUCCEEDED = 5 } } @@ -3854,9 +3744,6 @@ export namespace google { /** Runnable timeout */ timeout?: (google.protobuf.IDuration|null); - - /** Runnable labels */ - labels?: ({ [k: string]: string }|null); } /** Represents a Runnable. */ @@ -3892,9 +3779,6 @@ export namespace google { /** Runnable timeout. */ public timeout?: (google.protobuf.IDuration|null); - /** Runnable labels. */ - public labels: { [k: string]: string }; - /** Runnable executable. */ public executable?: ("container"|"script"|"barrier"); diff --git a/packages/google-cloud-batch/protos/protos.js b/packages/google-cloud-batch/protos/protos.js index 057cb5df633..f3f723e7db7 100644 --- a/packages/google-cloud-batch/protos/protos.js +++ b/packages/google-cloud-batch/protos/protos.js @@ -4974,7 +4974,6 @@ case 3: case 4: case 5: - case 6: break; } return null; @@ -5079,10 +5078,6 @@ case 5: message.newTaskState = 5; break; - case "UNEXECUTED": - case 6: - message.newTaskState = 6; - break; } return message; }; @@ -5173,7 +5168,6 @@ * @property {google.cloud.batch.v1.IServiceAccount|null} [serviceAccount] AllocationPolicy serviceAccount * @property {Object.|null} [labels] AllocationPolicy labels * @property {google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null} [network] AllocationPolicy network - * @property {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null} [placement] AllocationPolicy placement */ /** @@ -5233,14 +5227,6 @@ */ AllocationPolicy.prototype.network = null; - /** - * AllocationPolicy placement. - * @member {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null|undefined} placement - * @memberof google.cloud.batch.v1.AllocationPolicy - * @instance - */ - AllocationPolicy.prototype.placement = null; - /** * Creates a new AllocationPolicy instance using the specified properties. * @function create @@ -5277,8 +5263,6 @@ $root.google.cloud.batch.v1.AllocationPolicy.InstancePolicyOrTemplate.encode(message.instances[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) $root.google.cloud.batch.v1.ServiceAccount.encode(message.serviceAccount, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); - if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) - $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.encode(message.placement, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -5354,10 +5338,6 @@ message.network = $root.google.cloud.batch.v1.AllocationPolicy.NetworkPolicy.decode(reader, reader.uint32()); break; } - case 10: { - message.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.decode(reader, reader.uint32()); - break; - } default: reader.skipType(tag & 7); break; @@ -5425,11 +5405,6 @@ if (error) return "network." + error; } - if (message.placement != null && message.hasOwnProperty("placement")) { - var error = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify(message.placement); - if (error) - return "placement." + error; - } return null; }; @@ -5477,11 +5452,6 @@ throw TypeError(".google.cloud.batch.v1.AllocationPolicy.network: object expected"); message.network = $root.google.cloud.batch.v1.AllocationPolicy.NetworkPolicy.fromObject(object.network); } - if (object.placement != null) { - if (typeof object.placement !== "object") - throw TypeError(".google.cloud.batch.v1.AllocationPolicy.placement: object expected"); - message.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.fromObject(object.placement); - } return message; }; @@ -5506,7 +5476,6 @@ object.location = null; object.network = null; object.serviceAccount = null; - object.placement = null; } if (message.location != null && message.hasOwnProperty("location")) object.location = $root.google.cloud.batch.v1.AllocationPolicy.LocationPolicy.toObject(message.location, options); @@ -5525,8 +5494,6 @@ } if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) object.serviceAccount = $root.google.cloud.batch.v1.ServiceAccount.toObject(message.serviceAccount, options); - if (message.placement != null && message.hasOwnProperty("placement")) - object.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.toObject(message.placement, options); return object; }; @@ -7805,247 +7772,6 @@ return NetworkPolicy; })(); - AllocationPolicy.PlacementPolicy = (function() { - - /** - * Properties of a PlacementPolicy. - * @memberof google.cloud.batch.v1.AllocationPolicy - * @interface IPlacementPolicy - * @property {string|null} [collocation] PlacementPolicy collocation - * @property {number|Long|null} [maxDistance] PlacementPolicy maxDistance - */ - - /** - * Constructs a new PlacementPolicy. - * @memberof google.cloud.batch.v1.AllocationPolicy - * @classdesc Represents a PlacementPolicy. - * @implements IPlacementPolicy - * @constructor - * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set - */ - function PlacementPolicy(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]]; - } - - /** - * PlacementPolicy collocation. - * @member {string} collocation - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @instance - */ - PlacementPolicy.prototype.collocation = ""; - - /** - * PlacementPolicy maxDistance. - * @member {number|Long} maxDistance - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @instance - */ - PlacementPolicy.prototype.maxDistance = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new PlacementPolicy instance using the specified properties. - * @function create - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set - * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy instance - */ - PlacementPolicy.create = function create(properties) { - return new PlacementPolicy(properties); - }; - - /** - * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. - * @function encode - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PlacementPolicy.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.collocation != null && Object.hasOwnProperty.call(message, "collocation")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.collocation); - if (message.maxDistance != null && Object.hasOwnProperty.call(message, "maxDistance")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.maxDistance); - return writer; - }; - - /** - * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. - * @function encodeDelimited - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PlacementPolicy.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a PlacementPolicy message from the specified reader or buffer. - * @function decode - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @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.AllocationPolicy.PlacementPolicy} PlacementPolicy - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PlacementPolicy.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.AllocationPolicy.PlacementPolicy(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - message.collocation = reader.string(); - break; - } - case 2: { - message.maxDistance = reader.int64(); - break; - } - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PlacementPolicy.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a PlacementPolicy message. - * @function verify - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - PlacementPolicy.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.collocation != null && message.hasOwnProperty("collocation")) - if (!$util.isString(message.collocation)) - return "collocation: string expected"; - if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) - if (!$util.isInteger(message.maxDistance) && !(message.maxDistance && $util.isInteger(message.maxDistance.low) && $util.isInteger(message.maxDistance.high))) - return "maxDistance: integer|Long expected"; - return null; - }; - - /** - * Creates a PlacementPolicy message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {Object.} object Plain object - * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy - */ - PlacementPolicy.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy) - return object; - var message = new $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy(); - if (object.collocation != null) - message.collocation = String(object.collocation); - if (object.maxDistance != null) - if ($util.Long) - (message.maxDistance = $util.Long.fromValue(object.maxDistance)).unsigned = false; - else if (typeof object.maxDistance === "string") - message.maxDistance = parseInt(object.maxDistance, 10); - else if (typeof object.maxDistance === "number") - message.maxDistance = object.maxDistance; - else if (typeof object.maxDistance === "object") - message.maxDistance = new $util.LongBits(object.maxDistance.low >>> 0, object.maxDistance.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. - * @function toObject - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} message PlacementPolicy - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - PlacementPolicy.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.collocation = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.maxDistance = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.maxDistance = options.longs === String ? "0" : 0; - } - if (message.collocation != null && message.hasOwnProperty("collocation")) - object.collocation = message.collocation; - if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) - if (typeof message.maxDistance === "number") - object.maxDistance = options.longs === String ? String(message.maxDistance) : message.maxDistance; - else - object.maxDistance = options.longs === String ? $util.Long.prototype.toString.call(message.maxDistance) : options.longs === Number ? new $util.LongBits(message.maxDistance.low >>> 0, message.maxDistance.high >>> 0).toNumber() : message.maxDistance; - return object; - }; - - /** - * Converts this PlacementPolicy to JSON. - * @function toJSON - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @instance - * @returns {Object.} JSON object - */ - PlacementPolicy.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Gets the default type url for PlacementPolicy - * @function getTypeUrl - * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - PlacementPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/google.cloud.batch.v1.AllocationPolicy.PlacementPolicy"; - }; - - return PlacementPolicy; - })(); - /** * ProvisioningModel enum. * @name google.cloud.batch.v1.AllocationPolicy.ProvisioningModel @@ -9253,7 +8979,6 @@ case 3: case 4: case 5: - case 6: break; } return null; @@ -9316,10 +9041,6 @@ case 5: message.taskState = 5; break; - case "UNEXECUTED": - case 6: - message.taskState = 6; - break; } return message; }; @@ -9749,7 +9470,6 @@ case 3: case 4: case 5: - case 6: break; } if (message.statusEvents != null && message.hasOwnProperty("statusEvents")) { @@ -9807,10 +9527,6 @@ case 5: message.state = 5; break; - case "UNEXECUTED": - case 6: - message.state = 6; - break; } if (object.statusEvents) { if (!Array.isArray(object.statusEvents)) @@ -9888,7 +9604,6 @@ * @property {number} RUNNING=3 RUNNING value * @property {number} FAILED=4 FAILED value * @property {number} SUCCEEDED=5 SUCCEEDED value - * @property {number} UNEXECUTED=6 UNEXECUTED value */ TaskStatus.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -9898,7 +9613,6 @@ values[valuesById[3] = "RUNNING"] = 3; values[valuesById[4] = "FAILED"] = 4; values[valuesById[5] = "SUCCEEDED"] = 5; - values[valuesById[6] = "UNEXECUTED"] = 6; return values; })(); @@ -9919,7 +9633,6 @@ * @property {boolean|null} [alwaysRun] Runnable alwaysRun * @property {google.cloud.batch.v1.IEnvironment|null} [environment] Runnable environment * @property {google.protobuf.IDuration|null} [timeout] Runnable timeout - * @property {Object.|null} [labels] Runnable labels */ /** @@ -9931,7 +9644,6 @@ * @param {google.cloud.batch.v1.IRunnable=} [properties] Properties to set */ function Runnable(properties) { - this.labels = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -10002,14 +9714,6 @@ */ Runnable.prototype.timeout = null; - /** - * Runnable labels. - * @member {Object.} labels - * @memberof google.cloud.batch.v1.Runnable - * @instance - */ - Runnable.prototype.labels = $util.emptyObject; - // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -10064,9 +9768,6 @@ $root.google.cloud.batch.v1.Environment.encode(message.environment, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.timeout != null && Object.hasOwnProperty.call(message, "timeout")) $root.google.protobuf.Duration.encode(message.timeout, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) - for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) - writer.uint32(/* id 9, wireType 2 =*/74).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); return writer; }; @@ -10097,7 +9798,7 @@ Runnable.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.Runnable(), key, value; + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.batch.v1.Runnable(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -10133,29 +9834,6 @@ message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } - case 9: { - if (message.labels === $util.emptyObject) - message.labels = {}; - 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.labels[key] = value; - break; - } default: reader.skipType(tag & 7); break; @@ -10239,14 +9917,6 @@ if (error) return "timeout." + error; } - if (message.labels != null && message.hasOwnProperty("labels")) { - if (!$util.isObject(message.labels)) - return "labels: object expected"; - var key = Object.keys(message.labels); - for (var i = 0; i < key.length; ++i) - if (!$util.isString(message.labels[key[i]])) - return "labels: string{k:string} expected"; - } return null; }; @@ -10293,13 +9963,6 @@ throw TypeError(".google.cloud.batch.v1.Runnable.timeout: object expected"); message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); } - if (object.labels) { - if (typeof object.labels !== "object") - throw TypeError(".google.cloud.batch.v1.Runnable.labels: object expected"); - message.labels = {}; - for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) - message.labels[keys[i]] = String(object.labels[keys[i]]); - } return message; }; @@ -10316,8 +9979,6 @@ if (!options) options = {}; var object = {}; - if (options.objects || options.defaults) - object.labels = {}; if (options.defaults) { object.ignoreExitStatus = false; object.background = false; @@ -10350,12 +10011,6 @@ object.environment = $root.google.cloud.batch.v1.Environment.toObject(message.environment, options); if (message.timeout != null && message.hasOwnProperty("timeout")) object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); - var keys2; - if (message.labels && (keys2 = Object.keys(message.labels)).length) { - object.labels = {}; - for (var j = 0; j < keys2.length; ++j) - object.labels[keys2[j]] = message.labels[keys2[j]]; - } return object; }; diff --git a/packages/google-cloud-batch/protos/protos.json b/packages/google-cloud-batch/protos/protos.json index 986b1da644a..e64eb1bbbdd 100644 --- a/packages/google-cloud-batch/protos/protos.json +++ b/packages/google-cloud-batch/protos/protos.json @@ -576,10 +576,6 @@ "network": { "type": "NetworkPolicy", "id": 7 - }, - "placement": { - "type": "PlacementPolicy", - "id": 10 } }, "nested": { @@ -746,18 +742,6 @@ } } }, - "PlacementPolicy": { - "fields": { - "collocation": { - "type": "string", - "id": 1 - }, - "maxDistance": { - "type": "int64", - "id": 2 - } - } - }, "ProvisioningModel": { "values": { "PROVISIONING_MODEL_UNSPECIFIED": 0, @@ -896,8 +880,7 @@ "ASSIGNED": 2, "RUNNING": 3, "FAILED": 4, - "SUCCEEDED": 5, - "UNEXECUTED": 6 + "SUCCEEDED": 5 } } } @@ -944,11 +927,6 @@ "timeout": { "type": "google.protobuf.Duration", "id": 8 - }, - "labels": { - "keyType": "string", - "type": "string", - "id": 9 } }, "nested": { 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 8f3744ff68a..da3aed8764e 100644 --- a/packages/google-cloud-batch/src/v1/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1/batch_service_client.ts @@ -242,6 +242,15 @@ export class BatchServiceClient { selector: 'google.cloud.location.Locations.ListLocations', get: '/v1/{name=projects/*}/locations', }, + { + 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/*}', From ef8ea997b187c7f9483b77a36585b551af98958e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 16 May 2023 09:53:37 +0000 Subject: [PATCH 09/13] fix: override HTTP URLs for LRO cancel/delete operations PiperOrigin-RevId: 532357846 Source-Link: https://github.com/googleapis/googleapis/commit/5cfe30bb7e28287ef82b319e3df1f6778b9d55fd Source-Link: https://github.com/googleapis/googleapis-gen/commit/0e1e293ad959be26640d593b978cab7fba7ced97 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiIwZTFlMjkzYWQ5NTliZTI2NjQwZDU5M2I5NzhjYWI3ZmJhN2NlZDk3In0= --- .../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 | 270 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 506 +++++ .../protos/google/cloud/batch/v1/task.proto | 333 +++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../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 | 278 +++ .../google/cloud/batch/v1alpha/job.proto | 655 ++++++ .../google/cloud/batch/v1alpha/task.proto | 355 ++++ .../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 | 79 + .../v1alpha/batch_service.list_tasks.js | 84 + ...t_metadata.google.cloud.batch.v1alpha.json | 307 +++ .../google-cloud-batch/v1alpha/src/index.ts | 25 + .../src/v1alpha/batch_service_client.ts | 1615 +++++++++++++++ .../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 | 1835 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12187 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..d4f03a0df2e --- /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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..91b43dd9dc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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 + // the 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 + // the 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..4bed626c1ac --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,506 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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. + // For example, the following are all valid URLs: + // (1) Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // (2) Specify the image version: + // projects/{project}/global/images/{image_version} + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // "batch-debian": use Batch Debian images. + // "batch-centos": use Batch CentOS images. + // "batch-cos": use Batch Container-Optimized images. + 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, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // 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; + } + + // 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; + + // 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/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..62e982976c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,333 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..8447d992c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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..de0c6885153 --- /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 + * the 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..6e2ad9b9488 --- /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 + * the 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..8c8493c6038 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 + * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 + * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..f70983ca35f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,1835 @@ +// 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, 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('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..d4f03a0df2e --- /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..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..c654d9c2596 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,278 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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 + // the 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 + // the 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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..c4a2201cfbc --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,655 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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; + + // The resource usage of the job. + ResourceUsage resource_usage = 6; +} + +// ResourceUsage describes the resource usage of the job. +message ResourceUsage { + // The CPU core hours that the job consumes. + double core_hours = 1; +} + +// 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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 consume only the specified reservation. + // If not specified (default), VMs will consume any applicable 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. + AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; + } + + // 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. + 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..c7db752b26a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,355 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; + + // The resource usage of the task. + TaskResourceUsage resource_usage = 3; +} + +// TaskResourceUsage describes the resource usage of the task. +message TaskResourceUsage { + // The CPU core hours the task consumes based on task requirement and run + // time. + double core_hours = 1; +} + +// 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..5b3d72a7e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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..1ca515333b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..3458538cfae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..92c74b3b847 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..83c71aecb81 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..16709131898 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..c3268d24c57 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js @@ -0,0 +1,84 @@ +// 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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..6821e36d3ec --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -0,0 +1,307 @@ +{ + "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": 71, + "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": "order_by", + "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": 76, + "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": "order_by", + "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..0395a498ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 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..bcca459e6fa --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1615 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * the 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..b8c39b803c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,1835 @@ +// 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, 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('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 8556889161ad0b04c4da3b1510e501994c7b91d9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 16 May 2023 09:59:16 +0000 Subject: [PATCH 10/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 | 270 --- .../v1/protos/google/cloud/batch/v1/job.proto | 506 ----- .../protos/google/cloud/batch/v1/task.proto | 333 --- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../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 | 278 --- .../google/cloud/batch/v1alpha/job.proto | 655 ------ .../google/cloud/batch/v1alpha/task.proto | 355 ---- .../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 | 79 - .../v1alpha/batch_service.list_tasks.js | 84 - ...t_metadata.google.cloud.batch.v1alpha.json | 307 --- .../google-cloud-batch/v1alpha/src/index.ts | 25 - .../src/v1alpha/batch_service_client.ts | 1615 --------------- .../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 | 1835 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../src/v1alpha/batch_service_client.ts | 9 + 65 files changed, 9 insertions(+), 12187 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 d4f03a0df2e..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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 91b43dd9dc3..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 - // the 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 - // the 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 4bed626c1ac..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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. - // For example, the following are all valid URLs: - // (1) Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // (2) Specify the image version: - // projects/{project}/global/images/{image_version} - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // "batch-debian": use Batch Debian images. - // "batch-centos": use Batch CentOS images. - // "batch-cos": use Batch Container-Optimized images. - 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, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // 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; - } - - // 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; - - // 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/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 62e982976c5..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 8447d992c48..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 de0c6885153..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 - * the 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 6e2ad9b9488..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 - * the 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 8c8493c6038..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 - * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 - * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 f70983ca35f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,1835 +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, 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('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 d4f03a0df2e..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 bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 c654d9c2596..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 - // the 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 - // the 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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 c4a2201cfbc..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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; - - // The resource usage of the job. - ResourceUsage resource_usage = 6; -} - -// ResourceUsage describes the resource usage of the job. -message ResourceUsage { - // The CPU core hours that the job consumes. - double core_hours = 1; -} - -// 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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 consume only the specified reservation. - // If not specified (default), VMs will consume any applicable 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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. - // - // Tasks might be executed in parallel depending on parallelism and - // task_count values. - AS_SOON_AS_POSSIBLE = 1; - - // Run Tasks sequentially with increased task index. - // - // Not yet implemented. - IN_ORDER = 2; - } - - // 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - // The default value is AS_SOON_AS_POSSIBLE. - 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 c7db752b26a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; - - // The resource usage of the task. - TaskResourceUsage resource_usage = 3; -} - -// TaskResourceUsage describes the resource usage of the task. -message TaskResourceUsage { - // The CPU core hours the task consumes based on task requirement and run - // time. - double core_hours = 1; -} - -// 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 5b3d72a7e80..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 1ca515333b0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 3458538cfae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 92c74b3b847..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 83c71aecb81..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 16709131898..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 c3268d24c57..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js +++ /dev/null @@ -1,84 +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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 6821e36d3ec..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ /dev/null @@ -1,307 +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": 71, - "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": "order_by", - "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": 76, - "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": "order_by", - "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 0395a498ffb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 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 bcca459e6fa..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1615 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * the 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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 ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 b8c39b803c0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,1835 +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, 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('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/src/v1alpha/batch_service_client.ts b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts index 1b4844c7178..61203cb0b27 100644 --- a/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts +++ b/packages/google-cloud-batch/src/v1alpha/batch_service_client.ts @@ -242,6 +242,15 @@ export class BatchServiceClient { selector: 'google.cloud.location.Locations.ListLocations', get: '/v1alpha/{name=projects/*}/locations', }, + { + 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/*}', From 929742e61a937325eea4df683984068bb7d7d06c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 16 May 2023 14:19:51 +0000 Subject: [PATCH 11/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 --- packages/google-cloud-batch/README.md | 31 +++++++++---------- packages/google-cloud-batch/samples/README.md | 18 ----------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/packages/google-cloud-batch/README.md b/packages/google-cloud-batch/README.md index adf39f01935..a0606bdf86c 100644 --- a/packages/google-cloud-batch/README.md +++ b/packages/google-cloud-batch/README.md @@ -2,7 +2,7 @@ [//]: # "To regenerate it, use `python -m synthtool`." Google Cloud Platform logo -# [Batch: Node.js Client](https://github.com/googleapis/google-cloud-node) +# [Batch: Node.js Client](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-batch) [![release level](https://img.shields.io/badge/release%20level-preview-yellow.svg?style=flat)](https://cloud.google.com/terms/launch-stages) [![npm version](https://img.shields.io/npm/v/@google-cloud/batch.svg)](https://www.npmjs.org/package/@google-cloud/batch) @@ -107,24 +107,23 @@ callListJobs(); ## Samples -Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample. +Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-batch/samples) directory. Each sample's `README.md` has instructions for running its sample. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Batch_service.create_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js,samples/README.md) | -| Batch_service.delete_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js,samples/README.md) | -| Batch_service.get_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js,samples/README.md) | -| Batch_service.get_task | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js,samples/README.md) | -| Batch_service.list_jobs | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js,samples/README.md) | -| Batch_service.list_tasks | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js,samples/README.md) | -| Batch_service.create_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.create_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.create_job.js,samples/README.md) | -| Batch_service.delete_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.delete_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.delete_job.js,samples/README.md) | -| Batch_service.get_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_job.js,samples/README.md) | -| Batch_service.get_task | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_task.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_task.js,samples/README.md) | -| Batch_service.list_jobs | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js,samples/README.md) | -| Batch_service.list_tasks | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js,samples/README.md) | -| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/quickstart.js,samples/README.md) | -| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/test/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/test/quickstart.js,samples/README.md) | +| Batch_service.create_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.create_job.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.delete_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.delete_job.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.get_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.get_job.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.get_task | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.get_task.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.list_jobs | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.list_jobs.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.list_tasks | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1/batch_service.list_tasks.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.create_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.create_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.create_job.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.delete_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.delete_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.delete_job.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.get_job | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_job.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_job.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.get_task | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_task.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.get_task.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.list_jobs | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_jobs.js,packages/google-cloud-batch/samples/README.md) | +| Batch_service.list_tasks | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/generated/v1alpha/batch_service.list_tasks.js,packages/google-cloud-batch/samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/quickstart.js,packages/google-cloud-batch/samples/README.md) | diff --git a/packages/google-cloud-batch/samples/README.md b/packages/google-cloud-batch/samples/README.md index 716d48a2d69..38d48ec3190 100644 --- a/packages/google-cloud-batch/samples/README.md +++ b/packages/google-cloud-batch/samples/README.md @@ -25,7 +25,6 @@ * [Batch_service.list_jobs](#batch_service.list_jobs) * [Batch_service.list_tasks](#batch_service.list_tasks) * [Quickstart](#quickstart) - * [Quickstart](#quickstart) ## Before you begin @@ -258,23 +257,6 @@ __Usage:__ `node packages/google-cloud-batch/samples/quickstart.js` ------ - - - - -### Quickstart - -View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-batch/samples/test/quickstart.js). - -[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-batch/samples/test/quickstart.js,samples/README.md) - -__Usage:__ - - -`node packages/google-cloud-batch/samples/test/quickstart.js` - - From c7e0f5c03388e87cf81aded132deabec21e0d81d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 16 May 2023 16:02:54 +0000 Subject: [PATCH 12/13] feat: add support for placement policies feat: per-Runnable labels PiperOrigin-RevId: 532437427 Source-Link: https://github.com/googleapis/googleapis/commit/288aa7fb71c9b6244db1a816cfd4108f811e6049 Source-Link: https://github.com/googleapis/googleapis-gen/commit/615d60f8e98ef120a79410c029b4c72448b53bde Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI2MTVkNjBmOGU5OGVmMTIwYTc5NDEwYzAyOWI0YzcyNDQ4YjUzYmRlIn0= --- .../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 | 270 +++ .../v1/protos/google/cloud/batch/v1/job.proto | 539 +++++ .../protos/google/cloud/batch/v1/task.proto | 340 +++ .../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 | 1597 ++++++++++++++ .../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 | 1835 +++++++++++++++++ .../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 | 278 +++ .../google/cloud/batch/v1alpha/job.proto | 655 ++++++ .../google/cloud/batch/v1alpha/task.proto | 355 ++++ .../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 | 79 + .../v1alpha/batch_service.list_tasks.js | 84 + ...t_metadata.google.cloud.batch.v1alpha.json | 307 +++ .../google-cloud-batch/v1alpha/src/index.ts | 25 + .../src/v1alpha/batch_service_client.ts | 1615 +++++++++++++++ .../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 | 1835 +++++++++++++++++ .../google-cloud-batch/v1alpha/tsconfig.json | 19 + .../v1alpha/webpack.config.js | 64 + 64 files changed, 12227 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..d4f03a0df2e --- /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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..91b43dd9dc3 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto @@ -0,0 +1,270 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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 + // the 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 + // the 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..32e1fc416d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto @@ -0,0 +1,539 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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; + } + + // 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + 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; + + // 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/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..b89ba09d0a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto @@ -0,0 +1,340 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..8447d992c48 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1; + +option csharp_namespace = "Google.Cloud.Batch.V1"; +option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; +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..de0c6885153 --- /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 + * the 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..6e2ad9b9488 --- /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 + * the 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..8c8493c6038 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts @@ -0,0 +1,1597 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 + * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 + * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 + * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..f70983ca35f --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts @@ -0,0 +1,1835 @@ +// 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, 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('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..d4f03a0df2e --- /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..bbbfb44aa99 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/.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/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..ab18901cdcd --- /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.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "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..c654d9c2596 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto @@ -0,0 +1,278 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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 + // the 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 + // the 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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; + + // Sort results. Supported are "name", "name desc", "create_time", + // "create_time desc", and "". + string order_by = 5; + + // 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..c4a2201cfbc --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto @@ -0,0 +1,655 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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). Default value is 0. + // Higher value indicates higher priority. + // 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; + + // The VM boot disk. + AllocationPolicy.Disk boot_disk = 4; + } + + // 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; + + // The resource usage of the job. + ResourceUsage resource_usage = 6; +} + +// ResourceUsage describes the resource usage of the job. +message ResourceUsage { + // The CPU core hours that the job consumes. + double core_hours = 1; +} + +// 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and + // 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. + // For example, the following are all valid URLs: + // + // * Specify the image by its family name: + // projects/{project}/global/images/family/{image_family} + // * Specify the image version: + // projects/{project}/global/images/{image_version} + // + // You can also use Batch customized image in short names. + // The following image values are supported for a boot disk: + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. + string image = 4; + + // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. + string snapshot = 5; + } + + // Disk type as shown in `gcloud compute disk-types list`. + // For example, local SSD uses type "local-ssd". + // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" + // or "pd-standard". + string type = 1; + + // Disk size in GB. + // + // For persistent disk, this field is ignored if `data_source` is `image` or + // `snapshot`. + // For local SSD, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. + // For boot disk, Batch will calculate the boot disk size based on source + // image and task requirements if you do not speicify the size. + // If both this field and the boot_disk_mib field in task spec's + // compute_resource are defined, Batch will only honor this field. + 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; + + // Boot disk to be created and attached to each VM by this InstancePolicy. + // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. + 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 consume only the specified reservation. + // If not specified (default), VMs will consume any applicable 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; + } + + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + + // 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; + + // The placement policy. + PlacementPolicy placement = 10; +} + +// 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. + // + // Tasks might be executed in parallel depending on parallelism and + // task_count values. + AS_SOON_AS_POSSIBLE = 1; + + // Run Tasks sequentially with increased task index. + // + // Not yet implemented. + IN_ORDER = 2; + } + + // 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). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. + int64 parallelism = 5; + + // Scheduling policy for Tasks in the TaskGroup. + // The default value is AS_SOON_AS_POSSIBLE. + 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..c7db752b26a --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto @@ -0,0 +1,355 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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; + + // Task State + TaskStatus.State task_state = 5; +} + +// 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; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; + } + + // Task state + State state = 1; + + // Detailed info about why the state is reached. + repeated StatusEvent status_events = 2; + + // The resource usage of the task. + TaskResourceUsage resource_usage = 3; +} + +// TaskResourceUsage describes the resource usage of the task. +message TaskResourceUsage { + // The CPU core hours the task consumes based on task requirement and run + // time. + double core_hours = 1; +} + +// 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, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. + 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. + // + // To specify an interpreter, please add a `#!`(also known as + // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the + // first line of the file.(For example, to execute the script using bash, + // `#!/bin/bash` should be the first line of the file. To execute the + // script using`Python3`, `#!/usr/bin/env python3` should be the first + // line of the file.) Otherwise, the file will by default be excuted by + // `/bin/sh`. + string path = 1; + + // Shell script text. + // + // To specify an interpreter, please add a `#!\n` at the + // beginning of the text.(For example, to execute the script using bash, + // `#!/bin/bash\n` should be added. To execute the script using`Python3`, + // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will + // by default be excuted by `/bin/sh`. + 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. + // Currently we only support one lifecycle policy. + // When the lifecycle policy condition is met, + // the action in the policy will execute. + // If task execution result does not meet with 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. + // When RETRY_TASK is specified, we will retry failed tasks + // if we notice any exit code match and fail tasks if no match is found. + // Likewise, when FAIL_TASK is specified, we will fail tasks + // if we notice any exit code match and retry tasks if no match is found. + 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..5b3d72a7e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.batch.v1alpha; + +option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; +option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; +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..1ca515333b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..3458538cfae --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 + * the 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..92c74b3b847 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..83c71aecb81 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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..16709131898 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..c3268d24c57 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js @@ -0,0 +1,84 @@ +// 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_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' + /** + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + */ + // const orderBy = '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..6821e36d3ec --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json @@ -0,0 +1,307 @@ +{ + "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": 71, + "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": "order_by", + "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": 76, + "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": "order_by", + "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..0395a498ffb --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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 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..bcca459e6fa --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts @@ -0,0 +1,1615 @@ +// 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, 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}; + 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.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.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 + * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 + * the 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy + * Sort results. Supported are "name", "name desc", "create_time", + * "create_time desc", and "". + * @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 + * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 + * {@link google.cloud.location.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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..20125bdd61d --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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..ad5cdbab015 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..a704285f484 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/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/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..b8c39b803c0 --- /dev/null +++ b/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts @@ -0,0 +1,1835 @@ +// 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, 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('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 7884e57df286a19072ddfc47d822cb3c427ddc4a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 16 May 2023 16:07:25 +0000 Subject: [PATCH 13/13] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-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 | 270 --- .../v1/protos/google/cloud/batch/v1/job.proto | 539 ----- .../protos/google/cloud/batch/v1/task.proto | 340 --- .../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 | 1597 -------------- .../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 | 1835 ----------------- .../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 | 278 --- .../google/cloud/batch/v1alpha/job.proto | 655 ------ .../google/cloud/batch/v1alpha/task.proto | 355 ---- .../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 | 79 - .../v1alpha/batch_service.list_tasks.js | 84 - ...t_metadata.google.cloud.batch.v1alpha.json | 307 --- .../google-cloud-batch/v1alpha/src/index.ts | 25 - .../src/v1alpha/batch_service_client.ts | 1615 --------------- .../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 | 1835 ----------------- .../google-cloud-batch/v1alpha/tsconfig.json | 19 - .../v1alpha/webpack.config.js | 64 - .../protos/google/cloud/batch/v1/job.proto | 63 +- .../protos/google/cloud/batch/v1/task.proto | 13 +- .../google-cloud-batch/protos/protos.d.ts | 118 +- packages/google-cloud-batch/protos/protos.js | 347 +++- .../google-cloud-batch/protos/protos.json | 24 +- 69 files changed, 544 insertions(+), 12248 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 d4f03a0df2e..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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 91b43dd9dc3..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/batch.proto +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 - // the 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 - // the 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 32e1fc416d2..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/job.proto +++ /dev/null @@ -1,539 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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; - } - - // 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - 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; - - // 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/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 b89ba09d0a1..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/task.proto +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 8447d992c48..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/protos/google/cloud/batch/v1/volume.proto +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1; - -option csharp_namespace = "Google.Cloud.Batch.V1"; -option go_package = "cloud.google.com/go/batch/apiv1/batchpb;batchpb"; -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 de0c6885153..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 - * the 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 6e2ad9b9488..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 - * the 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 8c8493c6038..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/src/v1/batch_service_client.ts +++ /dev/null @@ -1,1597 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 - * the 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 {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Job | 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 - * {@link google.cloud.batch.v1.Job | 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 {@link google.cloud.batch.v1.Task | 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 {@link google.cloud.batch.v1.Task | 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 - * {@link google.cloud.batch.v1.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 f70983ca35f..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1/test/gapic_batch_service_v1.ts +++ /dev/null @@ -1,1835 +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, 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('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 d4f03a0df2e..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 bbbfb44aa99..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.mocharc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/v1alpha/.prettierrc.js b/owl-bot-staging/google-cloud-batch/v1alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/.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/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 ab18901cdcd..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.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "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 c654d9c2596..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/batch.proto +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 - // the 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 - // the 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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; - - // Sort results. Supported are "name", "name desc", "create_time", - // "create_time desc", and "". - string order_by = 5; - - // 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 c4a2201cfbc..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/job.proto +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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). Default value is 0. - // Higher value indicates higher priority. - // 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; - - // The VM boot disk. - AllocationPolicy.Disk boot_disk = 4; - } - - // 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; - - // The resource usage of the job. - ResourceUsage resource_usage = 6; -} - -// ResourceUsage describes the resource usage of the job. -message ResourceUsage { - // The CPU core hours that the job consumes. - double core_hours = 1; -} - -// 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. - // See https://cloud.google.com/compute/docs/disks#pdspecs and - // 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. - // For example, the following are all valid URLs: - // - // * Specify the image by its family name: - // projects/{project}/global/images/family/{image_family} - // * Specify the image version: - // projects/{project}/global/images/{image_version} - // - // You can also use Batch customized image in short names. - // The following image values are supported for a boot disk: - // - // * "batch-debian": use Batch Debian images. - // * "batch-centos": use Batch CentOS images. - // * "batch-cos": use Batch Container-Optimized images. - string image = 4; - - // Name of a snapshot used as the data source. - // Snapshot is not supported as boot disk now. - string snapshot = 5; - } - - // Disk type as shown in `gcloud compute disk-types list`. - // For example, local SSD uses type "local-ssd". - // Persistent disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" - // or "pd-standard". - string type = 1; - - // Disk size in GB. - // - // For persistent disk, this field is ignored if `data_source` is `image` or - // `snapshot`. - // For local SSD, size_gb should be a multiple of 375GB, - // otherwise, the final size will be the next greater multiple of 375 GB. - // For boot disk, Batch will calculate the boot disk size based on source - // image and task requirements if you do not speicify the size. - // If both this field and the boot_disk_mib field in task spec's - // compute_resource are defined, Batch will only honor this field. - 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; - - // Boot disk to be created and attached to each VM by this InstancePolicy. - // Boot disk will be deleted when the VM is deleted. - // Batch API now only supports booting from image. - 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 consume only the specified reservation. - // If not specified (default), VMs will consume any applicable 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; - } - - // PlacementPolicy describes a group placement policy for the VMs controlled - // by this AllocationPolicy. - message PlacementPolicy { - // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you - // want VMs to be located close to each other for low network latency - // between the VMs. No placement policy will be generated when collocation - // is UNSPECIFIED. - string collocation = 1; - - // When specified, causes the job to fail if more than max_distance logical - // switches are required between VMs. Batch uses the most compact possible - // placement of VMs even when max_distance is not specified. An explicit - // max_distance makes that level of compactness a strict requirement. - // Not yet implemented - int64 max_distance = 2; - } - - // 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; - - // The placement policy. - PlacementPolicy placement = 10; -} - -// 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. - // - // Tasks might be executed in parallel depending on parallelism and - // task_count values. - AS_SOON_AS_POSSIBLE = 1; - - // Run Tasks sequentially with increased task index. - // - // Not yet implemented. - IN_ORDER = 2; - } - - // 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). - // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. - int64 parallelism = 5; - - // Scheduling policy for Tasks in the TaskGroup. - // The default value is AS_SOON_AS_POSSIBLE. - 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 c7db752b26a..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/task.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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 = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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; - - // Task State - TaskStatus.State task_state = 5; -} - -// 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; - - // The Task has not been executed when the Job finishes. - UNEXECUTED = 6; - } - - // Task state - State state = 1; - - // Detailed info about why the state is reached. - repeated StatusEvent status_events = 2; - - // The resource usage of the task. - TaskResourceUsage resource_usage = 3; -} - -// TaskResourceUsage describes the resource usage of the task. -message TaskResourceUsage { - // The CPU core hours the task consumes based on task requirement and run - // time. - double core_hours = 1; -} - -// 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, containers that are with block_external_network as true can - // still communicate with each other, network cannot be specified in the - // `container.options` field. - 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. - // - // To specify an interpreter, please add a `#!`(also known as - // [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix))) as the - // first line of the file.(For example, to execute the script using bash, - // `#!/bin/bash` should be the first line of the file. To execute the - // script using`Python3`, `#!/usr/bin/env python3` should be the first - // line of the file.) Otherwise, the file will by default be excuted by - // `/bin/sh`. - string path = 1; - - // Shell script text. - // - // To specify an interpreter, please add a `#!\n` at the - // beginning of the text.(For example, to execute the script using bash, - // `#!/bin/bash\n` should be added. To execute the script using`Python3`, - // `#!/usr/bin/env python3\n` should be added.) Otherwise, the script will - // by default be excuted by `/bin/sh`. - 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. - // Currently we only support one lifecycle policy. - // When the lifecycle policy condition is met, - // the action in the policy will execute. - // If task execution result does not meet with 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. - // When RETRY_TASK is specified, we will retry failed tasks - // if we notice any exit code match and fail tasks if no match is found. - // Likewise, when FAIL_TASK is specified, we will fail tasks - // if we notice any exit code match and retry tasks if no match is found. - 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 5b3d72a7e80..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/protos/google/cloud/batch/v1alpha/volume.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.batch.v1alpha; - -option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; -option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; -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 1ca515333b0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 3458538cfae..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 - * the 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 92c74b3b847..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 83c71aecb81..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/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_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 16709131898..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_jobs.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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 c3268d24c57..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/batch_service.list_tasks.js +++ /dev/null @@ -1,84 +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_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' - /** - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - */ - // const orderBy = '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 6821e36d3ec..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/samples/generated/v1alpha/snippet_metadata.google.cloud.batch.v1alpha.json +++ /dev/null @@ -1,307 +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": 71, - "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": "order_by", - "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": 76, - "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": "order_by", - "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 0395a498ffb..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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 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 bcca459e6fa..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/batch_service_client.ts +++ /dev/null @@ -1,1615 +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, 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}; - 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.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.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 - * the 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Job | 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 {@link google.cloud.batch.v1alpha.Task | 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 - * the 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Job | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 {@link google.cloud.batch.v1alpha.Task | 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 {string} request.orderBy - * Sort results. Supported are "name", "name desc", "create_time", - * "create_time desc", and "". - * @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 - * {@link google.cloud.batch.v1alpha.Task | 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 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 {@link google.cloud.location.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 - * {@link google.cloud.location.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 | 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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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 {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.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.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 20125bdd61d..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/src/v1alpha/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/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 ad5cdbab015..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 a704285f484..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/v1alpha/system-test/install.ts b/owl-bot-staging/google-cloud-batch/v1alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/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/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 b8c39b803c0..00000000000 --- a/owl-bot-staging/google-cloud-batch/v1alpha/test/gapic_batch_service_v1alpha.ts +++ /dev/null @@ -1,1835 +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, 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('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/protos/google/cloud/batch/v1/job.proto b/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto index 4bed626c1ac..32e1fc416d2 100644 --- a/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto +++ b/packages/google-cloud-batch/protos/google/cloud/batch/v1/job.proto @@ -225,12 +225,14 @@ message JobNotification { 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", @@ -241,25 +243,29 @@ message AllocationPolicy { // 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. + // See https://cloud.google.com/compute/docs/disks#pdspecs and // 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. // For example, the following are all valid URLs: - // (1) Specify the image by its family name: + // + // * Specify the image by its family name: // projects/{project}/global/images/family/{image_family} - // (2) Specify the image version: + // * Specify the image version: // projects/{project}/global/images/{image_version} + // // You can also use Batch customized image in short names. // The following image values are supported for a boot disk: - // "batch-debian": use Batch Debian images. - // "batch-centos": use Batch CentOS images. - // "batch-cos": use Batch Container-Optimized images. + // + // * "batch-debian": use Batch Debian images. + // * "batch-centos": use Batch CentOS images. + // * "batch-cos": use Batch Container-Optimized images. string image = 4; // Name of a snapshot used as the data source. + // Snapshot is not supported as boot disk now. string snapshot = 5; } @@ -270,6 +276,7 @@ message AllocationPolicy { string type = 1; // Disk size in GB. + // // For persistent disk, this field is ignored if `data_source` is `image` or // `snapshot`. // For local SSD, size_gb should be a multiple of 375GB, @@ -324,7 +331,7 @@ message AllocationPolicy { // The minimum CPU platform. // See - // `https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform`. + // https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform. // Not yet implemented. string min_cpu_platform = 3; @@ -334,8 +341,9 @@ message AllocationPolicy { // 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 to be created and attached to each VM by this InstancePolicy. // Boot disk will be deleted when the VM is deleted. + // Batch API now only supports booting from image. Disk boot_disk = 8; // Non-boot disks to be attached for each VM created by this InstancePolicy. @@ -366,18 +374,22 @@ message AllocationPolicy { 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} + // + // * 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} + // + // * 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 @@ -396,6 +408,23 @@ message AllocationPolicy { repeated NetworkInterface network_interfaces = 1; } + // PlacementPolicy describes a group placement policy for the VMs controlled + // by this AllocationPolicy. + message PlacementPolicy { + // UNSPECIFIED vs. COLLOCATED (default UNSPECIFIED). Use COLLOCATED when you + // want VMs to be located close to each other for low network latency + // between the VMs. No placement policy will be generated when collocation + // is UNSPECIFIED. + string collocation = 1; + + // When specified, causes the job to fail if more than max_distance logical + // switches are required between VMs. Batch uses the most compact possible + // placement of VMs even when max_distance is not specified. An explicit + // max_distance makes that level of compactness a strict requirement. + // Not yet implemented + int64 max_distance = 2; + } + // Compute Engine VM instance provisioning model. enum ProvisioningModel { // Unspecified. @@ -437,6 +466,9 @@ message AllocationPolicy { // The network policy. NetworkPolicy network = 7; + + // The placement policy. + PlacementPolicy placement = 10; } // A TaskGroup contains one or multiple Tasks that share the same @@ -457,11 +489,12 @@ message TaskGroup { TaskSpec task_spec = 3 [(google.api.field_behavior) = REQUIRED]; // Number of Tasks in the TaskGroup. - // default is 1 + // Default is 1. int64 task_count = 4; // Max number of tasks that can run in parallel. // Default to min(task_count, 1000). + // Field parallelism must be 1 if the scheduling_policy is IN_ORDER. int64 parallelism = 5; // An array of environment variable mappings, which are passed to Tasks with 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 62e982976c5..b89ba09d0a1 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 @@ -72,7 +72,7 @@ message TaskExecution { message TaskStatus { // Task states. enum State { - // unknown state + // Unknown state. STATE_UNSPECIFIED = 0; // The Task is created and waiting for resources. @@ -89,6 +89,9 @@ message TaskStatus { // The Task has succeeded. SUCCEEDED = 5; + + // The Task has not been executed when the Job finishes. + UNEXECUTED = 6; } // Task state @@ -124,8 +127,9 @@ message Runnable { 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'. + // blocked, containers that are with block_external_network as true can + // still communicate with each other, network cannot be specified in the + // `container.options` field. bool block_external_network = 9; // Optional username for logging in to a docker registry. If username @@ -208,6 +212,9 @@ message Runnable { // Timeout for this Runnable. google.protobuf.Duration timeout = 8; + + // Labels for this Runnable. + map labels = 9; } // Spec of a task diff --git a/packages/google-cloud-batch/protos/protos.d.ts b/packages/google-cloud-batch/protos/protos.d.ts index d3666ea5f61..4c91ccc8898 100644 --- a/packages/google-cloud-batch/protos/protos.d.ts +++ b/packages/google-cloud-batch/protos/protos.d.ts @@ -2031,6 +2031,9 @@ export namespace google { /** AllocationPolicy network */ network?: (google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null); + + /** AllocationPolicy placement */ + placement?: (google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null); } /** Represents an AllocationPolicy. */ @@ -2057,6 +2060,9 @@ export namespace google { /** AllocationPolicy network. */ public network?: (google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null); + /** AllocationPolicy placement. */ + public placement?: (google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null); + /** * Creates a new AllocationPolicy instance using the specified properties. * @param [properties] Properties to set @@ -3024,6 +3030,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a PlacementPolicy. */ + interface IPlacementPolicy { + + /** PlacementPolicy collocation */ + collocation?: (string|null); + + /** PlacementPolicy maxDistance */ + maxDistance?: (number|Long|string|null); + } + + /** Represents a PlacementPolicy. */ + class PlacementPolicy implements IPlacementPolicy { + + /** + * Constructs a new PlacementPolicy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy); + + /** PlacementPolicy collocation. */ + public collocation: string; + + /** PlacementPolicy maxDistance. */ + public maxDistance: (number|Long|string); + + /** + * Creates a new PlacementPolicy instance using the specified properties. + * @param [properties] Properties to set + * @returns PlacementPolicy instance + */ + public static create(properties?: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy): google.cloud.batch.v1.AllocationPolicy.PlacementPolicy; + + /** + * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @param message PlacementPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @param message PlacementPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PlacementPolicy + * @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.AllocationPolicy.PlacementPolicy; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PlacementPolicy + * @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.AllocationPolicy.PlacementPolicy; + + /** + * Verifies a PlacementPolicy 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 PlacementPolicy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PlacementPolicy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.batch.v1.AllocationPolicy.PlacementPolicy; + + /** + * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. + * @param message PlacementPolicy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.batch.v1.AllocationPolicy.PlacementPolicy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PlacementPolicy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PlacementPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** ProvisioningModel enum. */ enum ProvisioningModel { PROVISIONING_MODEL_UNSPECIFIED = 0, @@ -3714,7 +3823,8 @@ export namespace google { ASSIGNED = 2, RUNNING = 3, FAILED = 4, - SUCCEEDED = 5 + SUCCEEDED = 5, + UNEXECUTED = 6 } } @@ -3744,6 +3854,9 @@ export namespace google { /** Runnable timeout */ timeout?: (google.protobuf.IDuration|null); + + /** Runnable labels */ + labels?: ({ [k: string]: string }|null); } /** Represents a Runnable. */ @@ -3779,6 +3892,9 @@ export namespace google { /** Runnable timeout. */ public timeout?: (google.protobuf.IDuration|null); + /** Runnable labels. */ + public labels: { [k: string]: string }; + /** Runnable executable. */ public executable?: ("container"|"script"|"barrier"); diff --git a/packages/google-cloud-batch/protos/protos.js b/packages/google-cloud-batch/protos/protos.js index f3f723e7db7..057cb5df633 100644 --- a/packages/google-cloud-batch/protos/protos.js +++ b/packages/google-cloud-batch/protos/protos.js @@ -4974,6 +4974,7 @@ case 3: case 4: case 5: + case 6: break; } return null; @@ -5078,6 +5079,10 @@ case 5: message.newTaskState = 5; break; + case "UNEXECUTED": + case 6: + message.newTaskState = 6; + break; } return message; }; @@ -5168,6 +5173,7 @@ * @property {google.cloud.batch.v1.IServiceAccount|null} [serviceAccount] AllocationPolicy serviceAccount * @property {Object.|null} [labels] AllocationPolicy labels * @property {google.cloud.batch.v1.AllocationPolicy.INetworkPolicy|null} [network] AllocationPolicy network + * @property {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null} [placement] AllocationPolicy placement */ /** @@ -5227,6 +5233,14 @@ */ AllocationPolicy.prototype.network = null; + /** + * AllocationPolicy placement. + * @member {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy|null|undefined} placement + * @memberof google.cloud.batch.v1.AllocationPolicy + * @instance + */ + AllocationPolicy.prototype.placement = null; + /** * Creates a new AllocationPolicy instance using the specified properties. * @function create @@ -5263,6 +5277,8 @@ $root.google.cloud.batch.v1.AllocationPolicy.InstancePolicyOrTemplate.encode(message.instances[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) $root.google.cloud.batch.v1.ServiceAccount.encode(message.serviceAccount, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.encode(message.placement, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -5338,6 +5354,10 @@ message.network = $root.google.cloud.batch.v1.AllocationPolicy.NetworkPolicy.decode(reader, reader.uint32()); break; } + case 10: { + message.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -5405,6 +5425,11 @@ if (error) return "network." + error; } + if (message.placement != null && message.hasOwnProperty("placement")) { + var error = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify(message.placement); + if (error) + return "placement." + error; + } return null; }; @@ -5452,6 +5477,11 @@ throw TypeError(".google.cloud.batch.v1.AllocationPolicy.network: object expected"); message.network = $root.google.cloud.batch.v1.AllocationPolicy.NetworkPolicy.fromObject(object.network); } + if (object.placement != null) { + if (typeof object.placement !== "object") + throw TypeError(".google.cloud.batch.v1.AllocationPolicy.placement: object expected"); + message.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.fromObject(object.placement); + } return message; }; @@ -5476,6 +5506,7 @@ object.location = null; object.network = null; object.serviceAccount = null; + object.placement = null; } if (message.location != null && message.hasOwnProperty("location")) object.location = $root.google.cloud.batch.v1.AllocationPolicy.LocationPolicy.toObject(message.location, options); @@ -5494,6 +5525,8 @@ } if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) object.serviceAccount = $root.google.cloud.batch.v1.ServiceAccount.toObject(message.serviceAccount, options); + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.toObject(message.placement, options); return object; }; @@ -7772,6 +7805,247 @@ return NetworkPolicy; })(); + AllocationPolicy.PlacementPolicy = (function() { + + /** + * Properties of a PlacementPolicy. + * @memberof google.cloud.batch.v1.AllocationPolicy + * @interface IPlacementPolicy + * @property {string|null} [collocation] PlacementPolicy collocation + * @property {number|Long|null} [maxDistance] PlacementPolicy maxDistance + */ + + /** + * Constructs a new PlacementPolicy. + * @memberof google.cloud.batch.v1.AllocationPolicy + * @classdesc Represents a PlacementPolicy. + * @implements IPlacementPolicy + * @constructor + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set + */ + function PlacementPolicy(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]]; + } + + /** + * PlacementPolicy collocation. + * @member {string} collocation + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @instance + */ + PlacementPolicy.prototype.collocation = ""; + + /** + * PlacementPolicy maxDistance. + * @member {number|Long} maxDistance + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @instance + */ + PlacementPolicy.prototype.maxDistance = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PlacementPolicy instance using the specified properties. + * @function create + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy=} [properties] Properties to set + * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy instance + */ + PlacementPolicy.create = function create(properties) { + return new PlacementPolicy(properties); + }; + + /** + * Encodes the specified PlacementPolicy message. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @function encode + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlacementPolicy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.collocation != null && Object.hasOwnProperty.call(message, "collocation")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.collocation); + if (message.maxDistance != null && Object.hasOwnProperty.call(message, "maxDistance")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.maxDistance); + return writer; + }; + + /** + * Encodes the specified PlacementPolicy message, length delimited. Does not implicitly {@link google.cloud.batch.v1.AllocationPolicy.PlacementPolicy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.IPlacementPolicy} message PlacementPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlacementPolicy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @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.AllocationPolicy.PlacementPolicy} PlacementPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlacementPolicy.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.AllocationPolicy.PlacementPolicy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.collocation = reader.string(); + break; + } + case 2: { + message.maxDistance = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PlacementPolicy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlacementPolicy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PlacementPolicy message. + * @function verify + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PlacementPolicy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.collocation != null && message.hasOwnProperty("collocation")) + if (!$util.isString(message.collocation)) + return "collocation: string expected"; + if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) + if (!$util.isInteger(message.maxDistance) && !(message.maxDistance && $util.isInteger(message.maxDistance.low) && $util.isInteger(message.maxDistance.high))) + return "maxDistance: integer|Long expected"; + return null; + }; + + /** + * Creates a PlacementPolicy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} PlacementPolicy + */ + PlacementPolicy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy) + return object; + var message = new $root.google.cloud.batch.v1.AllocationPolicy.PlacementPolicy(); + if (object.collocation != null) + message.collocation = String(object.collocation); + if (object.maxDistance != null) + if ($util.Long) + (message.maxDistance = $util.Long.fromValue(object.maxDistance)).unsigned = false; + else if (typeof object.maxDistance === "string") + message.maxDistance = parseInt(object.maxDistance, 10); + else if (typeof object.maxDistance === "number") + message.maxDistance = object.maxDistance; + else if (typeof object.maxDistance === "object") + message.maxDistance = new $util.LongBits(object.maxDistance.low >>> 0, object.maxDistance.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PlacementPolicy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {google.cloud.batch.v1.AllocationPolicy.PlacementPolicy} message PlacementPolicy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PlacementPolicy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.collocation = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.maxDistance = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.maxDistance = options.longs === String ? "0" : 0; + } + if (message.collocation != null && message.hasOwnProperty("collocation")) + object.collocation = message.collocation; + if (message.maxDistance != null && message.hasOwnProperty("maxDistance")) + if (typeof message.maxDistance === "number") + object.maxDistance = options.longs === String ? String(message.maxDistance) : message.maxDistance; + else + object.maxDistance = options.longs === String ? $util.Long.prototype.toString.call(message.maxDistance) : options.longs === Number ? new $util.LongBits(message.maxDistance.low >>> 0, message.maxDistance.high >>> 0).toNumber() : message.maxDistance; + return object; + }; + + /** + * Converts this PlacementPolicy to JSON. + * @function toJSON + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @instance + * @returns {Object.} JSON object + */ + PlacementPolicy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PlacementPolicy + * @function getTypeUrl + * @memberof google.cloud.batch.v1.AllocationPolicy.PlacementPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PlacementPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.batch.v1.AllocationPolicy.PlacementPolicy"; + }; + + return PlacementPolicy; + })(); + /** * ProvisioningModel enum. * @name google.cloud.batch.v1.AllocationPolicy.ProvisioningModel @@ -8979,6 +9253,7 @@ case 3: case 4: case 5: + case 6: break; } return null; @@ -9041,6 +9316,10 @@ case 5: message.taskState = 5; break; + case "UNEXECUTED": + case 6: + message.taskState = 6; + break; } return message; }; @@ -9470,6 +9749,7 @@ case 3: case 4: case 5: + case 6: break; } if (message.statusEvents != null && message.hasOwnProperty("statusEvents")) { @@ -9527,6 +9807,10 @@ case 5: message.state = 5; break; + case "UNEXECUTED": + case 6: + message.state = 6; + break; } if (object.statusEvents) { if (!Array.isArray(object.statusEvents)) @@ -9604,6 +9888,7 @@ * @property {number} RUNNING=3 RUNNING value * @property {number} FAILED=4 FAILED value * @property {number} SUCCEEDED=5 SUCCEEDED value + * @property {number} UNEXECUTED=6 UNEXECUTED value */ TaskStatus.State = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -9613,6 +9898,7 @@ values[valuesById[3] = "RUNNING"] = 3; values[valuesById[4] = "FAILED"] = 4; values[valuesById[5] = "SUCCEEDED"] = 5; + values[valuesById[6] = "UNEXECUTED"] = 6; return values; })(); @@ -9633,6 +9919,7 @@ * @property {boolean|null} [alwaysRun] Runnable alwaysRun * @property {google.cloud.batch.v1.IEnvironment|null} [environment] Runnable environment * @property {google.protobuf.IDuration|null} [timeout] Runnable timeout + * @property {Object.|null} [labels] Runnable labels */ /** @@ -9644,6 +9931,7 @@ * @param {google.cloud.batch.v1.IRunnable=} [properties] Properties to set */ function Runnable(properties) { + this.labels = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -9714,6 +10002,14 @@ */ Runnable.prototype.timeout = null; + /** + * Runnable labels. + * @member {Object.} labels + * @memberof google.cloud.batch.v1.Runnable + * @instance + */ + Runnable.prototype.labels = $util.emptyObject; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -9768,6 +10064,9 @@ $root.google.cloud.batch.v1.Environment.encode(message.environment, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.timeout != null && Object.hasOwnProperty.call(message, "timeout")) $root.google.protobuf.Duration.encode(message.timeout, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); return writer; }; @@ -9798,7 +10097,7 @@ Runnable.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.Runnable(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.batch.v1.Runnable(), key, value; while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { @@ -9834,6 +10133,29 @@ message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 9: { + if (message.labels === $util.emptyObject) + message.labels = {}; + 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.labels[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -9917,6 +10239,14 @@ if (error) return "timeout." + error; } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } return null; }; @@ -9963,6 +10293,13 @@ throw TypeError(".google.cloud.batch.v1.Runnable.timeout: object expected"); message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.batch.v1.Runnable.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } return message; }; @@ -9979,6 +10316,8 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.labels = {}; if (options.defaults) { object.ignoreExitStatus = false; object.background = false; @@ -10011,6 +10350,12 @@ object.environment = $root.google.cloud.batch.v1.Environment.toObject(message.environment, options); if (message.timeout != null && message.hasOwnProperty("timeout")) object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } return object; }; diff --git a/packages/google-cloud-batch/protos/protos.json b/packages/google-cloud-batch/protos/protos.json index e64eb1bbbdd..986b1da644a 100644 --- a/packages/google-cloud-batch/protos/protos.json +++ b/packages/google-cloud-batch/protos/protos.json @@ -576,6 +576,10 @@ "network": { "type": "NetworkPolicy", "id": 7 + }, + "placement": { + "type": "PlacementPolicy", + "id": 10 } }, "nested": { @@ -742,6 +746,18 @@ } } }, + "PlacementPolicy": { + "fields": { + "collocation": { + "type": "string", + "id": 1 + }, + "maxDistance": { + "type": "int64", + "id": 2 + } + } + }, "ProvisioningModel": { "values": { "PROVISIONING_MODEL_UNSPECIFIED": 0, @@ -880,7 +896,8 @@ "ASSIGNED": 2, "RUNNING": 3, "FAILED": 4, - "SUCCEEDED": 5 + "SUCCEEDED": 5, + "UNEXECUTED": 6 } } } @@ -927,6 +944,11 @@ "timeout": { "type": "google.protobuf.Duration", "id": 8 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 9 } }, "nested": {