From 444e5eb6022111d5481c749cc12c557bcb3d05c4 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 13 Dec 2022 22:46:56 +0000 Subject: [PATCH 1/2] feat: Updated Client Libraries for Cloud Scheduler PiperOrigin-RevId: 495092454 Source-Link: https://github.com/googleapis/googleapis/commit/3fbdb936942430bcba3208ad2b8267801819a2fd Source-Link: https://github.com/googleapis/googleapis-gen/commit/ecf0b6c90ee76e53e38cb8ea5f60475f2b4e320c Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNjaGVkdWxlci8uT3dsQm90LnlhbWwiLCJoIjoiZWNmMGI2YzkwZWU3NmU1M2UzOGNiOGVhNWY2MDQ3NWYyYjRlMzIwYyJ9 --- .../google-cloud-scheduler/v1/.eslintignore | 7 + .../google-cloud-scheduler/v1/.eslintrc.json | 3 + .../google-cloud-scheduler/v1/.gitignore | 14 + .../google-cloud-scheduler/v1/.jsdoc.js | 55 + .../google-cloud-scheduler/v1/.mocharc.js | 33 + .../google-cloud-scheduler/v1/.prettierrc.js | 22 + .../google-cloud-scheduler/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../google-cloud-scheduler/v1/package.json | 64 + .../cloud/scheduler/v1/cloudscheduler.proto | 268 +++ .../google/cloud/scheduler/v1/job.proto | 236 +++ .../google/cloud/scheduler/v1/target.proto | 355 ++++ .../v1/cloud_scheduler.create_job.js | 71 + .../v1/cloud_scheduler.delete_job.js | 62 + .../generated/v1/cloud_scheduler.get_job.js | 62 + .../generated/v1/cloud_scheduler.list_jobs.js | 82 + .../generated/v1/cloud_scheduler.pause_job.js | 62 + .../v1/cloud_scheduler.resume_job.js | 62 + .../generated/v1/cloud_scheduler.run_job.js | 62 + .../v1/cloud_scheduler.update_job.js | 68 + ...et_metadata.google.cloud.scheduler.v1.json | 351 ++++ .../google-cloud-scheduler/v1/src/index.ts | 25 + .../v1/src/v1/cloud_scheduler_client.ts | 1189 +++++++++++++ .../src/v1/cloud_scheduler_client_config.json | 66 + .../v1/src/v1/cloud_scheduler_proto_list.json | 5 + .../v1/src/v1/gapic_metadata.json | 107 ++ .../google-cloud-scheduler/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_cloud_scheduler_v1.ts | 1319 +++++++++++++++ .../google-cloud-scheduler/v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../google-cloud-scheduler/v1beta1/.gitignore | 14 + .../google-cloud-scheduler/v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../google-cloud-scheduler/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 16 + .../v1beta1/package.json | 64 + .../scheduler/v1beta1/cloudscheduler.proto | 315 ++++ .../google/cloud/scheduler/v1beta1/job.proto | 268 +++ .../cloud/scheduler/v1beta1/target.proto | 371 ++++ .../v1beta1/cloud_scheduler.create_job.js | 72 + .../v1beta1/cloud_scheduler.delete_job.js | 68 + .../v1beta1/cloud_scheduler.get_job.js | 62 + .../v1beta1/cloud_scheduler.list_jobs.js | 101 ++ .../v1beta1/cloud_scheduler.pause_job.js | 62 + .../v1beta1/cloud_scheduler.resume_job.js | 62 + .../v1beta1/cloud_scheduler.run_job.js | 68 + .../v1beta1/cloud_scheduler.update_job.js | 68 + ...tadata.google.cloud.scheduler.v1beta1.json | 367 ++++ .../v1beta1/src/index.ts | 25 + .../src/v1beta1/cloud_scheduler_client.ts | 1344 +++++++++++++++ .../cloud_scheduler_client_config.json | 66 + .../v1beta1/cloud_scheduler_proto_list.json | 5 + .../v1beta1/src/v1beta1/gapic_metadata.json | 107 ++ .../v1beta1/src/v1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../test/gapic_cloud_scheduler_v1beta1.ts | 1485 +++++++++++++++++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + 66 files changed, 10218 insertions(+) create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/README.md create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/package.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js new file mode 100644 index 00000000000..08156a43898 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/scheduler', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/README.md b/owl-bot-staging/google-cloud-scheduler/v1/README.md new file mode 100644 index 00000000000..90fa2a2d162 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/README.md @@ -0,0 +1 @@ +Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1/linkinator.config.json b/owl-bot-staging/google-cloud-scheduler/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/package.json b/owl-bot-staging/google-cloud-scheduler/v1/package.json new file mode 100644 index 00000000000..312a11e17f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/scheduler", + "version": "0.1.0", + "description": "Scheduler client for Node.js", + "repository": "googleapis/nodejs-scheduler", + "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 scheduler", + "scheduler", + "cloud scheduler" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto new file mode 100644 index 00000000000..89ce8cbd338 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto @@ -0,0 +1,268 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.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.scheduler.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/scheduler/v1/job.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1;scheduler"; +option java_multiple_files = true; +option java_outer_classname = "SchedulerProto"; +option java_package = "com.google.cloud.scheduler.v1"; +option objc_class_prefix = "SCHEDULER"; + +// The Cloud Scheduler API allows external entities to reliably +// schedule asynchronous jobs. +service CloudScheduler { + option (google.api.default_host) = "cloudscheduler.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists jobs. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a job. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates 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"; + } + + // Updates a job. + // + // If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does + // not exist, `NOT_FOUND` is returned. + // + // If UpdateJob does not successfully return, it is possible for the + // job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in this state may + // not be executed. If this happens, retry the UpdateJob request + // until a successful response is received. + rpc UpdateJob(UpdateJobRequest) returns (Job) { + option (google.api.http) = { + patch: "/v1/{job.name=projects/*/locations/*/jobs/*}" + body: "job" + }; + option (google.api.method_signature) = "job,update_mask"; + } + + // Deletes a job. + rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses a job. + // + // If a job is paused then the system will stop executing the job + // until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The + // state of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if paused it + // will be set to [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] + // to be paused. + rpc PauseJob(PauseJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/jobs/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resume a job. + // + // This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The + // state of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it + // will be set to [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in + // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed. + rpc ResumeJob(ResumeJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/jobs/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Forces a job to run now. + // + // When this method is called, Cloud Scheduler will dispatch the job, even + // if the job is already running. + rpc RunJob(RunJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/jobs/*}:run" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request message for listing jobs using [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. +message ListJobsRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // Requested page size. + // + // The maximum page size is 500. If unspecified, the page size will + // be the maximum. Fewer jobs than requested might be returned, + // even if more jobs exist; use next_page_token to determine if more + // jobs exist. + int32 page_size = 5; + + // A token identifying a page of results the server will return. To + // request the first page results, page_token must be empty. To + // request the next page of results, page_token must be the value of + // [next_page_token][google.cloud.scheduler.v1.ListJobsResponse.next_page_token] returned from + // the previous call to [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. It is an error to + // switch the value of [filter][google.cloud.scheduler.v1.ListJobsRequest.filter] or + // [order_by][google.cloud.scheduler.v1.ListJobsRequest.order_by] while iterating through pages. + string page_token = 6; +} + +// Response message for listing jobs using [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. +message ListJobsResponse { + // The list of jobs. + repeated Job jobs = 1; + + // A token to retrieve next page of results. Pass this value in the + // [page_token][google.cloud.scheduler.v1.ListJobsRequest.page_token] field in the subsequent call to + // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs] to retrieve the next page of results. + // If this is empty it indicates that there are no more results + // through which to paginate. + // + // The page token is valid for only 2 hours. + string next_page_token = 2; +} + +// Request message for [GetJob][google.cloud.scheduler.v1.CloudScheduler.GetJob]. +message GetJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob]. +message CreateJobRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // Required. The job to add. The user can optionally specify a name for the + // job in [name][google.cloud.scheduler.v1.Job.name]. [name][google.cloud.scheduler.v1.Job.name] cannot be the same as an + // existing job. If a name is not specified then the system will + // generate a random unique name that will be returned + // ([name][google.cloud.scheduler.v1.Job.name]) in the response. + Job job = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. +message UpdateJobRequest { + // Required. The new job properties. [name][google.cloud.scheduler.v1.Job.name] must be specified. + // + // Output only fields cannot be modified using UpdateJob. + // Any value specified for an output only field will be ignored. + Job job = 1 [(google.api.field_behavior) = REQUIRED]; + + // A mask used to specify which fields of the job are being updated. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for deleting a job using +// [DeleteJob][google.cloud.scheduler.v1.CloudScheduler.DeleteJob]. +message DeleteJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for [PauseJob][google.cloud.scheduler.v1.CloudScheduler.PauseJob]. +message PauseJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. +message ResumeJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for forcing a job to run now using +// [RunJob][google.cloud.scheduler.v1.CloudScheduler.RunJob]. +message RunJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto new file mode 100644 index 00000000000..7e43ff1647f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto @@ -0,0 +1,236 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.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.scheduler.v1; + +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1/target.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1;scheduler"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.scheduler.v1"; + +// Configuration for a job. +// The maximum allowed size for a job is 100KB. +message Job { + option (google.api.resource) = { + type: "cloudscheduler.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + }; + + // State of the job. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The job is executing normally. + ENABLED = 1; + + // The job is paused by the user. It will not execute. A user can + // intentionally pause the job using + // [PauseJobRequest][google.cloud.scheduler.v1.PauseJobRequest]. + PAUSED = 2; + + // The job is disabled by the system due to error. The user + // cannot directly set a job to be disabled. + DISABLED = 3; + + // The job state resulting from a failed [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] + // operation. To recover a job from this state, retry + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] until a successful response is received. + UPDATE_FAILED = 4; + } + + // Optionally caller-specified in [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob], after + // which it becomes output only. + // + // The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + // + // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), colons (:), or periods (.). + // For more information, see + // [Identifying + // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) + // * `LOCATION_ID` is the canonical ID for the job's location. + // The list of available locations can be obtained by calling + // [ListLocations][google.cloud.location.Locations.ListLocations]. + // For more information, see https://cloud.google.com/about/locations/. + // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), or underscores (_). The maximum length is 500 characters. + string name = 1; + + // Optionally caller-specified in [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob] or + // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. + // + // A human-readable description for the job. This string must not contain + // more than 500 characters. + string description = 2; + + // Required. + // + // Delivery settings containing destination and parameters. + oneof target { + // Pub/Sub target. + PubsubTarget pubsub_target = 4; + + // App Engine HTTP target. + AppEngineHttpTarget app_engine_http_target = 5; + + // HTTP target. + HttpTarget http_target = 6; + } + + // Required, except when used with [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. + // + // Describes the schedule on which the job will be executed. + // + // The schedule can be either of the following types: + // + // * [Crontab](http://en.wikipedia.org/wiki/Cron#Overview) + // * English-like + // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) + // + // As a general rule, execution `n + 1` of a job will not begin + // until execution `n` has finished. Cloud Scheduler will never + // allow two simultaneously outstanding executions. For example, + // this implies that if the `n+1`th execution is scheduled to run at + // 16:00 but the `n`th execution takes until 16:15, the `n+1`th + // execution will not start until `16:15`. + // A scheduled start time will be delayed if the previous + // execution has not ended when its scheduled time occurs. + // + // If [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] > 0 and a job attempt fails, + // the job will be tried a total of [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] + // times, with exponential backoff, until the next scheduled start + // time. + string schedule = 20; + + // Specifies the time zone to be used in interpreting + // [schedule][google.cloud.scheduler.v1.Job.schedule]. The value of this field must be a time + // zone name from the [tz database](http://en.wikipedia.org/wiki/Tz_database). + // + // Note that some time zones include a provision for + // daylight savings time. The rules for daylight saving time are + // determined by the chosen tz. For UTC use the string "utc". If a + // time zone is not specified, the default will be in UTC (also known + // as GMT). + string time_zone = 21; + + // Output only. The creation time of the job. + google.protobuf.Timestamp user_update_time = 9; + + // Output only. State of the job. + State state = 10; + + // Output only. The response from the target for the last attempted execution. + google.rpc.Status status = 11; + + // Output only. The next time the job is scheduled. Note that this may be a + // retry of a previously failed attempt or the next execution time + // according to the schedule. + google.protobuf.Timestamp schedule_time = 17; + + // Output only. The time the last job attempt started. + google.protobuf.Timestamp last_attempt_time = 18; + + // Settings that determine the retry behavior. + RetryConfig retry_config = 19; + + // The deadline for job attempts. If the request handler does not respond by + // this deadline then the request is cancelled and the attempt is marked as a + // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in + // execution logs. Cloud Scheduler will retry the job according + // to the [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. + // + // The allowed duration for this deadline is: + // * For [HTTP targets][google.cloud.scheduler.v1.Job.http_target], between 15 seconds and 30 minutes. + // * For [App Engine HTTP targets][google.cloud.scheduler.v1.Job.app_engine_http_target], between 15 + // seconds and 24 hours. + google.protobuf.Duration attempt_deadline = 22; +} + +// Settings that determine the retry behavior. +// +// By default, if a job does not complete successfully (meaning that +// an acknowledgement is not received from the handler, then it will be retried +// with exponential backoff according to the settings in [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. +message RetryConfig { + // The number of attempts that the system will make to run a job using the + // exponential backoff procedure described by + // [max_doublings][google.cloud.scheduler.v1.RetryConfig.max_doublings]. + // + // The default value of retry_count is zero. + // + // If retry_count is zero, a job attempt will *not* be retried if + // it fails. Instead the Cloud Scheduler system will wait for the + // next scheduled execution time. + // + // If retry_count is set to a non-zero number then Cloud Scheduler + // will retry failed attempts, using exponential backoff, + // retry_count times, or until the next scheduled execution time, + // whichever comes first. + // + // Values greater than 5 and negative values are not allowed. + int32 retry_count = 1; + + // The time limit for retrying a failed job, measured from time when an + // execution was first attempted. If specified with + // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count], the job will be retried until both + // limits are reached. + // + // The default value for max_retry_duration is zero, which means retry + // duration is unlimited. + google.protobuf.Duration max_retry_duration = 2; + + // The minimum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 5 seconds. + google.protobuf.Duration min_backoff_duration = 3; + + // The maximum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 1 hour. + google.protobuf.Duration max_backoff_duration = 4; + + // The time between retries will double `max_doublings` times. + // + // A job's retry interval starts at + // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration], then doubles + // `max_doublings` times, then increases linearly, and finally + // retries retries at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] up to + // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times. + // + // For example, if [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration] is + // 10s, [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] is 300s, and + // `max_doublings` is 3, then the a job will first be retried in 10s. The + // retry interval will double three times, and then increase linearly by + // 2^3 * 10s. Finally, the job will retry at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] until the job has + // been attempted [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times. Thus, the + // requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, .... + // + // The default value of this field is 5. + int32 max_doublings = 5; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto new file mode 100644 index 00000000000..07466ce9765 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto @@ -0,0 +1,355 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.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.scheduler.v1; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1;scheduler"; +option java_multiple_files = true; +option java_outer_classname = "TargetProto"; +option java_package = "com.google.cloud.scheduler.v1"; + +// Http target. The job will be pushed to the job handler by means of +// an HTTP request via an [http_method][google.cloud.scheduler.v1.HttpTarget.http_method] such as HTTP +// POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. A failure to receive a response +// constitutes a failed execution. For a redirected request, the response +// returned by the redirected request is considered. +message HttpTarget { + // Required. The full URI path that the request will be sent to. This string + // must begin with either "http://" or "https://". Some examples of + // valid values for [uri][google.cloud.scheduler.v1.HttpTarget.uri] are: + // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will + // encode some characters for safety and compatibility. The maximum allowed + // URL length is 2083 characters after encoding. + string uri = 1; + + // Which HTTP method to use for the request. + HttpMethod http_method = 2; + + // The user can specify HTTP request headers to send with the job's + // HTTP request. This map contains the header field names and + // values. Repeated headers are not supported, but a header value can + // contain commas. These headers represent a subset of the headers + // that will accompany the job's HTTP request. Some HTTP request + // headers will be ignored or replaced. A partial list of headers that + // will be ignored or replaced is below: + // - Host: This will be computed by Cloud Scheduler and derived from + // [uri][google.cloud.scheduler.v1.HttpTarget.uri]. + // * `Content-Length`: This will be computed by Cloud Scheduler. + // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. + // * `X-Google-*`: Google internal use only. + // * `X-AppEngine-*`: Google internal use only. + // + // The total size of headers must be less than 80KB. + map headers = 3; + + // HTTP request body. A request body is allowed only if the HTTP + // method is POST, PUT, or PATCH. It is an error to set body on a job with an + // incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. + bytes body = 4; + + // The mode for generating an `Authorization` header for HTTP requests. + // + // If specified, all `Authorization` headers in the [HttpTarget.headers][google.cloud.scheduler.v1.HttpTarget.headers] + // field will be overridden. + oneof authorization_header { + // If specified, an + // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) + // will be generated and attached as an `Authorization` header in the HTTP + // request. + // + // This type of authorization should generally only be used when calling + // Google APIs hosted on *.googleapis.com. + OAuthToken oauth_token = 5; + + // If specified, an + // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) + // token will be generated and attached as an `Authorization` header in the + // HTTP request. + // + // This type of authorization can be used for many scenarios, including + // calling Cloud Run, or endpoints where you intend to validate the token + // yourself. + OidcToken oidc_token = 6; + } +} + +// App Engine target. The job will be pushed to a job handler by means +// of an HTTP request via an [http_method][google.cloud.scheduler.v1.AppEngineHttpTarget.http_method] such +// as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an +// HTTP response code in the range [200 - 299]. Error 503 is +// considered an App Engine system error instead of an application +// error. Requests returning error 503 will be retried regardless of +// retry configuration and not counted against retry counts. Any other +// response code, or a failure to receive a response before the +// deadline, constitutes a failed attempt. +message AppEngineHttpTarget { + // The HTTP method to use for the request. PATCH and OPTIONS are not + // permitted. + HttpMethod http_method = 1; + + // App Engine Routing setting for the job. + AppEngineRouting app_engine_routing = 2; + + // The relative URI. + // + // The relative URL must begin with "/" and must be a valid HTTP relative URL. + // It can contain a path, query string arguments, and `#` fragments. + // If the relative URL is empty, then the root path "/" will be used. + // No spaces are allowed, and the maximum length allowed is 2083 characters. + string relative_uri = 3; + + // HTTP request headers. + // + // This map contains the header field names and values. Headers can be set + // when the job is created. + // + // Cloud Scheduler sets some headers to default values: + // + // * `User-Agent`: By default, this header is + // `"AppEngine-Google; (+http://code.google.com/appengine)"`. + // This header can be modified, but Cloud Scheduler will append + // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the + // modified `User-Agent`. + // * `X-CloudScheduler`: This header will be set to true. + // + // If the job has an [body][google.cloud.scheduler.v1.AppEngineHttpTarget.body], Cloud Scheduler sets + // the following headers: + // + // * `Content-Type`: By default, the `Content-Type` header is set to + // `"application/octet-stream"`. The default can be overridden by explictly + // setting `Content-Type` to a particular media type when the job is + // created. + // For example, `Content-Type` can be set to `"application/json"`. + // * `Content-Length`: This is computed by Cloud Scheduler. This value is + // output only. It cannot be changed. + // + // The headers below are output only. They cannot be set or overridden: + // + // * `X-Google-*`: For Google internal use only. + // * `X-AppEngine-*`: For Google internal use only. + // + // In addition, some App Engine headers, which contain + // job-specific information, are also be sent to the job handler. + map headers = 4; + + // Body. + // + // HTTP request body. A request body is allowed only if the HTTP method is + // POST or PUT. It will result in invalid argument error to set a body on a + // job with an incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. + bytes body = 5; +} + +// Pub/Sub target. The job will be delivered by publishing a message to +// the given Pub/Sub topic. +message PubsubTarget { + // Required. The name of the Cloud Pub/Sub topic to which messages will + // be published when a job is delivered. The topic name must be in the + // same format as required by PubSub's + // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), + // for example `projects/PROJECT_ID/topics/TOPIC_ID`. + // + // The topic must be in the same project as the Cloud Scheduler job. + string topic_name = 1 [(google.api.resource_reference) = { + type: "pubsub.googleapis.com/Topic" + }]; + + // The message payload for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + bytes data = 3; + + // Attributes for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + map attributes = 4; +} + +// App Engine Routing. +// +// For more information about services, versions, and instances see +// [An Overview of App +// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), +// [Microservices Architecture on Google App +// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), +// [App Engine Standard request +// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), +// and [App Engine Flex request +// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). +message AppEngineRouting { + // App service. + // + // By default, the job is sent to the service which is the default + // service when the job is attempted. + string service = 1; + + // App version. + // + // By default, the job is sent to the version which is the default + // version when the job is attempted. + string version = 2; + + // App instance. + // + // By default, the job is sent to an instance which is available when + // the job is attempted. + // + // Requests can only be sent to a specific instance if + // [manual scaling is used in App Engine + // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes). + // App Engine Flex does not support instances. For more information, see + // [App Engine Standard request + // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) + // and [App Engine Flex request + // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). + string instance = 3; + + // Output only. The host that the job is sent to. + // + // For more information about how App Engine requests are routed, see + // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). + // + // The host is constructed as: + // + // + // * `host = [application_domain_name]`
+ // `| [service] + '.' + [application_domain_name]`
+ // `| [version] + '.' + [application_domain_name]`
+ // `| [version_dot_service]+ '.' + [application_domain_name]`
+ // `| [instance] + '.' + [application_domain_name]`
+ // `| [instance_dot_service] + '.' + [application_domain_name]`
+ // `| [instance_dot_version] + '.' + [application_domain_name]`
+ // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` + // + // * `application_domain_name` = The domain name of the app, for + // example .appspot.com, which is associated with the + // job's project ID. + // + // * `service =` [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // * `version =` [version][google.cloud.scheduler.v1.AppEngineRouting.version] + // + // * `version_dot_service =` + // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` + // [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // * `instance =` [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] + // + // * `instance_dot_service =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` + // [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // * `instance_dot_version =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` + // [version][google.cloud.scheduler.v1.AppEngineRouting.version] + // + // * `instance_dot_version_dot_service =` + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` + // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` + // [service][google.cloud.scheduler.v1.AppEngineRouting.service] + // + // + // If [service][google.cloud.scheduler.v1.AppEngineRouting.service] is empty, then the job will be sent + // to the service which is the default service when the job is attempted. + // + // If [version][google.cloud.scheduler.v1.AppEngineRouting.version] is empty, then the job will be sent + // to the version which is the default version when the job is attempted. + // + // If [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is empty, then the job will be + // sent to an instance which is available when the job is attempted. + // + // If [service][google.cloud.scheduler.v1.AppEngineRouting.service], + // [version][google.cloud.scheduler.v1.AppEngineRouting.version], or + // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is invalid, then the job will be sent + // to the default version of the default service when the job is attempted. + string host = 4; +} + +// The HTTP method used to execute the job. +enum HttpMethod { + // HTTP method unspecified. Defaults to POST. + HTTP_METHOD_UNSPECIFIED = 0; + + // HTTP POST + POST = 1; + + // HTTP GET + GET = 2; + + // HTTP HEAD + HEAD = 3; + + // HTTP PUT + PUT = 4; + + // HTTP DELETE + DELETE = 5; + + // HTTP PATCH + PATCH = 6; + + // HTTP OPTIONS + OPTIONS = 7; +} + +// Contains information needed for generating an +// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). +// This type of authorization should generally only be used when calling Google +// APIs hosted on *.googleapis.com. +message OAuthToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OAuth token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // OAuth scope to be used for generating OAuth access token. + // If not specified, "https://www.googleapis.com/auth/cloud-platform" + // will be used. + string scope = 2; +} + +// Contains information needed for generating an +// [OpenID Connect +// token](https://developers.google.com/identity/protocols/OpenIDConnect). +// This type of authorization can be used for many scenarios, including +// calling Cloud Run, or endpoints where you intend to validate the token +// yourself. +message OidcToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OIDC token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // Audience to be used when generating OIDC token. If not specified, the URI + // specified in target will be used. + string audience = 2; +} + +// The Pub/Sub Topic resource definition is in google/cloud/pubsub/v1/, +// but we do not import that proto directly; therefore, we redefine the +// pattern here. +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Topic" + pattern: "projects/{project}/topics/{topic}" +}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js new file mode 100644 index 00000000000..1e0a1f0ab3f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, job) { + // [START cloudscheduler_v1_generated_CloudScheduler_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 location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * Required. The job to add. The user can optionally specify a name for the + * job in name google.cloud.scheduler.v1.Job.name. name google.cloud.scheduler.v1.Job.name cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * (name google.cloud.scheduler.v1.Job.name) in the response. + */ + // const job = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + }; + + // Run request + const response = await schedulerClient.createJob(request); + console.log(response); + } + + callCreateJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js new file mode 100644 index 00000000000..d92b0f68a94 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1_generated_CloudScheduler_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. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callDeleteJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.deleteJob(request); + console.log(response); + } + + callDeleteJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js new file mode 100644 index 00000000000..69e1bd5a214 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1_generated_CloudScheduler_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. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js new file mode 100644 index 00000000000..b40f6e56edd --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START cloudscheduler_v1_generated_CloudScheduler_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. + */ + /** + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * Requested page size. + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * next_page_token google.cloud.scheduler.v1.ListJobsResponse.next_page_token returned from + * the previous call to ListJobs google.cloud.scheduler.v1.CloudScheduler.ListJobs. It is an error to + * switch the value of filter google.cloud.scheduler.v1.ListJobsRequest.filter or + * order_by google.cloud.scheduler.v1.ListJobsRequest.order_by while iterating through pages. + */ + // const pageToken = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callListJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await schedulerClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js new file mode 100644 index 00000000000..5632518f52c --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1_generated_CloudScheduler_PauseJob_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 job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callPauseJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.pauseJob(request); + console.log(response); + } + + callPauseJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_PauseJob_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-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js new file mode 100644 index 00000000000..a5c2c1682d5 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1_generated_CloudScheduler_ResumeJob_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 job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callResumeJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.resumeJob(request); + console.log(response); + } + + callResumeJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_ResumeJob_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-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js new file mode 100644 index 00000000000..65dc433434a --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1_generated_CloudScheduler_RunJob_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 job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callRunJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.runJob(request); + console.log(response); + } + + callRunJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_RunJob_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-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js new file mode 100644 index 00000000000..6c10cb2435e --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(job, updateMask) { + // [START cloudscheduler_v1_generated_CloudScheduler_UpdateJob_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 new job properties. name google.cloud.scheduler.v1.Job.name must be specified. + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + */ + // const job = {} + /** + * A mask used to specify which fields of the job are being updated. + */ + // const updateMask = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callUpdateJob() { + // Construct request + const request = { + job, + updateMask, + }; + + // Run request + const response = await schedulerClient.updateJob(request); + console.log(response); + } + + callUpdateJob(); + // [END cloudscheduler_v1_generated_CloudScheduler_UpdateJob_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-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json new file mode 100644 index 00000000000..08f67a411f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json @@ -0,0 +1,351 @@ +{ + "clientLibrary": { + "name": "nodejs-scheduler", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.scheduler.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ListJobs_async", + "title": "scheduler listJobs Sample", + "origin": "API_DEFINITION", + "description": " Lists jobs.", + "canonical": true, + "file": "cloud_scheduler.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.ListJobsResponse", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_GetJob_async", + "title": "scheduler getJob Sample", + "origin": "API_DEFINITION", + "description": " Gets a job.", + "canonical": true, + "file": "cloud_scheduler.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_CreateJob_async", + "title": "scheduler createJob Sample", + "origin": "API_DEFINITION", + "description": " Creates a job.", + "canonical": true, + "file": "cloud_scheduler.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.scheduler.v1.Job" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async", + "title": "scheduler updateJob Sample", + "origin": "API_DEFINITION", + "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", + "canonical": true, + "file": "cloud_scheduler.update_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", + "async": true, + "parameters": [ + { + "name": "job", + "type": ".google.cloud.scheduler.v1.Job" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async", + "title": "scheduler deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Deletes a job.", + "canonical": true, + "file": "cloud_scheduler.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_PauseJob_async", + "title": "scheduler pauseJob Sample", + "origin": "API_DEFINITION", + "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused.", + "canonical": true, + "file": "cloud_scheduler.pause_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async", + "title": "scheduler resumeJob Sample", + "origin": "API_DEFINITION", + "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed.", + "canonical": true, + "file": "cloud_scheduler.resume_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1_generated_CloudScheduler_RunJob_async", + "title": "scheduler runJob Sample", + "origin": "API_DEFINITION", + "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", + "canonical": true, + "file": "cloud_scheduler.run_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" + }, + "method": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1.CloudScheduler" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts new file mode 100644 index 00000000000..80a3740f221 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const CloudSchedulerClient = v1.CloudSchedulerClient; +type CloudSchedulerClient = v1.CloudSchedulerClient; +export {v1, CloudSchedulerClient}; +export default {v1, CloudSchedulerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts new file mode 100644 index 00000000000..0cf62985d23 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts @@ -0,0 +1,1189 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/cloud_scheduler_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_scheduler_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Cloud Scheduler API allows external entities to reliably + * schedule asynchronous jobs. + * @class + * @memberof v1 + */ +export class CloudSchedulerClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + cloudSchedulerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudSchedulerClient. + * + * @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 CloudSchedulerClient({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 CloudSchedulerClient; + 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; + } + + // 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}' + ), + }; + + // 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') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.scheduler.v1.CloudScheduler', 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.cloudSchedulerStub) { + return this.cloudSchedulerStub; + } + + // Put together the "service stub" for + // google.cloud.scheduler.v1.CloudScheduler. + this.cloudSchedulerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1.CloudScheduler') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.scheduler.v1.CloudScheduler, + 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 cloudSchedulerStubMethods = + ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; + for (const methodName of cloudSchedulerStubMethods) { + const callPromise = this.cloudSchedulerStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.cloudSchedulerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudscheduler.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 'cloudscheduler.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.get_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_GetJob_async + */ + getJob( + request?: protos.google.cloud.scheduler.v1.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.scheduler.v1.IGetJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.scheduler.v1.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.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); + } +/** + * Creates a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {google.cloud.scheduler.v1.Job} request.job + * Required. The job to add. The user can optionally specify a name for the + * job in {@link google.cloud.scheduler.v1.Job.name|name}. {@link google.cloud.scheduler.v1.Job.name|name} cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * ({@link google.cloud.scheduler.v1.Job.name|name}) in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.create_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_CreateJob_async + */ + createJob( + request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.scheduler.v1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.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); + } +/** + * Updates a job. + * + * If successful, the updated {@link google.cloud.scheduler.v1.Job|Job} is returned. If the job does + * not exist, `NOT_FOUND` is returned. + * + * If UpdateJob does not successfully return, it is possible for the + * job to be in an {@link google.cloud.scheduler.v1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} state. A job in this state may + * not be executed. If this happens, retry the UpdateJob request + * until a successful response is received. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.scheduler.v1.Job} request.job + * Required. The new job properties. {@link google.cloud.scheduler.v1.Job.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the job are being updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.update_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async + */ + updateJob( + request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined + ]>; + updateJob( + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IUpdateJobRequest|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({ + 'job.name': request.job!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateJob(request, options, callback); + } +/** + * Deletes a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @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 [Empty]{@link google.protobuf.Empty}. + * 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/cloud_scheduler.delete_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1.IDeleteJobRequest|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); + } +/** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via {@link google.cloud.scheduler.v1.CloudScheduler.ResumeJob|ResumeJob}. The + * state of the job is stored in {@link google.cloud.scheduler.v1.Job.state|state}; if paused it + * will be set to {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED} + * to be paused. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.pause_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_PauseJob_async + */ + pauseJob( + request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined + ]>; + pauseJob( + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request: protos.google.cloud.scheduler.v1.IPauseJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IPauseJobRequest|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.pauseJob(request, options, callback); + } +/** + * Resume a job. + * + * This method reenables a job after it has been {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. The + * state of a job is stored in {@link google.cloud.scheduler.v1.Job.state|Job.state}; after calling this method it + * will be set to {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in + * {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.resume_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async + */ + resumeJob( + request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined + ]>; + resumeJob( + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request: protos.google.cloud.scheduler.v1.IResumeJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IResumeJobRequest|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.resumeJob(request, options, callback); + } +/** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.run_job.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_RunJob_async + */ + runJob( + request?: protos.google.cloud.scheduler.v1.IRunJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined + ]>; + runJob( + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request: protos.google.cloud.scheduler.v1.IRunJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request?: protos.google.cloud.scheduler.v1.IRunJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob, + protos.google.cloud.scheduler.v1.IRunJobRequest|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.runJob(request, options, callback); + } + + /** + * Lists jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1.Job}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listJobs( + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1.IJob[], + protos.google.cloud.scheduler.v1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>): void; + listJobs( + request: protos.google.cloud.scheduler.v1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>): void; + listJobs( + request?: protos.google.cloud.scheduler.v1.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>, + callback?: PaginationCallback< + protos.google.cloud.scheduler.v1.IListJobsRequest, + protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1.IJob>): + Promise<[ + protos.google.cloud.scheduler.v1.IJob[], + protos.google.cloud.scheduler.v1.IListJobsRequest|null, + protos.google.cloud.scheduler.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 + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1.Job} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listJobsStream( + request?: protos.google.cloud.scheduler.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 + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from + * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to + * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Job]{@link google.cloud.scheduler.v1.Job}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/cloud_scheduler.list_jobs.js + * region_tag:cloudscheduler_v1_generated_CloudScheduler_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.scheduler.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; + } + // -------------------- + // -- 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; + } + + /** + * 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.cloudSchedulerStub && !this._terminated) { + return this.cloudSchedulerStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json new file mode 100644 index 00000000000..edb34789cd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.scheduler.v1.CloudScheduler": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListJobs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResumeJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RunJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json new file mode 100644 index 00000000000..2762a0163a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/scheduler/v1/cloudscheduler.proto", + "../../protos/google/cloud/scheduler/v1/job.proto", + "../../protos/google/cloud/scheduler/v1/target.proto" +] diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..122c43fbb24 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json @@ -0,0 +1,107 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.scheduler.v1", + "libraryPackage": "@google-cloud/scheduler", + "services": { + "CloudScheduler": { + "clients": { + "grpc": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts new file mode 100644 index 00000000000..d807e0c860d --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..c9d7fe466bc --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const scheduler = require('@google-cloud/scheduler'); + +function main() { + const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..9fce1cb1ef2 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {CloudSchedulerClient} from '@google-cloud/scheduler'; + +// check that the client class type name can be used +function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudSchedulerClient = new CloudSchedulerClient(); + doStuffWithCloudSchedulerClient(cloudSchedulerClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts b/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts new file mode 100644 index 00000000000..e92acb4e4f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts @@ -0,0 +1,1319 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as cloudschedulerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} 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 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.CloudSchedulerClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudschedulerModule.v1.CloudSchedulerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudschedulerModule.v1.CloudSchedulerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudschedulerModule.v1.CloudSchedulerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + await client.initialize(); + assert(client.cloudSchedulerStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudSchedulerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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('getJob', () => { + it('invokes getJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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('createJob', () => { + it('invokes createJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await 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 error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(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 closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('pauseJob', () => { + it('invokes pauseJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); + const [response] = await client.pauseJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseJob(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseJob(request), expectedError); + }); + }); + + describe('resumeJob', () => { + it('invokes resumeJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); + const [response] = await client.resumeJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeJob(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeJob(request), expectedError); + }); + }); + + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); + const [response] = await client.runJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob without error using callback', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runJob(request), expectedError); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with closed client', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runJob(request), expectedError); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.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.scheduler.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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.scheduler.v1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.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.scheduler.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('Path templates', () => { + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1.CloudSchedulerClient({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js new file mode 100644 index 00000000000..d4565464f20 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/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: 'scheduler', + filename: './scheduler.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-scheduler/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..08156a43898 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/scheduler', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md b/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md new file mode 100644 index 00000000000..90fa2a2d162 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md @@ -0,0 +1 @@ +Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/linkinator.config.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/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-scheduler/v1beta1/package.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json new file mode 100644 index 00000000000..312a11e17f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/scheduler", + "version": "0.1.0", + "description": "Scheduler client for Node.js", + "repository": "googleapis/nodejs-scheduler", + "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 scheduler", + "scheduler", + "cloud scheduler" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto new file mode 100644 index 00000000000..f9a2da03ff2 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto @@ -0,0 +1,315 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1beta1/job.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1;scheduler"; +option java_multiple_files = true; +option java_outer_classname = "SchedulerProto"; +option java_package = "com.google.cloud.scheduler.v1beta1"; +option objc_class_prefix = "SCHEDULER"; + +// The Cloud Scheduler API allows external entities to reliably +// schedule asynchronous jobs. +service CloudScheduler { + option (google.api.default_host) = "cloudscheduler.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists jobs. + rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/locations/*}/jobs" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a job. + rpc GetJob(GetJobRequest) returns (Job) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a job. + rpc CreateJob(CreateJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/jobs" + body: "job" + }; + option (google.api.method_signature) = "parent,job"; + } + + // Updates a job. + // + // If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is + // returned. If the job does not exist, `NOT_FOUND` is returned. + // + // If UpdateJob does not successfully return, it is possible for the + // job to be in an + // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] + // state. A job in this state may not be executed. If this happens, retry the + // UpdateJob request until a successful response is received. + rpc UpdateJob(UpdateJobRequest) returns (Job) { + option (google.api.http) = { + patch: "/v1beta1/{job.name=projects/*/locations/*/jobs/*}" + body: "job" + }; + option (google.api.method_signature) = "job,update_mask"; + } + + // Deletes a job. + rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/locations/*/jobs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses a job. + // + // If a job is paused then the system will stop executing the job + // until it is re-enabled via + // [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The + // state of the job is stored in + // [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set + // to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A + // job must be in + // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be + // paused. + rpc PauseJob(PauseJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resume a job. + // + // This method reenables a job after it has been + // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The + // state of a job is stored in + // [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this + // method it will be set to + // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A + // job must be in + // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be + // resumed. + rpc ResumeJob(ResumeJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Forces a job to run now. + // + // When this method is called, Cloud Scheduler will dispatch the job, even + // if the job is already running. + rpc RunJob(RunJobRequest) returns (Job) { + option (google.api.http) = { + post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:run" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. +message ListJobsRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // `filter` can be used to specify a subset of jobs. + // + // If `filter` equals `target_config="HttpConfig"`, then the http + // target jobs are retrieved. If `filter` equals + // `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + // retrieved. If `filter` equals `labels.foo=value1 + // labels.foo=value2` then only jobs which are labeled with + // foo=value1 AND foo=value2 will be returned. + string filter = 4; + + // Requested page size. + // + // The maximum page size is 500. If unspecified, the page size will + // be the maximum. Fewer jobs than requested might be returned, + // even if more jobs exist; use next_page_token to determine if more + // jobs exist. + int32 page_size = 5; + + // A token identifying a page of results the server will return. To + // request the first page results, page_token must be empty. To + // request the next page of results, page_token must be the value of + // [next_page_token][google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token] + // returned from the previous call to + // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. It is + // an error to switch the value of + // [filter][google.cloud.scheduler.v1beta1.ListJobsRequest.filter] or + // [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while + // iterating through pages. + string page_token = 6; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the jobs in the __cron + // queue will be listed instead. + bool legacy_app_engine_cron = 7; +} + +// Response message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. +message ListJobsResponse { + // The list of jobs. + repeated Job jobs = 1; + + // A token to retrieve next page of results. Pass this value in the + // [page_token][google.cloud.scheduler.v1beta1.ListJobsRequest.page_token] + // field in the subsequent call to + // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs] to + // retrieve the next page of results. If this is empty it indicates that there + // are no more results through which to paginate. + // + // The page token is valid for only 2 hours. + string next_page_token = 2; +} + +// Request message for +// [GetJob][google.cloud.scheduler.v1beta1.CloudScheduler.GetJob]. +message GetJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob]. +message CreateJobRequest { + // Required. The location name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // Required. The job to add. The user can optionally specify a name for the + // job in [name][google.cloud.scheduler.v1beta1.Job.name]. + // [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an + // existing job. If a name is not specified then the system will + // generate a random unique name that will be returned + // ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. + Job job = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. +message UpdateJobRequest { + // Required. The new job properties. + // [name][google.cloud.scheduler.v1beta1.Job.name] must be specified. + // + // Output only fields cannot be modified using UpdateJob. + // Any value specified for an output only field will be ignored. + Job job = 1 [(google.api.field_behavior) = REQUIRED]; + + // A mask used to specify which fields of the job are being updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for deleting a job using +// [DeleteJob][google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob]. +message DeleteJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the job in the __cron + // queue with the corresponding name will be deleted instead. + bool legacy_app_engine_cron = 2; +} + +// Request message for +// [PauseJob][google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob]. +message PauseJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for +// [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. +message ResumeJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; +} + +// Request message for forcing a job to run now using +// [RunJob][google.cloud.scheduler.v1beta1.CloudScheduler.RunJob]. +message RunJobRequest { + // Required. The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudscheduler.googleapis.com/Job" + } + ]; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the job in the __cron + // queue with the corresponding name will be forced to run instead. + bool legacy_app_engine_cron = 2; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto new file mode 100644 index 00000000000..2353beecac8 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto @@ -0,0 +1,268 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1beta1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/scheduler/v1beta1/target.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1;scheduler"; +option java_multiple_files = true; +option java_outer_classname = "JobProto"; +option java_package = "com.google.cloud.scheduler.v1beta1"; + +// Configuration for a job. +// The maximum allowed size for a job is 1MB. +message Job { + option (google.api.resource) = { + type: "cloudscheduler.googleapis.com/Job" + pattern: "projects/{project}/locations/{location}/jobs/{job}" + }; + + // State of the job. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The job is executing normally. + ENABLED = 1; + + // The job is paused by the user. It will not execute. A user can + // intentionally pause the job using + // [PauseJobRequest][google.cloud.scheduler.v1beta1.PauseJobRequest]. + PAUSED = 2; + + // The job is disabled by the system due to error. The user + // cannot directly set a job to be disabled. + DISABLED = 3; + + // The job state resulting from a failed + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] + // operation. To recover a job from this state, retry + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] + // until a successful response is received. + UPDATE_FAILED = 4; + } + + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after + // which it becomes output only. + // + // The job name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + // + // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), colons (:), or periods (.). + // For more information, see + // [Identifying + // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) + // * `LOCATION_ID` is the canonical ID for the job's location. + // The list of available locations can be obtained by calling + // [ListLocations][google.cloud.location.Locations.ListLocations]. + // For more information, see https://cloud.google.com/about/locations/. + // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), or underscores (_). The maximum length is 500 characters. + string name = 1; + + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or + // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. + // + // A human-readable description for the job. This string must not contain + // more than 500 characters. + string description = 2; + + // Required. + // + // Delivery settings containing destination and parameters. + oneof target { + // Pub/Sub target. + PubsubTarget pubsub_target = 4; + + // App Engine HTTP target. + AppEngineHttpTarget app_engine_http_target = 5; + + // HTTP target. + HttpTarget http_target = 6; + } + + // Required, except when used with + // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. + // + // Describes the schedule on which the job will be executed. + // + // The schedule can be either of the following types: + // + // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) + // * English-like + // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) + // + // As a general rule, execution `n + 1` of a job will not begin + // until execution `n` has finished. Cloud Scheduler will never + // allow two simultaneously outstanding executions. For example, + // this implies that if the `n+1`th execution is scheduled to run at + // 16:00 but the `n`th execution takes until 16:15, the `n+1`th + // execution will not start until `16:15`. + // A scheduled start time will be delayed if the previous + // execution has not ended when its scheduled time occurs. + // + // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] > + // 0 and a job attempt fails, the job will be tried a total of + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times, with exponential backoff, until the next scheduled start + // time. + string schedule = 20; + + // Specifies the time zone to be used in interpreting + // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this + // field must be a time zone name from the [tz + // database](http://en.wikipedia.org/wiki/Tz_database). + // + // Note that some time zones include a provision for + // daylight savings time. The rules for daylight saving time are + // determined by the chosen tz. For UTC use the string "utc". If a + // time zone is not specified, the default will be in UTC (also known + // as GMT). + string time_zone = 21; + + // Output only. The creation time of the job. + google.protobuf.Timestamp user_update_time = 9; + + // Output only. State of the job. + State state = 10; + + // Output only. The response from the target for the last attempted execution. + google.rpc.Status status = 11; + + // Output only. The next time the job is scheduled. Note that this may be a + // retry of a previously failed attempt or the next execution time + // according to the schedule. + google.protobuf.Timestamp schedule_time = 17; + + // Output only. The time the last job attempt started. + google.protobuf.Timestamp last_attempt_time = 18; + + // Settings that determine the retry behavior. + RetryConfig retry_config = 19; + + // The deadline for job attempts. If the request handler does not respond by + // this deadline then the request is cancelled and the attempt is marked as a + // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in + // execution logs. Cloud Scheduler will retry the job according + // to the [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. + // + // The default and the allowed values depend on the type of target: + // + // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], the + // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 + // minutes]. + // + // * For [App Engine HTTP + // targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], 0 + // indicates that the request has the default deadline. The default deadline + // depends on the scaling type of the service: 10 minutes for standard apps + // with automatic scaling, 24 hours for standard apps with manual and basic + // scaling, and 60 minutes for flex apps. If the request deadline is set, it + // must be in the interval [15 seconds, 24 hours 15 seconds]. + // + // * For [Pub/Sub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target], + // this field is ignored. + google.protobuf.Duration attempt_deadline = 22; + + // Immutable. This field is used to manage the legacy App Engine Cron jobs + // using the Cloud Scheduler API. If the field is set to true, the job will be + // considered a legacy job. Note that App Engine Cron jobs have fewer + // features than Cloud Scheduler jobs, e.g., are only limited to App Engine + // targets. + bool legacy_app_engine_cron = 23 [(google.api.field_behavior) = IMMUTABLE]; +} + +// Settings that determine the retry behavior. +// +// By default, if a job does not complete successfully (meaning that +// an acknowledgement is not received from the handler, then it will be retried +// with exponential backoff according to the settings in +// [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. +message RetryConfig { + // The number of attempts that the system will make to run a job using the + // exponential backoff procedure described by + // [max_doublings][google.cloud.scheduler.v1beta1.RetryConfig.max_doublings]. + // + // The default value of retry_count is zero. + // + // If retry_count is zero, a job attempt will *not* be retried if + // it fails. Instead the Cloud Scheduler system will wait for the + // next scheduled execution time. + // + // If retry_count is set to a non-zero number then Cloud Scheduler + // will retry failed attempts, using exponential backoff, + // retry_count times, or until the next scheduled execution time, + // whichever comes first. + // + // Values greater than 5 and negative values are not allowed. + int32 retry_count = 1; + + // The time limit for retrying a failed job, measured from time when an + // execution was first attempted. If specified with + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the + // job will be retried until both limits are reached. + // + // The default value for max_retry_duration is zero, which means retry + // duration is unlimited. + google.protobuf.Duration max_retry_duration = 2; + + // The minimum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 5 seconds. + google.protobuf.Duration min_backoff_duration = 3; + + // The maximum amount of time to wait before retrying a job after + // it fails. + // + // The default value of this field is 1 hour. + google.protobuf.Duration max_backoff_duration = 4; + + // The time between retries will double `max_doublings` times. + // + // A job's retry interval starts at + // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration], + // then doubles `max_doublings` times, then increases linearly, and finally + // retries at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // up to [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times. + // + // For example, if + // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration] + // is 10s, + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // is 300s, and `max_doublings` is 3, then the a job will first be retried in + // 10s. The retry interval will double three times, and then increase linearly + // by 2^3 * 10s. Finally, the job will retry at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // until the job has been attempted + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, + // 300s, 300s, .... + // + // The default value of this field is 5. + int32 max_doublings = 5; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto new file mode 100644 index 00000000000..f98f210dc40 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto @@ -0,0 +1,371 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.scheduler.v1beta1; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1;scheduler"; +option java_multiple_files = true; +option java_outer_classname = "TargetProto"; +option java_package = "com.google.cloud.scheduler.v1beta1"; +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Topic" + pattern: "projects/{project}/topics/{topic}" +}; + +// Http target. The job will be pushed to the job handler by means of +// an HTTP request via an +// [http_method][google.cloud.scheduler.v1beta1.HttpTarget.http_method] such as +// HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. A failure to receive a response +// constitutes a failed execution. For a redirected request, the response +// returned by the redirected request is considered. +message HttpTarget { + // Required. The full URI path that the request will be sent to. This string + // must begin with either "http://" or "https://". Some examples of + // valid values for [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri] are: + // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will + // encode some characters for safety and compatibility. The maximum allowed + // URL length is 2083 characters after encoding. + string uri = 1; + + // Which HTTP method to use for the request. + HttpMethod http_method = 2; + + // The user can specify HTTP request headers to send with the job's + // HTTP request. This map contains the header field names and + // values. Repeated headers are not supported, but a header value can + // contain commas. These headers represent a subset of the headers + // that will accompany the job's HTTP request. Some HTTP request + // headers will be ignored or replaced. A partial list of headers that + // will be ignored or replaced is below: + // - Host: This will be computed by Cloud Scheduler and derived from + // [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri]. + // * `Content-Length`: This will be computed by Cloud Scheduler. + // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. + // * `X-Google-*`: Google internal use only. + // * `X-AppEngine-*`: Google internal use only. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. + // + // The total size of headers must be less than 80KB. + map headers = 3; + + // HTTP request body. A request body is allowed only if the HTTP + // method is POST, PUT, or PATCH. It is an error to set body on a job with an + // incompatible [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. + bytes body = 4; + + // The mode for generating an `Authorization` header for HTTP requests. + // + // If specified, all `Authorization` headers in the + // [HttpTarget.headers][google.cloud.scheduler.v1beta1.HttpTarget.headers] + // field will be overridden. + oneof authorization_header { + // If specified, an + // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) + // will be generated and attached as an `Authorization` header in the HTTP + // request. + // + // This type of authorization should generally only be used when calling + // Google APIs hosted on *.googleapis.com. + OAuthToken oauth_token = 5; + + // If specified, an + // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) + // token will be generated and attached as an `Authorization` header in the + // HTTP request. + // + // This type of authorization can be used for many scenarios, including + // calling Cloud Run, or endpoints where you intend to validate the token + // yourself. + OidcToken oidc_token = 6; + } +} + +// App Engine target. The job will be pushed to a job handler by means +// of an HTTP request via an +// [http_method][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.http_method] +// such as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. Error 503 is considered an App Engine +// system error instead of an application error. Requests returning error 503 +// will be retried regardless of retry configuration and not counted against +// retry counts. Any other response code, or a failure to receive a response +// before the deadline, constitutes a failed attempt. +message AppEngineHttpTarget { + // The HTTP method to use for the request. PATCH and OPTIONS are not + // permitted. + HttpMethod http_method = 1; + + // App Engine Routing setting for the job. + AppEngineRouting app_engine_routing = 2; + + // The relative URI. + // + // The relative URL must begin with "/" and must be a valid HTTP relative URL. + // It can contain a path, query string arguments, and `#` fragments. + // If the relative URL is empty, then the root path "/" will be used. + // No spaces are allowed, and the maximum length allowed is 2083 characters. + string relative_uri = 3; + + // HTTP request headers. + // + // This map contains the header field names and values. Headers can be set + // when the job is created. + // + // Cloud Scheduler sets some headers to default values: + // + // * `User-Agent`: By default, this header is + // `"AppEngine-Google; (+http://code.google.com/appengine)"`. + // This header can be modified, but Cloud Scheduler will append + // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the + // modified `User-Agent`. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. + // + // If the job has an + // [body][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.body], Cloud + // Scheduler sets the following headers: + // + // * `Content-Type`: By default, the `Content-Type` header is set to + // `"application/octet-stream"`. The default can be overridden by explictly + // setting `Content-Type` to a particular media type when the job is + // created. + // For example, `Content-Type` can be set to `"application/json"`. + // * `Content-Length`: This is computed by Cloud Scheduler. This value is + // output only. It cannot be changed. + // + // The headers below are output only. They cannot be set or overridden: + // + // * `X-Google-*`: For Google internal use only. + // * `X-AppEngine-*`: For Google internal use only. + // + // In addition, some App Engine headers, which contain + // job-specific information, are also be sent to the job handler. + map headers = 4; + + // Body. + // + // HTTP request body. A request body is allowed only if the HTTP method is + // POST or PUT. It will result in invalid argument error to set a body on a + // job with an incompatible + // [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. + bytes body = 5; +} + +// Pub/Sub target. The job will be delivered by publishing a message to +// the given Pub/Sub topic. +message PubsubTarget { + // Required. The name of the Cloud Pub/Sub topic to which messages will + // be published when a job is delivered. The topic name must be in the + // same format as required by Pub/Sub's + // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), + // for example `projects/PROJECT_ID/topics/TOPIC_ID`. + // + // The topic must be in the same project as the Cloud Scheduler job. + string topic_name = 1 [ + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } + ]; + + // The message payload for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + bytes data = 3; + + // Attributes for PubsubMessage. + // + // Pubsub message must contain either non-empty data, or at least one + // attribute. + map attributes = 4; +} + +// App Engine Routing. +// +// For more information about services, versions, and instances see +// [An Overview of App +// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), +// [Microservices Architecture on Google App +// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), +// [App Engine Standard request +// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), +// and [App Engine Flex request +// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). +message AppEngineRouting { + // App service. + // + // By default, the job is sent to the service which is the default + // service when the job is attempted. + string service = 1; + + // App version. + // + // By default, the job is sent to the version which is the default + // version when the job is attempted. + string version = 2; + + // App instance. + // + // By default, the job is sent to an instance which is available when + // the job is attempted. + // + // Requests can only be sent to a specific instance if + // [manual scaling is used in App Engine + // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). + // App Engine Flex does not support instances. For more information, see + // [App Engine Standard request + // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) + // and [App Engine Flex request + // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). + string instance = 3; + + // Output only. The host that the job is sent to. + // + // For more information about how App Engine requests are routed, see + // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). + // + // The host is constructed as: + // + // + // * `host = [application_domain_name]`
+ // `| [service] + '.' + [application_domain_name]`
+ // `| [version] + '.' + [application_domain_name]`
+ // `| [version_dot_service]+ '.' + [application_domain_name]`
+ // `| [instance] + '.' + [application_domain_name]`
+ // `| [instance_dot_service] + '.' + [application_domain_name]`
+ // `| [instance_dot_version] + '.' + [application_domain_name]`
+ // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` + // + // * `application_domain_name` = The domain name of the app, for + // example .appspot.com, which is associated with the + // job's project ID. + // + // * `service =` + // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // * `version =` + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // + // * `version_dot_service =` + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' + // +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // * `instance =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] + // + // * `instance_dot_service =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // * `instance_dot_version =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // + // * `instance_dot_version_dot_service =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // `+ '.' +` + // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // + // + // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] is + // empty, then the job will be sent to the service which is the default + // service when the job is attempted. + // + // If [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] is + // empty, then the job will be sent to the version which is the default + // version when the job is attempted. + // + // If [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is + // empty, then the job will be sent to an instance which is available when the + // job is attempted. + // + // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service], + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version], or + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is + // invalid, then the job will be sent to the default version of the default + // service when the job is attempted. + string host = 4; +} + +// The HTTP method used to execute the job. +enum HttpMethod { + // HTTP method unspecified. Defaults to POST. + HTTP_METHOD_UNSPECIFIED = 0; + + // HTTP POST + POST = 1; + + // HTTP GET + GET = 2; + + // HTTP HEAD + HEAD = 3; + + // HTTP PUT + PUT = 4; + + // HTTP DELETE + DELETE = 5; + + // HTTP PATCH + PATCH = 6; + + // HTTP OPTIONS + OPTIONS = 7; +} + +// Contains information needed for generating an +// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). +// This type of authorization should generally only be used when calling Google +// APIs hosted on *.googleapis.com. +message OAuthToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OAuth token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // OAuth scope to be used for generating OAuth access token. + // If not specified, "https://www.googleapis.com/auth/cloud-platform" + // will be used. + string scope = 2; +} + +// Contains information needed for generating an +// [OpenID Connect +// token](https://developers.google.com/identity/protocols/OpenIDConnect). +// This type of authorization can be used for many scenarios, including +// calling Cloud Run, or endpoints where you intend to validate the token +// yourself. +message OidcToken { + // [Service account email](https://cloud.google.com/iam/docs/service-accounts) + // to be used for generating OIDC token. + // The service account must be within the same project as the job. The caller + // must have iam.serviceAccounts.actAs permission for the service account. + string service_account_email = 1; + + // Audience to be used when generating OIDC token. If not specified, the URI + // specified in target will be used. + string audience = 2; +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js new file mode 100644 index 00000000000..92de5253bd7 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, job) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_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 location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * Required. The job to add. The user can optionally specify a name for the + * job in name google.cloud.scheduler.v1beta1.Job.name. + * name google.cloud.scheduler.v1beta1.Job.name cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * (name google.cloud.scheduler.v1beta1.Job.name) in the response. + */ + // const job = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callCreateJob() { + // Construct request + const request = { + parent, + job, + }; + + // Run request + const response = await schedulerClient.createJob(request); + console.log(response); + } + + callCreateJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js new file mode 100644 index 00000000000..b2d7fd2a8ad --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_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. + */ + /** + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be deleted instead. + */ + // const legacyAppEngineCron = true + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callDeleteJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.deleteJob(request); + console.log(response); + } + + callDeleteJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js new file mode 100644 index 00000000000..d22f591b519 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_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. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callGetJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.getJob(request); + console.log(response); + } + + callGetJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js new file mode 100644 index 00000000000..7ae9366e802 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js @@ -0,0 +1,101 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_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. + */ + /** + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + */ + // const parent = 'abc123' + /** + * `filter` can be used to specify a subset of jobs. + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + */ + // const filter = 'abc123' + /** + * Requested page size. + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * next_page_token google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token + * returned from the previous call to + * ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is + * an error to switch the value of + * filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter or + * order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by while + * iterating through pages. + */ + // const pageToken = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + */ + // const legacyAppEngineCron = true + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callListJobs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await schedulerClient.listJobsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListJobs(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js new file mode 100644 index 00000000000..762bf00520b --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_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 job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callPauseJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.pauseJob(request); + console.log(response); + } + + callPauseJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js new file mode 100644 index 00000000000..c27c161c969 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_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 job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callResumeJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.resumeJob(request); + console.log(response); + } + + callResumeJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js new file mode 100644 index 00000000000..52f869a91e7 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_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 job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + */ + // const name = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be forced to run instead. + */ + // const legacyAppEngineCron = true + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callRunJob() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await schedulerClient.runJob(request); + console.log(response); + } + + callRunJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js new file mode 100644 index 00000000000..ed9680f11c9 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(job) { + // [START cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_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 new job properties. + * name google.cloud.scheduler.v1beta1.Job.name must be specified. + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + */ + // const job = {} + /** + * A mask used to specify which fields of the job are being updated. + */ + // const updateMask = {} + + // Imports the Scheduler library + const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; + + // Instantiates a client + const schedulerClient = new CloudSchedulerClient(); + + async function callUpdateJob() { + // Construct request + const request = { + job, + }; + + // Run request + const response = await schedulerClient.updateJob(request); + console.log(response); + } + + callUpdateJob(); + // [END cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_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-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json new file mode 100644 index 00000000000..19c756a7cd0 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json @@ -0,0 +1,367 @@ +{ + "clientLibrary": { + "name": "nodejs-scheduler", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.scheduler.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async", + "title": "scheduler listJobs Sample", + "origin": "API_DEFINITION", + "description": " Lists jobs.", + "canonical": true, + "file": "cloud_scheduler.list_jobs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.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" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.ListJobsResponse", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async", + "title": "scheduler getJob Sample", + "origin": "API_DEFINITION", + "description": " Gets a job.", + "canonical": true, + "file": "cloud_scheduler.get_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "GetJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async", + "title": "scheduler createJob Sample", + "origin": "API_DEFINITION", + "description": " Creates a job.", + "canonical": true, + "file": "cloud_scheduler.create_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "job", + "type": ".google.cloud.scheduler.v1beta1.Job" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "CreateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async", + "title": "scheduler updateJob Sample", + "origin": "API_DEFINITION", + "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", + "canonical": true, + "file": "cloud_scheduler.update_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", + "async": true, + "parameters": [ + { + "name": "job", + "type": ".google.cloud.scheduler.v1beta1.Job" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "UpdateJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async", + "title": "scheduler deleteJob Sample", + "origin": "API_DEFINITION", + "description": " Deletes a job.", + "canonical": true, + "file": "cloud_scheduler.delete_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async", + "title": "scheduler pauseJob Sample", + "origin": "API_DEFINITION", + "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.", + "canonical": true, + "file": "cloud_scheduler.pause_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "PauseJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async", + "title": "scheduler resumeJob Sample", + "origin": "API_DEFINITION", + "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.", + "canonical": true, + "file": "cloud_scheduler.resume_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "ResumeJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + }, + { + "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async", + "title": "scheduler runJob Sample", + "origin": "API_DEFINITION", + "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", + "canonical": true, + "file": "cloud_scheduler.run_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.scheduler.v1beta1.Job", + "client": { + "shortName": "CloudSchedulerClient", + "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" + }, + "method": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts new file mode 100644 index 00000000000..5137a469f2d --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const CloudSchedulerClient = v1beta1.CloudSchedulerClient; +type CloudSchedulerClient = v1beta1.CloudSchedulerClient; +export {v1beta1, CloudSchedulerClient}; +export default {v1beta1, CloudSchedulerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts new file mode 100644 index 00000000000..e6ffe25f901 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts @@ -0,0 +1,1344 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, 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/v1beta1/cloud_scheduler_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_scheduler_client_config.json'; +const version = require('../../../package.json').version; + +/** + * The Cloud Scheduler API allows external entities to reliably + * schedule asynchronous jobs. + * @class + * @memberof v1beta1 + */ +export class CloudSchedulerClient { + 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}; + cloudSchedulerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudSchedulerClient. + * + * @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 CloudSchedulerClient({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 CloudSchedulerClient; + 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}' + ), + }; + + // 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') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.scheduler.v1beta1.CloudScheduler', 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.cloudSchedulerStub) { + return this.cloudSchedulerStub; + } + + // Put together the "service stub" for + // google.cloud.scheduler.v1beta1.CloudScheduler. + this.cloudSchedulerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1beta1.CloudScheduler') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.scheduler.v1beta1.CloudScheduler, + 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 cloudSchedulerStubMethods = + ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; + for (const methodName of cloudSchedulerStubMethods) { + const callPromise = this.cloudSchedulerStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.cloudSchedulerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudscheduler.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 'cloudscheduler.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.get_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async + */ + getJob( + request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined + ]>; + getJob( + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>): void; + getJob( + request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.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); + } +/** + * Creates a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {google.cloud.scheduler.v1beta1.Job} request.job + * Required. The job to add. The user can optionally specify a name for the + * job in {@link google.cloud.scheduler.v1beta1.Job.name|name}. + * {@link google.cloud.scheduler.v1beta1.Job.name|name} cannot be the same as an + * existing job. If a name is not specified then the system will + * generate a random unique name that will be returned + * ({@link google.cloud.scheduler.v1beta1.Job.name|name}) in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.create_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async + */ + createJob( + request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined + ]>; + createJob( + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>): void; + createJob( + request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.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); + } +/** + * Updates a job. + * + * If successful, the updated {@link google.cloud.scheduler.v1beta1.Job|Job} is + * returned. If the job does not exist, `NOT_FOUND` is returned. + * + * If UpdateJob does not successfully return, it is possible for the + * job to be in an + * {@link google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} + * state. A job in this state may not be executed. If this happens, retry the + * UpdateJob request until a successful response is received. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.scheduler.v1beta1.Job} request.job + * Required. The new job properties. + * {@link google.cloud.scheduler.v1beta1.Job.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateJob. + * Any value specified for an output only field will be ignored. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the job are being updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.update_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async + */ + updateJob( + request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined + ]>; + updateJob( + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): void; + updateJob( + request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|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({ + 'job.name': request.job!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateJob(request, options, callback); + } +/** + * Deletes a job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be deleted instead. + * @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 [Empty]{@link google.protobuf.Empty}. + * 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/v1beta1/cloud_scheduler.delete_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async + */ + deleteJob( + request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined + ]>; + deleteJob( + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): void; + deleteJob( + request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|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); + } +/** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The + * state of the job is stored in + * {@link google.cloud.scheduler.v1beta1.Job.state|state}; if paused it will be set + * to {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A + * job must be in + * {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} to be + * paused. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.pause_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async + */ + pauseJob( + request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined + ]>; + pauseJob( + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>): void; + pauseJob( + request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|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.pauseJob(request, options, callback); + } +/** + * Resume a job. + * + * This method reenables a job after it has been + * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The + * state of a job is stored in + * {@link google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this + * method it will be set to + * {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A + * job must be in + * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be + * resumed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.resume_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async + */ + resumeJob( + request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined + ]>; + resumeJob( + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>): void; + resumeJob( + request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|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.resumeJob(request, options, callback); + } +/** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The job name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be forced to run instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.run_job.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async + */ + runJob( + request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined + ]>; + runJob( + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + callback: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>): void; + runJob( + request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob, + protos.google.cloud.scheduler.v1beta1.IRunJobRequest|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.runJob(request, options, callback); + } + + /** + * Lists jobs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.IListJobsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob[], + protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse + ]>; + listJobs( + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>): void; + listJobs( + request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>): void; + listJobs( + request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>, + callback?: PaginationCallback< + protos.google.cloud.scheduler.v1beta1.IListJobsRequest, + protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, + protos.google.cloud.scheduler.v1beta1.IJob>): + Promise<[ + protos.google.cloud.scheduler.v1beta1.IJob[], + protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, + protos.google.cloud.scheduler.v1beta1.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 + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.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 + * Required. The location name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 500. If unspecified, the page size will + * be the maximum. Fewer jobs than requested might be returned, + * even if more jobs exist; use next_page_token to determine if more + * jobs exist. + * @param {string} request.pageToken + * A token identifying a page of results the server will return. To + * request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.list_jobs.js + * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async + */ + listJobsAsync( + request?: protos.google.cloud.scheduler.v1beta1.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; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + // -------------------- + // -- 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; + } + + /** + * 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.cloudSchedulerStub && !this._terminated) { + return this.cloudSchedulerStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json new file mode 100644 index 00000000000..6ded8ffff11 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.scheduler.v1beta1.CloudScheduler": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListJobs": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ResumeJob": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunJob": { + "timeout_millis": 600000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json new file mode 100644 index 00000000000..a911aaeb80f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto", + "../../protos/google/cloud/scheduler/v1beta1/job.proto", + "../../protos/google/cloud/scheduler/v1beta1/target.proto" +] diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..c097889cd1f --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,107 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.scheduler.v1beta1", + "libraryPackage": "@google-cloud/scheduler", + "services": { + "CloudScheduler": { + "clients": { + "grpc": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudSchedulerClient", + "rpcs": { + "GetJob": { + "methods": [ + "getJob" + ] + }, + "CreateJob": { + "methods": [ + "createJob" + ] + }, + "UpdateJob": { + "methods": [ + "updateJob" + ] + }, + "DeleteJob": { + "methods": [ + "deleteJob" + ] + }, + "PauseJob": { + "methods": [ + "pauseJob" + ] + }, + "ResumeJob": { + "methods": [ + "resumeJob" + ] + }, + "RunJob": { + "methods": [ + "runJob" + ] + }, + "ListJobs": { + "methods": [ + "listJobs", + "listJobsStream", + "listJobsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..d807e0c860d --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..c9d7fe466bc --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const scheduler = require('@google-cloud/scheduler'); + +function main() { + const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..9fce1cb1ef2 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {CloudSchedulerClient} from '@google-cloud/scheduler'; + +// check that the client class type name can be used +function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudSchedulerClient = new CloudSchedulerClient(); + doStuffWithCloudSchedulerClient(cloudSchedulerClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts new file mode 100644 index 00000000000..8f4b686d1dd --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts @@ -0,0 +1,1485 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as cloudschedulerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, 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 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('v1beta1.CloudSchedulerClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudschedulerModule.v1beta1.CloudSchedulerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudschedulerModule.v1beta1.CloudSchedulerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudschedulerModule.v1beta1.CloudSchedulerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + await client.initialize(); + assert(client.cloudSchedulerStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudSchedulerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudSchedulerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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('getJob', () => { + it('invokes getJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.GetJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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('createJob', () => { + it('invokes createJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() + ); + request.job ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); + request.job.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await 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 error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(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 closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('pauseJob', () => { + it('invokes pauseJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); + const [response] = await client.pauseJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseJob(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseJob(request), expectedError); + }); + }); + + describe('resumeJob', () => { + it('invokes resumeJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); + const [response] = await client.resumeJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeJob(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeJob(request), expectedError); + }); + }); + + describe('runJob', () => { + it('invokes runJob without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); + const [response] = await client.runJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob without error using callback', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.Job() + ); + client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runJob( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runJob(request), expectedError); + const actualRequest = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runJob with closed client', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.RunJobRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runJob(request), expectedError); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.Job[] = []; + stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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('Path templates', () => { + + describe('job', () => { + const fakePath = "/rendered/path/job"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + job: "jobValue", + }; + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/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-scheduler/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js new file mode 100644 index 00000000000..d4565464f20 --- /dev/null +++ b/owl-bot-staging/google-cloud-scheduler/v1beta1/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: 'scheduler', + filename: './scheduler.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 75b3321ceaa8d81c2dad1f465ab7c02ea9310176 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 13 Dec 2022 22:51:27 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google-cloud-scheduler/v1/.eslintignore | 7 - .../google-cloud-scheduler/v1/.eslintrc.json | 3 - .../google-cloud-scheduler/v1/.gitignore | 14 - .../google-cloud-scheduler/v1/.jsdoc.js | 55 - .../google-cloud-scheduler/v1/.mocharc.js | 33 - .../google-cloud-scheduler/v1/.prettierrc.js | 22 - .../google-cloud-scheduler/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../google-cloud-scheduler/v1/package.json | 64 - .../cloud/scheduler/v1/cloudscheduler.proto | 268 --- .../google/cloud/scheduler/v1/job.proto | 236 --- .../google/cloud/scheduler/v1/target.proto | 355 ---- .../v1/cloud_scheduler.create_job.js | 71 - .../v1/cloud_scheduler.delete_job.js | 62 - .../generated/v1/cloud_scheduler.get_job.js | 62 - .../generated/v1/cloud_scheduler.list_jobs.js | 82 - .../generated/v1/cloud_scheduler.pause_job.js | 62 - .../v1/cloud_scheduler.resume_job.js | 62 - .../generated/v1/cloud_scheduler.run_job.js | 62 - .../v1/cloud_scheduler.update_job.js | 68 - ...et_metadata.google.cloud.scheduler.v1.json | 351 ---- .../google-cloud-scheduler/v1/src/index.ts | 25 - .../v1/src/v1/cloud_scheduler_client.ts | 1189 ------------- .../src/v1/cloud_scheduler_client_config.json | 66 - .../v1/src/v1/cloud_scheduler_proto_list.json | 5 - .../v1/src/v1/gapic_metadata.json | 107 -- .../google-cloud-scheduler/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_cloud_scheduler_v1.ts | 1319 --------------- .../google-cloud-scheduler/v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../google-cloud-scheduler/v1beta1/.gitignore | 14 - .../google-cloud-scheduler/v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../google-cloud-scheduler/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 16 - .../v1beta1/package.json | 64 - .../scheduler/v1beta1/cloudscheduler.proto | 315 ---- .../google/cloud/scheduler/v1beta1/job.proto | 268 --- .../cloud/scheduler/v1beta1/target.proto | 371 ---- .../v1beta1/cloud_scheduler.create_job.js | 72 - .../v1beta1/cloud_scheduler.delete_job.js | 68 - .../v1beta1/cloud_scheduler.get_job.js | 62 - .../v1beta1/cloud_scheduler.list_jobs.js | 101 -- .../v1beta1/cloud_scheduler.pause_job.js | 62 - .../v1beta1/cloud_scheduler.resume_job.js | 62 - .../v1beta1/cloud_scheduler.run_job.js | 68 - .../v1beta1/cloud_scheduler.update_job.js | 68 - ...tadata.google.cloud.scheduler.v1beta1.json | 367 ---- .../v1beta1/src/index.ts | 25 - .../src/v1beta1/cloud_scheduler_client.ts | 1344 --------------- .../cloud_scheduler_client_config.json | 66 - .../v1beta1/cloud_scheduler_proto_list.json | 5 - .../v1beta1/src/v1beta1/gapic_metadata.json | 107 -- .../v1beta1/src/v1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../test/gapic_cloud_scheduler_v1beta1.ts | 1485 ----------------- .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../scheduler/v1beta1/cloudscheduler.proto | 114 +- .../google/cloud/scheduler/v1beta1/job.proto | 100 +- .../cloud/scheduler/v1beta1/target.proto | 112 +- .../google-cloud-scheduler/protos/protos.d.ts | 30 + .../google-cloud-scheduler/protos/protos.js | 121 +- .../google-cloud-scheduler/protos/protos.json | 23 + .../v1beta1/cloud_scheduler.create_job.js | 3 +- .../v1beta1/cloud_scheduler.delete_job.js | 6 + .../v1beta1/cloud_scheduler.list_jobs.js | 27 +- .../v1beta1/cloud_scheduler.run_job.js | 6 + .../v1beta1/cloud_scheduler.update_job.js | 3 +- ...tadata.google.cloud.scheduler.v1beta1.json | 26 +- .../src/v1/cloud_scheduler_client.ts | 3 + .../src/v1beta1/cloud_scheduler_client.ts | 213 ++- .../test/gapic_cloud_scheduler_v1beta1.ts | 200 ++- 81 files changed, 830 insertions(+), 10375 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js deleted file mode 100644 index 08156a43898..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/scheduler', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/README.md b/owl-bot-staging/google-cloud-scheduler/v1/README.md deleted file mode 100644 index 90fa2a2d162..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1/linkinator.config.json b/owl-bot-staging/google-cloud-scheduler/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/package.json b/owl-bot-staging/google-cloud-scheduler/v1/package.json deleted file mode 100644 index 312a11e17f5..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/scheduler", - "version": "0.1.0", - "description": "Scheduler client for Node.js", - "repository": "googleapis/nodejs-scheduler", - "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 scheduler", - "scheduler", - "cloud scheduler" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto deleted file mode 100644 index 89ce8cbd338..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/cloudscheduler.proto +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.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.scheduler.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/scheduler/v1/job.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1;scheduler"; -option java_multiple_files = true; -option java_outer_classname = "SchedulerProto"; -option java_package = "com.google.cloud.scheduler.v1"; -option objc_class_prefix = "SCHEDULER"; - -// The Cloud Scheduler API allows external entities to reliably -// schedule asynchronous jobs. -service CloudScheduler { - option (google.api.default_host) = "cloudscheduler.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Lists jobs. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a job. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates 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"; - } - - // Updates a job. - // - // If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does - // not exist, `NOT_FOUND` is returned. - // - // If UpdateJob does not successfully return, it is possible for the - // job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in this state may - // not be executed. If this happens, retry the UpdateJob request - // until a successful response is received. - rpc UpdateJob(UpdateJobRequest) returns (Job) { - option (google.api.http) = { - patch: "/v1/{job.name=projects/*/locations/*/jobs/*}" - body: "job" - }; - option (google.api.method_signature) = "job,update_mask"; - } - - // Deletes a job. - rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses a job. - // - // If a job is paused then the system will stop executing the job - // until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The - // state of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if paused it - // will be set to [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] - // to be paused. - rpc PauseJob(PauseJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/jobs/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resume a job. - // - // This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The - // state of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it - // will be set to [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in - // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed. - rpc ResumeJob(ResumeJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/jobs/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Forces a job to run now. - // - // When this method is called, Cloud Scheduler will dispatch the job, even - // if the job is already running. - rpc RunJob(RunJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/jobs/*}:run" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// Request message for listing jobs using [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. -message ListJobsRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // Requested page size. - // - // The maximum page size is 500. If unspecified, the page size will - // be the maximum. Fewer jobs than requested might be returned, - // even if more jobs exist; use next_page_token to determine if more - // jobs exist. - int32 page_size = 5; - - // A token identifying a page of results the server will return. To - // request the first page results, page_token must be empty. To - // request the next page of results, page_token must be the value of - // [next_page_token][google.cloud.scheduler.v1.ListJobsResponse.next_page_token] returned from - // the previous call to [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. It is an error to - // switch the value of [filter][google.cloud.scheduler.v1.ListJobsRequest.filter] or - // [order_by][google.cloud.scheduler.v1.ListJobsRequest.order_by] while iterating through pages. - string page_token = 6; -} - -// Response message for listing jobs using [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. -message ListJobsResponse { - // The list of jobs. - repeated Job jobs = 1; - - // A token to retrieve next page of results. Pass this value in the - // [page_token][google.cloud.scheduler.v1.ListJobsRequest.page_token] field in the subsequent call to - // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs] to retrieve the next page of results. - // If this is empty it indicates that there are no more results - // through which to paginate. - // - // The page token is valid for only 2 hours. - string next_page_token = 2; -} - -// Request message for [GetJob][google.cloud.scheduler.v1.CloudScheduler.GetJob]. -message GetJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob]. -message CreateJobRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // Required. The job to add. The user can optionally specify a name for the - // job in [name][google.cloud.scheduler.v1.Job.name]. [name][google.cloud.scheduler.v1.Job.name] cannot be the same as an - // existing job. If a name is not specified then the system will - // generate a random unique name that will be returned - // ([name][google.cloud.scheduler.v1.Job.name]) in the response. - Job job = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. -message UpdateJobRequest { - // Required. The new job properties. [name][google.cloud.scheduler.v1.Job.name] must be specified. - // - // Output only fields cannot be modified using UpdateJob. - // Any value specified for an output only field will be ignored. - Job job = 1 [(google.api.field_behavior) = REQUIRED]; - - // A mask used to specify which fields of the job are being updated. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for deleting a job using -// [DeleteJob][google.cloud.scheduler.v1.CloudScheduler.DeleteJob]. -message DeleteJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for [PauseJob][google.cloud.scheduler.v1.CloudScheduler.PauseJob]. -message PauseJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. -message ResumeJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for forcing a job to run now using -// [RunJob][google.cloud.scheduler.v1.CloudScheduler.RunJob]. -message RunJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto deleted file mode 100644 index 7e43ff1647f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/job.proto +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.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.scheduler.v1; - -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1/target.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1;scheduler"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.scheduler.v1"; - -// Configuration for a job. -// The maximum allowed size for a job is 100KB. -message Job { - option (google.api.resource) = { - type: "cloudscheduler.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - }; - - // State of the job. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The job is executing normally. - ENABLED = 1; - - // The job is paused by the user. It will not execute. A user can - // intentionally pause the job using - // [PauseJobRequest][google.cloud.scheduler.v1.PauseJobRequest]. - PAUSED = 2; - - // The job is disabled by the system due to error. The user - // cannot directly set a job to be disabled. - DISABLED = 3; - - // The job state resulting from a failed [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] - // operation. To recover a job from this state, retry - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob] until a successful response is received. - UPDATE_FAILED = 4; - } - - // Optionally caller-specified in [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob], after - // which it becomes output only. - // - // The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - // - // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), colons (:), or periods (.). - // For more information, see - // [Identifying - // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) - // * `LOCATION_ID` is the canonical ID for the job's location. - // The list of available locations can be obtained by calling - // [ListLocations][google.cloud.location.Locations.ListLocations]. - // For more information, see https://cloud.google.com/about/locations/. - // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), or underscores (_). The maximum length is 500 characters. - string name = 1; - - // Optionally caller-specified in [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob] or - // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. - // - // A human-readable description for the job. This string must not contain - // more than 500 characters. - string description = 2; - - // Required. - // - // Delivery settings containing destination and parameters. - oneof target { - // Pub/Sub target. - PubsubTarget pubsub_target = 4; - - // App Engine HTTP target. - AppEngineHttpTarget app_engine_http_target = 5; - - // HTTP target. - HttpTarget http_target = 6; - } - - // Required, except when used with [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. - // - // Describes the schedule on which the job will be executed. - // - // The schedule can be either of the following types: - // - // * [Crontab](http://en.wikipedia.org/wiki/Cron#Overview) - // * English-like - // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) - // - // As a general rule, execution `n + 1` of a job will not begin - // until execution `n` has finished. Cloud Scheduler will never - // allow two simultaneously outstanding executions. For example, - // this implies that if the `n+1`th execution is scheduled to run at - // 16:00 but the `n`th execution takes until 16:15, the `n+1`th - // execution will not start until `16:15`. - // A scheduled start time will be delayed if the previous - // execution has not ended when its scheduled time occurs. - // - // If [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] > 0 and a job attempt fails, - // the job will be tried a total of [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] - // times, with exponential backoff, until the next scheduled start - // time. - string schedule = 20; - - // Specifies the time zone to be used in interpreting - // [schedule][google.cloud.scheduler.v1.Job.schedule]. The value of this field must be a time - // zone name from the [tz database](http://en.wikipedia.org/wiki/Tz_database). - // - // Note that some time zones include a provision for - // daylight savings time. The rules for daylight saving time are - // determined by the chosen tz. For UTC use the string "utc". If a - // time zone is not specified, the default will be in UTC (also known - // as GMT). - string time_zone = 21; - - // Output only. The creation time of the job. - google.protobuf.Timestamp user_update_time = 9; - - // Output only. State of the job. - State state = 10; - - // Output only. The response from the target for the last attempted execution. - google.rpc.Status status = 11; - - // Output only. The next time the job is scheduled. Note that this may be a - // retry of a previously failed attempt or the next execution time - // according to the schedule. - google.protobuf.Timestamp schedule_time = 17; - - // Output only. The time the last job attempt started. - google.protobuf.Timestamp last_attempt_time = 18; - - // Settings that determine the retry behavior. - RetryConfig retry_config = 19; - - // The deadline for job attempts. If the request handler does not respond by - // this deadline then the request is cancelled and the attempt is marked as a - // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in - // execution logs. Cloud Scheduler will retry the job according - // to the [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. - // - // The allowed duration for this deadline is: - // * For [HTTP targets][google.cloud.scheduler.v1.Job.http_target], between 15 seconds and 30 minutes. - // * For [App Engine HTTP targets][google.cloud.scheduler.v1.Job.app_engine_http_target], between 15 - // seconds and 24 hours. - google.protobuf.Duration attempt_deadline = 22; -} - -// Settings that determine the retry behavior. -// -// By default, if a job does not complete successfully (meaning that -// an acknowledgement is not received from the handler, then it will be retried -// with exponential backoff according to the settings in [RetryConfig][google.cloud.scheduler.v1.RetryConfig]. -message RetryConfig { - // The number of attempts that the system will make to run a job using the - // exponential backoff procedure described by - // [max_doublings][google.cloud.scheduler.v1.RetryConfig.max_doublings]. - // - // The default value of retry_count is zero. - // - // If retry_count is zero, a job attempt will *not* be retried if - // it fails. Instead the Cloud Scheduler system will wait for the - // next scheduled execution time. - // - // If retry_count is set to a non-zero number then Cloud Scheduler - // will retry failed attempts, using exponential backoff, - // retry_count times, or until the next scheduled execution time, - // whichever comes first. - // - // Values greater than 5 and negative values are not allowed. - int32 retry_count = 1; - - // The time limit for retrying a failed job, measured from time when an - // execution was first attempted. If specified with - // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count], the job will be retried until both - // limits are reached. - // - // The default value for max_retry_duration is zero, which means retry - // duration is unlimited. - google.protobuf.Duration max_retry_duration = 2; - - // The minimum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 5 seconds. - google.protobuf.Duration min_backoff_duration = 3; - - // The maximum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 1 hour. - google.protobuf.Duration max_backoff_duration = 4; - - // The time between retries will double `max_doublings` times. - // - // A job's retry interval starts at - // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration], then doubles - // `max_doublings` times, then increases linearly, and finally - // retries retries at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] up to - // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times. - // - // For example, if [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration] is - // 10s, [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] is 300s, and - // `max_doublings` is 3, then the a job will first be retried in 10s. The - // retry interval will double three times, and then increase linearly by - // 2^3 * 10s. Finally, the job will retry at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration] until the job has - // been attempted [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times. Thus, the - // requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, .... - // - // The default value of this field is 5. - int32 max_doublings = 5; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto deleted file mode 100644 index 07466ce9765..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/protos/google/cloud/scheduler/v1/target.proto +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.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.scheduler.v1; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1;scheduler"; -option java_multiple_files = true; -option java_outer_classname = "TargetProto"; -option java_package = "com.google.cloud.scheduler.v1"; - -// Http target. The job will be pushed to the job handler by means of -// an HTTP request via an [http_method][google.cloud.scheduler.v1.HttpTarget.http_method] such as HTTP -// POST, HTTP GET, etc. The job is acknowledged by means of an HTTP -// response code in the range [200 - 299]. A failure to receive a response -// constitutes a failed execution. For a redirected request, the response -// returned by the redirected request is considered. -message HttpTarget { - // Required. The full URI path that the request will be sent to. This string - // must begin with either "http://" or "https://". Some examples of - // valid values for [uri][google.cloud.scheduler.v1.HttpTarget.uri] are: - // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will - // encode some characters for safety and compatibility. The maximum allowed - // URL length is 2083 characters after encoding. - string uri = 1; - - // Which HTTP method to use for the request. - HttpMethod http_method = 2; - - // The user can specify HTTP request headers to send with the job's - // HTTP request. This map contains the header field names and - // values. Repeated headers are not supported, but a header value can - // contain commas. These headers represent a subset of the headers - // that will accompany the job's HTTP request. Some HTTP request - // headers will be ignored or replaced. A partial list of headers that - // will be ignored or replaced is below: - // - Host: This will be computed by Cloud Scheduler and derived from - // [uri][google.cloud.scheduler.v1.HttpTarget.uri]. - // * `Content-Length`: This will be computed by Cloud Scheduler. - // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. - // * `X-Google-*`: Google internal use only. - // * `X-AppEngine-*`: Google internal use only. - // - // The total size of headers must be less than 80KB. - map headers = 3; - - // HTTP request body. A request body is allowed only if the HTTP - // method is POST, PUT, or PATCH. It is an error to set body on a job with an - // incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. - bytes body = 4; - - // The mode for generating an `Authorization` header for HTTP requests. - // - // If specified, all `Authorization` headers in the [HttpTarget.headers][google.cloud.scheduler.v1.HttpTarget.headers] - // field will be overridden. - oneof authorization_header { - // If specified, an - // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) - // will be generated and attached as an `Authorization` header in the HTTP - // request. - // - // This type of authorization should generally only be used when calling - // Google APIs hosted on *.googleapis.com. - OAuthToken oauth_token = 5; - - // If specified, an - // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) - // token will be generated and attached as an `Authorization` header in the - // HTTP request. - // - // This type of authorization can be used for many scenarios, including - // calling Cloud Run, or endpoints where you intend to validate the token - // yourself. - OidcToken oidc_token = 6; - } -} - -// App Engine target. The job will be pushed to a job handler by means -// of an HTTP request via an [http_method][google.cloud.scheduler.v1.AppEngineHttpTarget.http_method] such -// as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an -// HTTP response code in the range [200 - 299]. Error 503 is -// considered an App Engine system error instead of an application -// error. Requests returning error 503 will be retried regardless of -// retry configuration and not counted against retry counts. Any other -// response code, or a failure to receive a response before the -// deadline, constitutes a failed attempt. -message AppEngineHttpTarget { - // The HTTP method to use for the request. PATCH and OPTIONS are not - // permitted. - HttpMethod http_method = 1; - - // App Engine Routing setting for the job. - AppEngineRouting app_engine_routing = 2; - - // The relative URI. - // - // The relative URL must begin with "/" and must be a valid HTTP relative URL. - // It can contain a path, query string arguments, and `#` fragments. - // If the relative URL is empty, then the root path "/" will be used. - // No spaces are allowed, and the maximum length allowed is 2083 characters. - string relative_uri = 3; - - // HTTP request headers. - // - // This map contains the header field names and values. Headers can be set - // when the job is created. - // - // Cloud Scheduler sets some headers to default values: - // - // * `User-Agent`: By default, this header is - // `"AppEngine-Google; (+http://code.google.com/appengine)"`. - // This header can be modified, but Cloud Scheduler will append - // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the - // modified `User-Agent`. - // * `X-CloudScheduler`: This header will be set to true. - // - // If the job has an [body][google.cloud.scheduler.v1.AppEngineHttpTarget.body], Cloud Scheduler sets - // the following headers: - // - // * `Content-Type`: By default, the `Content-Type` header is set to - // `"application/octet-stream"`. The default can be overridden by explictly - // setting `Content-Type` to a particular media type when the job is - // created. - // For example, `Content-Type` can be set to `"application/json"`. - // * `Content-Length`: This is computed by Cloud Scheduler. This value is - // output only. It cannot be changed. - // - // The headers below are output only. They cannot be set or overridden: - // - // * `X-Google-*`: For Google internal use only. - // * `X-AppEngine-*`: For Google internal use only. - // - // In addition, some App Engine headers, which contain - // job-specific information, are also be sent to the job handler. - map headers = 4; - - // Body. - // - // HTTP request body. A request body is allowed only if the HTTP method is - // POST or PUT. It will result in invalid argument error to set a body on a - // job with an incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod]. - bytes body = 5; -} - -// Pub/Sub target. The job will be delivered by publishing a message to -// the given Pub/Sub topic. -message PubsubTarget { - // Required. The name of the Cloud Pub/Sub topic to which messages will - // be published when a job is delivered. The topic name must be in the - // same format as required by PubSub's - // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), - // for example `projects/PROJECT_ID/topics/TOPIC_ID`. - // - // The topic must be in the same project as the Cloud Scheduler job. - string topic_name = 1 [(google.api.resource_reference) = { - type: "pubsub.googleapis.com/Topic" - }]; - - // The message payload for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - bytes data = 3; - - // Attributes for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - map attributes = 4; -} - -// App Engine Routing. -// -// For more information about services, versions, and instances see -// [An Overview of App -// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), -// [Microservices Architecture on Google App -// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), -// [App Engine Standard request -// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), -// and [App Engine Flex request -// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). -message AppEngineRouting { - // App service. - // - // By default, the job is sent to the service which is the default - // service when the job is attempted. - string service = 1; - - // App version. - // - // By default, the job is sent to the version which is the default - // version when the job is attempted. - string version = 2; - - // App instance. - // - // By default, the job is sent to an instance which is available when - // the job is attempted. - // - // Requests can only be sent to a specific instance if - // [manual scaling is used in App Engine - // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes). - // App Engine Flex does not support instances. For more information, see - // [App Engine Standard request - // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) - // and [App Engine Flex request - // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). - string instance = 3; - - // Output only. The host that the job is sent to. - // - // For more information about how App Engine requests are routed, see - // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). - // - // The host is constructed as: - // - // - // * `host = [application_domain_name]`
- // `| [service] + '.' + [application_domain_name]`
- // `| [version] + '.' + [application_domain_name]`
- // `| [version_dot_service]+ '.' + [application_domain_name]`
- // `| [instance] + '.' + [application_domain_name]`
- // `| [instance_dot_service] + '.' + [application_domain_name]`
- // `| [instance_dot_version] + '.' + [application_domain_name]`
- // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` - // - // * `application_domain_name` = The domain name of the app, for - // example .appspot.com, which is associated with the - // job's project ID. - // - // * `service =` [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // * `version =` [version][google.cloud.scheduler.v1.AppEngineRouting.version] - // - // * `version_dot_service =` - // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` - // [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // * `instance =` [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] - // - // * `instance_dot_service =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` - // [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // * `instance_dot_version =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` - // [version][google.cloud.scheduler.v1.AppEngineRouting.version] - // - // * `instance_dot_version_dot_service =` - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +` - // [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +` - // [service][google.cloud.scheduler.v1.AppEngineRouting.service] - // - // - // If [service][google.cloud.scheduler.v1.AppEngineRouting.service] is empty, then the job will be sent - // to the service which is the default service when the job is attempted. - // - // If [version][google.cloud.scheduler.v1.AppEngineRouting.version] is empty, then the job will be sent - // to the version which is the default version when the job is attempted. - // - // If [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is empty, then the job will be - // sent to an instance which is available when the job is attempted. - // - // If [service][google.cloud.scheduler.v1.AppEngineRouting.service], - // [version][google.cloud.scheduler.v1.AppEngineRouting.version], or - // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is invalid, then the job will be sent - // to the default version of the default service when the job is attempted. - string host = 4; -} - -// The HTTP method used to execute the job. -enum HttpMethod { - // HTTP method unspecified. Defaults to POST. - HTTP_METHOD_UNSPECIFIED = 0; - - // HTTP POST - POST = 1; - - // HTTP GET - GET = 2; - - // HTTP HEAD - HEAD = 3; - - // HTTP PUT - PUT = 4; - - // HTTP DELETE - DELETE = 5; - - // HTTP PATCH - PATCH = 6; - - // HTTP OPTIONS - OPTIONS = 7; -} - -// Contains information needed for generating an -// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). -// This type of authorization should generally only be used when calling Google -// APIs hosted on *.googleapis.com. -message OAuthToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OAuth token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // OAuth scope to be used for generating OAuth access token. - // If not specified, "https://www.googleapis.com/auth/cloud-platform" - // will be used. - string scope = 2; -} - -// Contains information needed for generating an -// [OpenID Connect -// token](https://developers.google.com/identity/protocols/OpenIDConnect). -// This type of authorization can be used for many scenarios, including -// calling Cloud Run, or endpoints where you intend to validate the token -// yourself. -message OidcToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OIDC token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // Audience to be used when generating OIDC token. If not specified, the URI - // specified in target will be used. - string audience = 2; -} - -// The Pub/Sub Topic resource definition is in google/cloud/pubsub/v1/, -// but we do not import that proto directly; therefore, we redefine the -// pattern here. -option (google.api.resource_definition) = { - type: "pubsub.googleapis.com/Topic" - pattern: "projects/{project}/topics/{topic}" -}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js deleted file mode 100644 index 1e0a1f0ab3f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.create_job.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, job) { - // [START cloudscheduler_v1_generated_CloudScheduler_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 location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * Required. The job to add. The user can optionally specify a name for the - * job in name google.cloud.scheduler.v1.Job.name. name google.cloud.scheduler.v1.Job.name cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * (name google.cloud.scheduler.v1.Job.name) in the response. - */ - // const job = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - }; - - // Run request - const response = await schedulerClient.createJob(request); - console.log(response); - } - - callCreateJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js deleted file mode 100644 index d92b0f68a94..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.delete_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1_generated_CloudScheduler_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. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callDeleteJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.deleteJob(request); - console.log(response); - } - - callDeleteJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js deleted file mode 100644 index 69e1bd5a214..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.get_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1_generated_CloudScheduler_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. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js deleted file mode 100644 index b40f6e56edd..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.list_jobs.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START cloudscheduler_v1_generated_CloudScheduler_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. - */ - /** - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * Requested page size. - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * next_page_token google.cloud.scheduler.v1.ListJobsResponse.next_page_token returned from - * the previous call to ListJobs google.cloud.scheduler.v1.CloudScheduler.ListJobs. It is an error to - * switch the value of filter google.cloud.scheduler.v1.ListJobsRequest.filter or - * order_by google.cloud.scheduler.v1.ListJobsRequest.order_by while iterating through pages. - */ - // const pageToken = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callListJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await schedulerClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END cloudscheduler_v1_generated_CloudScheduler_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-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js deleted file mode 100644 index 5632518f52c..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.pause_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1_generated_CloudScheduler_PauseJob_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 job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callPauseJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.pauseJob(request); - console.log(response); - } - - callPauseJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_PauseJob_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-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js deleted file mode 100644 index a5c2c1682d5..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.resume_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1_generated_CloudScheduler_ResumeJob_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 job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callResumeJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.resumeJob(request); - console.log(response); - } - - callResumeJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_ResumeJob_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-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js deleted file mode 100644 index 65dc433434a..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.run_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1_generated_CloudScheduler_RunJob_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 job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callRunJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.runJob(request); - console.log(response); - } - - callRunJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_RunJob_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-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js deleted file mode 100644 index 6c10cb2435e..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/cloud_scheduler.update_job.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(job, updateMask) { - // [START cloudscheduler_v1_generated_CloudScheduler_UpdateJob_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 new job properties. name google.cloud.scheduler.v1.Job.name must be specified. - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - */ - // const job = {} - /** - * A mask used to specify which fields of the job are being updated. - */ - // const updateMask = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callUpdateJob() { - // Construct request - const request = { - job, - updateMask, - }; - - // Run request - const response = await schedulerClient.updateJob(request); - console.log(response); - } - - callUpdateJob(); - // [END cloudscheduler_v1_generated_CloudScheduler_UpdateJob_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-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json b/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json deleted file mode 100644 index 08f67a411f1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json +++ /dev/null @@ -1,351 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-scheduler", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.scheduler.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ListJobs_async", - "title": "scheduler listJobs Sample", - "origin": "API_DEFINITION", - "description": " Lists jobs.", - "canonical": true, - "file": "cloud_scheduler.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.ListJobsResponse", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ListJobs", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_GetJob_async", - "title": "scheduler getJob Sample", - "origin": "API_DEFINITION", - "description": " Gets a job.", - "canonical": true, - "file": "cloud_scheduler.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.GetJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_CreateJob_async", - "title": "scheduler createJob Sample", - "origin": "API_DEFINITION", - "description": " Creates a job.", - "canonical": true, - "file": "cloud_scheduler.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.scheduler.v1.Job" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.CreateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async", - "title": "scheduler updateJob Sample", - "origin": "API_DEFINITION", - "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", - "canonical": true, - "file": "cloud_scheduler.update_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", - "async": true, - "parameters": [ - { - "name": "job", - "type": ".google.cloud.scheduler.v1.Job" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.UpdateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async", - "title": "scheduler deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Deletes a job.", - "canonical": true, - "file": "cloud_scheduler.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.DeleteJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_PauseJob_async", - "title": "scheduler pauseJob Sample", - "origin": "API_DEFINITION", - "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused.", - "canonical": true, - "file": "cloud_scheduler.pause_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.PauseJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async", - "title": "scheduler resumeJob Sample", - "origin": "API_DEFINITION", - "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed.", - "canonical": true, - "file": "cloud_scheduler.resume_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.ResumeJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1_generated_CloudScheduler_RunJob_async", - "title": "scheduler runJob Sample", - "origin": "API_DEFINITION", - "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", - "canonical": true, - "file": "cloud_scheduler.run_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1.CloudSchedulerClient" - }, - "method": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1.CloudScheduler.RunJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1.CloudScheduler" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts deleted file mode 100644 index 80a3740f221..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const CloudSchedulerClient = v1.CloudSchedulerClient; -type CloudSchedulerClient = v1.CloudSchedulerClient; -export {v1, CloudSchedulerClient}; -export default {v1, CloudSchedulerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts deleted file mode 100644 index 0cf62985d23..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client.ts +++ /dev/null @@ -1,1189 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/cloud_scheduler_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_scheduler_client_config.json'; -const version = require('../../../package.json').version; - -/** - * The Cloud Scheduler API allows external entities to reliably - * schedule asynchronous jobs. - * @class - * @memberof v1 - */ -export class CloudSchedulerClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudSchedulerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudSchedulerClient. - * - * @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 CloudSchedulerClient({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 CloudSchedulerClient; - 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; - } - - // 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}' - ), - }; - - // 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') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.scheduler.v1.CloudScheduler', 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.cloudSchedulerStub) { - return this.cloudSchedulerStub; - } - - // Put together the "service stub" for - // google.cloud.scheduler.v1.CloudScheduler. - this.cloudSchedulerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1.CloudScheduler') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.scheduler.v1.CloudScheduler, - 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 cloudSchedulerStubMethods = - ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; - for (const methodName of cloudSchedulerStubMethods) { - const callPromise = this.cloudSchedulerStub.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] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.cloudSchedulerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudscheduler.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 'cloudscheduler.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.get_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_GetJob_async - */ - getJob( - request?: protos.google.cloud.scheduler.v1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.scheduler.v1.IGetJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.scheduler.v1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.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); - } -/** - * Creates a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {google.cloud.scheduler.v1.Job} request.job - * Required. The job to add. The user can optionally specify a name for the - * job in {@link google.cloud.scheduler.v1.Job.name|name}. {@link google.cloud.scheduler.v1.Job.name|name} cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * ({@link google.cloud.scheduler.v1.Job.name|name}) in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.create_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_CreateJob_async - */ - createJob( - request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.scheduler.v1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.scheduler.v1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.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); - } -/** - * Updates a job. - * - * If successful, the updated {@link google.cloud.scheduler.v1.Job|Job} is returned. If the job does - * not exist, `NOT_FOUND` is returned. - * - * If UpdateJob does not successfully return, it is possible for the - * job to be in an {@link google.cloud.scheduler.v1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} state. A job in this state may - * not be executed. If this happens, retry the UpdateJob request - * until a successful response is received. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.scheduler.v1.Job} request.job - * Required. The new job properties. {@link google.cloud.scheduler.v1.Job.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the job are being updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.update_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_UpdateJob_async - */ - updateJob( - request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|undefined, {}|undefined - ]>; - updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request?: protos.google.cloud.scheduler.v1.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IUpdateJobRequest|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({ - 'job.name': request.job!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateJob(request, options, callback); - } -/** - * Deletes a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @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 [Empty]{@link google.protobuf.Empty}. - * 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/cloud_scheduler.delete_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.scheduler.v1.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1.IDeleteJobRequest|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); - } -/** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via {@link google.cloud.scheduler.v1.CloudScheduler.ResumeJob|ResumeJob}. The - * state of the job is stored in {@link google.cloud.scheduler.v1.Job.state|state}; if paused it - * will be set to {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED} - * to be paused. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.pause_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_PauseJob_async - */ - pauseJob( - request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|undefined, {}|undefined - ]>; - pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request: protos.google.cloud.scheduler.v1.IPauseJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request?: protos.google.cloud.scheduler.v1.IPauseJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IPauseJobRequest|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.pauseJob(request, options, callback); - } -/** - * Resume a job. - * - * This method reenables a job after it has been {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED}. The - * state of a job is stored in {@link google.cloud.scheduler.v1.Job.state|Job.state}; after calling this method it - * will be set to {@link google.cloud.scheduler.v1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in - * {@link google.cloud.scheduler.v1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.resume_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_ResumeJob_async - */ - resumeJob( - request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|undefined, {}|undefined - ]>; - resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request: protos.google.cloud.scheduler.v1.IResumeJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request?: protos.google.cloud.scheduler.v1.IResumeJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IResumeJobRequest|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.resumeJob(request, options, callback); - } -/** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1.Job}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.run_job.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_RunJob_async - */ - runJob( - request?: protos.google.cloud.scheduler.v1.IRunJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|undefined, {}|undefined - ]>; - runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request: protos.google.cloud.scheduler.v1.IRunJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request?: protos.google.cloud.scheduler.v1.IRunJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob, - protos.google.cloud.scheduler.v1.IRunJobRequest|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.runJob(request, options, callback); - } - - /** - * Lists jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1.Job}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listJobs( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1.IJob[], - protos.google.cloud.scheduler.v1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): void; - listJobs( - request: protos.google.cloud.scheduler.v1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): void; - listJobs( - request?: protos.google.cloud.scheduler.v1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>, - callback?: PaginationCallback< - protos.google.cloud.scheduler.v1.IListJobsRequest, - protos.google.cloud.scheduler.v1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1.IJob>): - Promise<[ - protos.google.cloud.scheduler.v1.IJob[], - protos.google.cloud.scheduler.v1.IListJobsRequest|null, - protos.google.cloud.scheduler.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 - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1.Job} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listJobsStream( - request?: protos.google.cloud.scheduler.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 - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1.ListJobsRequest.order_by|order_by} while iterating through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Job]{@link google.cloud.scheduler.v1.Job}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/cloud_scheduler.list_jobs.js - * region_tag:cloudscheduler_v1_generated_CloudScheduler_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.scheduler.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; - } - // -------------------- - // -- 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; - } - - /** - * 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.cloudSchedulerStub && !this._terminated) { - return this.cloudSchedulerStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json deleted file mode 100644 index edb34789cd4..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.scheduler.v1.CloudScheduler": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListJobs": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PauseJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResumeJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "RunJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json deleted file mode 100644 index 2762a0163a0..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/cloud_scheduler_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/scheduler/v1/cloudscheduler.proto", - "../../protos/google/cloud/scheduler/v1/job.proto", - "../../protos/google/cloud/scheduler/v1/target.proto" -] diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 122c43fbb24..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.scheduler.v1", - "libraryPackage": "@google-cloud/scheduler", - "services": { - "CloudScheduler": { - "clients": { - "grpc": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts deleted file mode 100644 index d807e0c860d..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index c9d7fe466bc..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const scheduler = require('@google-cloud/scheduler'); - -function main() { - const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 9fce1cb1ef2..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {CloudSchedulerClient} from '@google-cloud/scheduler'; - -// check that the client class type name can be used -function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudSchedulerClient = new CloudSchedulerClient(); - doStuffWithCloudSchedulerClient(cloudSchedulerClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts b/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts deleted file mode 100644 index e92acb4e4f1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1/test/gapic_cloud_scheduler_v1.ts +++ /dev/null @@ -1,1319 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as cloudschedulerModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} 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 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.CloudSchedulerClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudschedulerModule.v1.CloudSchedulerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudschedulerModule.v1.CloudSchedulerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudschedulerModule.v1.CloudSchedulerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - await client.initialize(); - assert(client.cloudSchedulerStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudSchedulerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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('getJob', () => { - it('invokes getJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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('createJob', () => { - it('invokes createJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateJob(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(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 closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteJob(request), expectedError); - }); - }); - - describe('pauseJob', () => { - it('invokes pauseJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); - const [response] = await client.pauseJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseJob(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseJob(request), expectedError); - }); - }); - - describe('resumeJob', () => { - it('invokes resumeJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); - const [response] = await client.resumeJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeJob(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeJob(request), expectedError); - }); - }); - - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); - const [response] = await client.runJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob without error using callback', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runJob(request), expectedError); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with closed client', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.runJob(request), expectedError); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.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.scheduler.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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.scheduler.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.scheduler.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 cloudschedulerModule.v1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.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.scheduler.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('Path templates', () => { - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1.CloudSchedulerClient({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/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-scheduler/v1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1/webpack.config.js deleted file mode 100644 index d4565464f20..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/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: 'scheduler', - filename: './scheduler.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-scheduler/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore b/owl-bot-staging/google-cloud-scheduler/v1beta1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.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-scheduler/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js deleted file mode 100644 index 08156a43898..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/scheduler', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md b/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md deleted file mode 100644 index 90fa2a2d162..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Scheduler: Nodejs Client diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/linkinator.config.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/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-scheduler/v1beta1/package.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json deleted file mode 100644 index 312a11e17f5..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/scheduler", - "version": "0.1.0", - "description": "Scheduler client for Node.js", - "repository": "googleapis/nodejs-scheduler", - "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 scheduler", - "scheduler", - "cloud scheduler" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto deleted file mode 100644 index f9a2da03ff2..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1beta1/job.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1;scheduler"; -option java_multiple_files = true; -option java_outer_classname = "SchedulerProto"; -option java_package = "com.google.cloud.scheduler.v1beta1"; -option objc_class_prefix = "SCHEDULER"; - -// The Cloud Scheduler API allows external entities to reliably -// schedule asynchronous jobs. -service CloudScheduler { - option (google.api.default_host) = "cloudscheduler.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists jobs. - rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/locations/*}/jobs" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a job. - rpc GetJob(GetJobRequest) returns (Job) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a job. - rpc CreateJob(CreateJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/jobs" - body: "job" - }; - option (google.api.method_signature) = "parent,job"; - } - - // Updates a job. - // - // If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is - // returned. If the job does not exist, `NOT_FOUND` is returned. - // - // If UpdateJob does not successfully return, it is possible for the - // job to be in an - // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] - // state. A job in this state may not be executed. If this happens, retry the - // UpdateJob request until a successful response is received. - rpc UpdateJob(UpdateJobRequest) returns (Job) { - option (google.api.http) = { - patch: "/v1beta1/{job.name=projects/*/locations/*/jobs/*}" - body: "job" - }; - option (google.api.method_signature) = "job,update_mask"; - } - - // Deletes a job. - rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/locations/*/jobs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses a job. - // - // If a job is paused then the system will stop executing the job - // until it is re-enabled via - // [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The - // state of the job is stored in - // [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set - // to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A - // job must be in - // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be - // paused. - rpc PauseJob(PauseJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resume a job. - // - // This method reenables a job after it has been - // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The - // state of a job is stored in - // [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this - // method it will be set to - // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A - // job must be in - // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be - // resumed. - rpc ResumeJob(ResumeJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Forces a job to run now. - // - // When this method is called, Cloud Scheduler will dispatch the job, even - // if the job is already running. - rpc RunJob(RunJobRequest) returns (Job) { - option (google.api.http) = { - post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:run" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// Request message for listing jobs using -// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. -message ListJobsRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // `filter` can be used to specify a subset of jobs. - // - // If `filter` equals `target_config="HttpConfig"`, then the http - // target jobs are retrieved. If `filter` equals - // `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - // retrieved. If `filter` equals `labels.foo=value1 - // labels.foo=value2` then only jobs which are labeled with - // foo=value1 AND foo=value2 will be returned. - string filter = 4; - - // Requested page size. - // - // The maximum page size is 500. If unspecified, the page size will - // be the maximum. Fewer jobs than requested might be returned, - // even if more jobs exist; use next_page_token to determine if more - // jobs exist. - int32 page_size = 5; - - // A token identifying a page of results the server will return. To - // request the first page results, page_token must be empty. To - // request the next page of results, page_token must be the value of - // [next_page_token][google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token] - // returned from the previous call to - // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. It is - // an error to switch the value of - // [filter][google.cloud.scheduler.v1beta1.ListJobsRequest.filter] or - // [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while - // iterating through pages. - string page_token = 6; - - // This field is used to manage the legacy App Engine Cron jobs using the - // Cloud Scheduler API. If the field is set to true, the jobs in the __cron - // queue will be listed instead. - bool legacy_app_engine_cron = 7; -} - -// Response message for listing jobs using -// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. -message ListJobsResponse { - // The list of jobs. - repeated Job jobs = 1; - - // A token to retrieve next page of results. Pass this value in the - // [page_token][google.cloud.scheduler.v1beta1.ListJobsRequest.page_token] - // field in the subsequent call to - // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs] to - // retrieve the next page of results. If this is empty it indicates that there - // are no more results through which to paginate. - // - // The page token is valid for only 2 hours. - string next_page_token = 2; -} - -// Request message for -// [GetJob][google.cloud.scheduler.v1beta1.CloudScheduler.GetJob]. -message GetJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob]. -message CreateJobRequest { - // Required. The location name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // Required. The job to add. The user can optionally specify a name for the - // job in [name][google.cloud.scheduler.v1beta1.Job.name]. - // [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an - // existing job. If a name is not specified then the system will - // generate a random unique name that will be returned - // ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. - Job job = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. -message UpdateJobRequest { - // Required. The new job properties. - // [name][google.cloud.scheduler.v1beta1.Job.name] must be specified. - // - // Output only fields cannot be modified using UpdateJob. - // Any value specified for an output only field will be ignored. - Job job = 1 [(google.api.field_behavior) = REQUIRED]; - - // A mask used to specify which fields of the job are being updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request message for deleting a job using -// [DeleteJob][google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob]. -message DeleteJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // This field is used to manage the legacy App Engine Cron jobs using the - // Cloud Scheduler API. If the field is set to true, the job in the __cron - // queue with the corresponding name will be deleted instead. - bool legacy_app_engine_cron = 2; -} - -// Request message for -// [PauseJob][google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob]. -message PauseJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for -// [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. -message ResumeJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; -} - -// Request message for forcing a job to run now using -// [RunJob][google.cloud.scheduler.v1beta1.CloudScheduler.RunJob]. -message RunJobRequest { - // Required. The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudscheduler.googleapis.com/Job" - } - ]; - - // This field is used to manage the legacy App Engine Cron jobs using the - // Cloud Scheduler API. If the field is set to true, the job in the __cron - // queue with the corresponding name will be forced to run instead. - bool legacy_app_engine_cron = 2; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto deleted file mode 100644 index 2353beecac8..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/job.proto +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1beta1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/scheduler/v1beta1/target.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1;scheduler"; -option java_multiple_files = true; -option java_outer_classname = "JobProto"; -option java_package = "com.google.cloud.scheduler.v1beta1"; - -// Configuration for a job. -// The maximum allowed size for a job is 1MB. -message Job { - option (google.api.resource) = { - type: "cloudscheduler.googleapis.com/Job" - pattern: "projects/{project}/locations/{location}/jobs/{job}" - }; - - // State of the job. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The job is executing normally. - ENABLED = 1; - - // The job is paused by the user. It will not execute. A user can - // intentionally pause the job using - // [PauseJobRequest][google.cloud.scheduler.v1beta1.PauseJobRequest]. - PAUSED = 2; - - // The job is disabled by the system due to error. The user - // cannot directly set a job to be disabled. - DISABLED = 3; - - // The job state resulting from a failed - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] - // operation. To recover a job from this state, retry - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] - // until a successful response is received. - UPDATE_FAILED = 4; - } - - // Optionally caller-specified in - // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after - // which it becomes output only. - // - // The job name. For example: - // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - // - // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), colons (:), or periods (.). - // For more information, see - // [Identifying - // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) - // * `LOCATION_ID` is the canonical ID for the job's location. - // The list of available locations can be obtained by calling - // [ListLocations][google.cloud.location.Locations.ListLocations]. - // For more information, see https://cloud.google.com/about/locations/. - // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), - // hyphens (-), or underscores (_). The maximum length is 500 characters. - string name = 1; - - // Optionally caller-specified in - // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or - // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. - // - // A human-readable description for the job. This string must not contain - // more than 500 characters. - string description = 2; - - // Required. - // - // Delivery settings containing destination and parameters. - oneof target { - // Pub/Sub target. - PubsubTarget pubsub_target = 4; - - // App Engine HTTP target. - AppEngineHttpTarget app_engine_http_target = 5; - - // HTTP target. - HttpTarget http_target = 6; - } - - // Required, except when used with - // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. - // - // Describes the schedule on which the job will be executed. - // - // The schedule can be either of the following types: - // - // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) - // * English-like - // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) - // - // As a general rule, execution `n + 1` of a job will not begin - // until execution `n` has finished. Cloud Scheduler will never - // allow two simultaneously outstanding executions. For example, - // this implies that if the `n+1`th execution is scheduled to run at - // 16:00 but the `n`th execution takes until 16:15, the `n+1`th - // execution will not start until `16:15`. - // A scheduled start time will be delayed if the previous - // execution has not ended when its scheduled time occurs. - // - // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] > - // 0 and a job attempt fails, the job will be tried a total of - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] - // times, with exponential backoff, until the next scheduled start - // time. - string schedule = 20; - - // Specifies the time zone to be used in interpreting - // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this - // field must be a time zone name from the [tz - // database](http://en.wikipedia.org/wiki/Tz_database). - // - // Note that some time zones include a provision for - // daylight savings time. The rules for daylight saving time are - // determined by the chosen tz. For UTC use the string "utc". If a - // time zone is not specified, the default will be in UTC (also known - // as GMT). - string time_zone = 21; - - // Output only. The creation time of the job. - google.protobuf.Timestamp user_update_time = 9; - - // Output only. State of the job. - State state = 10; - - // Output only. The response from the target for the last attempted execution. - google.rpc.Status status = 11; - - // Output only. The next time the job is scheduled. Note that this may be a - // retry of a previously failed attempt or the next execution time - // according to the schedule. - google.protobuf.Timestamp schedule_time = 17; - - // Output only. The time the last job attempt started. - google.protobuf.Timestamp last_attempt_time = 18; - - // Settings that determine the retry behavior. - RetryConfig retry_config = 19; - - // The deadline for job attempts. If the request handler does not respond by - // this deadline then the request is cancelled and the attempt is marked as a - // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in - // execution logs. Cloud Scheduler will retry the job according - // to the [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. - // - // The default and the allowed values depend on the type of target: - // - // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], the - // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 - // minutes]. - // - // * For [App Engine HTTP - // targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], 0 - // indicates that the request has the default deadline. The default deadline - // depends on the scaling type of the service: 10 minutes for standard apps - // with automatic scaling, 24 hours for standard apps with manual and basic - // scaling, and 60 minutes for flex apps. If the request deadline is set, it - // must be in the interval [15 seconds, 24 hours 15 seconds]. - // - // * For [Pub/Sub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target], - // this field is ignored. - google.protobuf.Duration attempt_deadline = 22; - - // Immutable. This field is used to manage the legacy App Engine Cron jobs - // using the Cloud Scheduler API. If the field is set to true, the job will be - // considered a legacy job. Note that App Engine Cron jobs have fewer - // features than Cloud Scheduler jobs, e.g., are only limited to App Engine - // targets. - bool legacy_app_engine_cron = 23 [(google.api.field_behavior) = IMMUTABLE]; -} - -// Settings that determine the retry behavior. -// -// By default, if a job does not complete successfully (meaning that -// an acknowledgement is not received from the handler, then it will be retried -// with exponential backoff according to the settings in -// [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. -message RetryConfig { - // The number of attempts that the system will make to run a job using the - // exponential backoff procedure described by - // [max_doublings][google.cloud.scheduler.v1beta1.RetryConfig.max_doublings]. - // - // The default value of retry_count is zero. - // - // If retry_count is zero, a job attempt will *not* be retried if - // it fails. Instead the Cloud Scheduler system will wait for the - // next scheduled execution time. - // - // If retry_count is set to a non-zero number then Cloud Scheduler - // will retry failed attempts, using exponential backoff, - // retry_count times, or until the next scheduled execution time, - // whichever comes first. - // - // Values greater than 5 and negative values are not allowed. - int32 retry_count = 1; - - // The time limit for retrying a failed job, measured from time when an - // execution was first attempted. If specified with - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the - // job will be retried until both limits are reached. - // - // The default value for max_retry_duration is zero, which means retry - // duration is unlimited. - google.protobuf.Duration max_retry_duration = 2; - - // The minimum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 5 seconds. - google.protobuf.Duration min_backoff_duration = 3; - - // The maximum amount of time to wait before retrying a job after - // it fails. - // - // The default value of this field is 1 hour. - google.protobuf.Duration max_backoff_duration = 4; - - // The time between retries will double `max_doublings` times. - // - // A job's retry interval starts at - // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration], - // then doubles `max_doublings` times, then increases linearly, and finally - // retries at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] - // up to [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] - // times. - // - // For example, if - // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration] - // is 10s, - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] - // is 300s, and `max_doublings` is 3, then the a job will first be retried in - // 10s. The retry interval will double three times, and then increase linearly - // by 2^3 * 10s. Finally, the job will retry at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] - // until the job has been attempted - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] - // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, - // 300s, 300s, .... - // - // The default value of this field is 5. - int32 max_doublings = 5; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto b/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto deleted file mode 100644 index f98f210dc40..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/protos/google/cloud/scheduler/v1beta1/target.proto +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.scheduler.v1beta1; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1;scheduler"; -option java_multiple_files = true; -option java_outer_classname = "TargetProto"; -option java_package = "com.google.cloud.scheduler.v1beta1"; -option (google.api.resource_definition) = { - type: "pubsub.googleapis.com/Topic" - pattern: "projects/{project}/topics/{topic}" -}; - -// Http target. The job will be pushed to the job handler by means of -// an HTTP request via an -// [http_method][google.cloud.scheduler.v1beta1.HttpTarget.http_method] such as -// HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP -// response code in the range [200 - 299]. A failure to receive a response -// constitutes a failed execution. For a redirected request, the response -// returned by the redirected request is considered. -message HttpTarget { - // Required. The full URI path that the request will be sent to. This string - // must begin with either "http://" or "https://". Some examples of - // valid values for [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri] are: - // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will - // encode some characters for safety and compatibility. The maximum allowed - // URL length is 2083 characters after encoding. - string uri = 1; - - // Which HTTP method to use for the request. - HttpMethod http_method = 2; - - // The user can specify HTTP request headers to send with the job's - // HTTP request. This map contains the header field names and - // values. Repeated headers are not supported, but a header value can - // contain commas. These headers represent a subset of the headers - // that will accompany the job's HTTP request. Some HTTP request - // headers will be ignored or replaced. A partial list of headers that - // will be ignored or replaced is below: - // - Host: This will be computed by Cloud Scheduler and derived from - // [uri][google.cloud.scheduler.v1beta1.HttpTarget.uri]. - // * `Content-Length`: This will be computed by Cloud Scheduler. - // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. - // * `X-Google-*`: Google internal use only. - // * `X-AppEngine-*`: Google internal use only. - // * `X-CloudScheduler`: This header will be set to true. - // * `X-CloudScheduler-JobName`: This header will contain the job name. - // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in - // the unix-cron format, this header will contain the job schedule time in - // RFC3339 UTC "Zulu" format. - // - // The total size of headers must be less than 80KB. - map headers = 3; - - // HTTP request body. A request body is allowed only if the HTTP - // method is POST, PUT, or PATCH. It is an error to set body on a job with an - // incompatible [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. - bytes body = 4; - - // The mode for generating an `Authorization` header for HTTP requests. - // - // If specified, all `Authorization` headers in the - // [HttpTarget.headers][google.cloud.scheduler.v1beta1.HttpTarget.headers] - // field will be overridden. - oneof authorization_header { - // If specified, an - // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) - // will be generated and attached as an `Authorization` header in the HTTP - // request. - // - // This type of authorization should generally only be used when calling - // Google APIs hosted on *.googleapis.com. - OAuthToken oauth_token = 5; - - // If specified, an - // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) - // token will be generated and attached as an `Authorization` header in the - // HTTP request. - // - // This type of authorization can be used for many scenarios, including - // calling Cloud Run, or endpoints where you intend to validate the token - // yourself. - OidcToken oidc_token = 6; - } -} - -// App Engine target. The job will be pushed to a job handler by means -// of an HTTP request via an -// [http_method][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.http_method] -// such as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP -// response code in the range [200 - 299]. Error 503 is considered an App Engine -// system error instead of an application error. Requests returning error 503 -// will be retried regardless of retry configuration and not counted against -// retry counts. Any other response code, or a failure to receive a response -// before the deadline, constitutes a failed attempt. -message AppEngineHttpTarget { - // The HTTP method to use for the request. PATCH and OPTIONS are not - // permitted. - HttpMethod http_method = 1; - - // App Engine Routing setting for the job. - AppEngineRouting app_engine_routing = 2; - - // The relative URI. - // - // The relative URL must begin with "/" and must be a valid HTTP relative URL. - // It can contain a path, query string arguments, and `#` fragments. - // If the relative URL is empty, then the root path "/" will be used. - // No spaces are allowed, and the maximum length allowed is 2083 characters. - string relative_uri = 3; - - // HTTP request headers. - // - // This map contains the header field names and values. Headers can be set - // when the job is created. - // - // Cloud Scheduler sets some headers to default values: - // - // * `User-Agent`: By default, this header is - // `"AppEngine-Google; (+http://code.google.com/appengine)"`. - // This header can be modified, but Cloud Scheduler will append - // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the - // modified `User-Agent`. - // * `X-CloudScheduler`: This header will be set to true. - // * `X-CloudScheduler-JobName`: This header will contain the job name. - // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in - // the unix-cron format, this header will contain the job schedule time in - // RFC3339 UTC "Zulu" format. - // - // If the job has an - // [body][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.body], Cloud - // Scheduler sets the following headers: - // - // * `Content-Type`: By default, the `Content-Type` header is set to - // `"application/octet-stream"`. The default can be overridden by explictly - // setting `Content-Type` to a particular media type when the job is - // created. - // For example, `Content-Type` can be set to `"application/json"`. - // * `Content-Length`: This is computed by Cloud Scheduler. This value is - // output only. It cannot be changed. - // - // The headers below are output only. They cannot be set or overridden: - // - // * `X-Google-*`: For Google internal use only. - // * `X-AppEngine-*`: For Google internal use only. - // - // In addition, some App Engine headers, which contain - // job-specific information, are also be sent to the job handler. - map headers = 4; - - // Body. - // - // HTTP request body. A request body is allowed only if the HTTP method is - // POST or PUT. It will result in invalid argument error to set a body on a - // job with an incompatible - // [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. - bytes body = 5; -} - -// Pub/Sub target. The job will be delivered by publishing a message to -// the given Pub/Sub topic. -message PubsubTarget { - // Required. The name of the Cloud Pub/Sub topic to which messages will - // be published when a job is delivered. The topic name must be in the - // same format as required by Pub/Sub's - // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), - // for example `projects/PROJECT_ID/topics/TOPIC_ID`. - // - // The topic must be in the same project as the Cloud Scheduler job. - string topic_name = 1 [ - (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } - ]; - - // The message payload for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - bytes data = 3; - - // Attributes for PubsubMessage. - // - // Pubsub message must contain either non-empty data, or at least one - // attribute. - map attributes = 4; -} - -// App Engine Routing. -// -// For more information about services, versions, and instances see -// [An Overview of App -// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), -// [Microservices Architecture on Google App -// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), -// [App Engine Standard request -// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), -// and [App Engine Flex request -// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). -message AppEngineRouting { - // App service. - // - // By default, the job is sent to the service which is the default - // service when the job is attempted. - string service = 1; - - // App version. - // - // By default, the job is sent to the version which is the default - // version when the job is attempted. - string version = 2; - - // App instance. - // - // By default, the job is sent to an instance which is available when - // the job is attempted. - // - // Requests can only be sent to a specific instance if - // [manual scaling is used in App Engine - // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). - // App Engine Flex does not support instances. For more information, see - // [App Engine Standard request - // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) - // and [App Engine Flex request - // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). - string instance = 3; - - // Output only. The host that the job is sent to. - // - // For more information about how App Engine requests are routed, see - // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). - // - // The host is constructed as: - // - // - // * `host = [application_domain_name]`
- // `| [service] + '.' + [application_domain_name]`
- // `| [version] + '.' + [application_domain_name]`
- // `| [version_dot_service]+ '.' + [application_domain_name]`
- // `| [instance] + '.' + [application_domain_name]`
- // `| [instance_dot_service] + '.' + [application_domain_name]`
- // `| [instance_dot_version] + '.' + [application_domain_name]`
- // `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` - // - // * `application_domain_name` = The domain name of the app, for - // example .appspot.com, which is associated with the - // job's project ID. - // - // * `service =` - // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // * `version =` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] - // - // * `version_dot_service =` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' - // +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // * `instance =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] - // - // * `instance_dot_service =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ - // '.' +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // * `instance_dot_version =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ - // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] - // - // * `instance_dot_version_dot_service =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ - // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] - // `+ '.' +` - // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] - // - // - // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] is - // empty, then the job will be sent to the service which is the default - // service when the job is attempted. - // - // If [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] is - // empty, then the job will be sent to the version which is the default - // version when the job is attempted. - // - // If [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is - // empty, then the job will be sent to an instance which is available when the - // job is attempted. - // - // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service], - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version], or - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is - // invalid, then the job will be sent to the default version of the default - // service when the job is attempted. - string host = 4; -} - -// The HTTP method used to execute the job. -enum HttpMethod { - // HTTP method unspecified. Defaults to POST. - HTTP_METHOD_UNSPECIFIED = 0; - - // HTTP POST - POST = 1; - - // HTTP GET - GET = 2; - - // HTTP HEAD - HEAD = 3; - - // HTTP PUT - PUT = 4; - - // HTTP DELETE - DELETE = 5; - - // HTTP PATCH - PATCH = 6; - - // HTTP OPTIONS - OPTIONS = 7; -} - -// Contains information needed for generating an -// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). -// This type of authorization should generally only be used when calling Google -// APIs hosted on *.googleapis.com. -message OAuthToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OAuth token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // OAuth scope to be used for generating OAuth access token. - // If not specified, "https://www.googleapis.com/auth/cloud-platform" - // will be used. - string scope = 2; -} - -// Contains information needed for generating an -// [OpenID Connect -// token](https://developers.google.com/identity/protocols/OpenIDConnect). -// This type of authorization can be used for many scenarios, including -// calling Cloud Run, or endpoints where you intend to validate the token -// yourself. -message OidcToken { - // [Service account email](https://cloud.google.com/iam/docs/service-accounts) - // to be used for generating OIDC token. - // The service account must be within the same project as the job. The caller - // must have iam.serviceAccounts.actAs permission for the service account. - string service_account_email = 1; - - // Audience to be used when generating OIDC token. If not specified, the URI - // specified in target will be used. - string audience = 2; -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js deleted file mode 100644 index 92de5253bd7..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.create_job.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, job) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_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 location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * Required. The job to add. The user can optionally specify a name for the - * job in name google.cloud.scheduler.v1beta1.Job.name. - * name google.cloud.scheduler.v1beta1.Job.name cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * (name google.cloud.scheduler.v1beta1.Job.name) in the response. - */ - // const job = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callCreateJob() { - // Construct request - const request = { - parent, - job, - }; - - // Run request - const response = await schedulerClient.createJob(request); - console.log(response); - } - - callCreateJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js deleted file mode 100644 index b2d7fd2a8ad..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.delete_job.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_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. - */ - /** - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - /** - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be deleted instead. - */ - // const legacyAppEngineCron = true - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callDeleteJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.deleteJob(request); - console.log(response); - } - - callDeleteJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js deleted file mode 100644 index d22f591b519..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.get_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_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. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callGetJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.getJob(request); - console.log(response); - } - - callGetJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js deleted file mode 100644 index 7ae9366e802..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.list_jobs.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_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. - */ - /** - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - */ - // const parent = 'abc123' - /** - * `filter` can be used to specify a subset of jobs. - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - */ - // const filter = 'abc123' - /** - * Requested page size. - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * next_page_token google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token - * returned from the previous call to - * ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is - * an error to switch the value of - * filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter or - * order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by while - * iterating through pages. - */ - // const pageToken = 'abc123' - /** - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - */ - // const legacyAppEngineCron = true - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callListJobs() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await schedulerClient.listJobsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListJobs(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js deleted file mode 100644 index 762bf00520b..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.pause_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_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 job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callPauseJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.pauseJob(request); - console.log(response); - } - - callPauseJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js deleted file mode 100644 index c27c161c969..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.resume_job.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_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 job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callResumeJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.resumeJob(request); - console.log(response); - } - - callResumeJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js deleted file mode 100644 index 52f869a91e7..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.run_job.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_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 job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - */ - // const name = 'abc123' - /** - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be forced to run instead. - */ - // const legacyAppEngineCron = true - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callRunJob() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await schedulerClient.runJob(request); - console.log(response); - } - - callRunJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_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-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js deleted file mode 100644 index ed9680f11c9..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/cloud_scheduler.update_job.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(job) { - // [START cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_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 new job properties. - * name google.cloud.scheduler.v1beta1.Job.name must be specified. - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - */ - // const job = {} - /** - * A mask used to specify which fields of the job are being updated. - */ - // const updateMask = {} - - // Imports the Scheduler library - const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; - - // Instantiates a client - const schedulerClient = new CloudSchedulerClient(); - - async function callUpdateJob() { - // Construct request - const request = { - job, - }; - - // Run request - const response = await schedulerClient.updateJob(request); - console.log(response); - } - - callUpdateJob(); - // [END cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_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-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json deleted file mode 100644 index 19c756a7cd0..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json +++ /dev/null @@ -1,367 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-scheduler", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.scheduler.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async", - "title": "scheduler listJobs Sample", - "origin": "API_DEFINITION", - "description": " Lists jobs.", - "canonical": true, - "file": "cloud_scheduler.list_jobs.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.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" - }, - { - "name": "legacy_app_engine_cron", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.ListJobsResponse", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "ListJobs", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async", - "title": "scheduler getJob Sample", - "origin": "API_DEFINITION", - "description": " Gets a job.", - "canonical": true, - "file": "cloud_scheduler.get_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "GetJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.GetJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async", - "title": "scheduler createJob Sample", - "origin": "API_DEFINITION", - "description": " Creates a job.", - "canonical": true, - "file": "cloud_scheduler.create_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "job", - "type": ".google.cloud.scheduler.v1beta1.Job" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "CreateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async", - "title": "scheduler updateJob Sample", - "origin": "API_DEFINITION", - "description": " Updates a job. If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is returned. If the job does not exist, `NOT_FOUND` is returned. If UpdateJob does not successfully return, it is possible for the job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.", - "canonical": true, - "file": "cloud_scheduler.update_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", - "async": true, - "parameters": [ - { - "name": "job", - "type": ".google.cloud.scheduler.v1beta1.Job" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "UpdateJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async", - "title": "scheduler deleteJob Sample", - "origin": "API_DEFINITION", - "description": " Deletes a job.", - "canonical": true, - "file": "cloud_scheduler.delete_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "legacy_app_engine_cron", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "DeleteJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async", - "title": "scheduler pauseJob Sample", - "origin": "API_DEFINITION", - "description": " Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused.", - "canonical": true, - "file": "cloud_scheduler.pause_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "PauseJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async", - "title": "scheduler resumeJob Sample", - "origin": "API_DEFINITION", - "description": " Resume a job. This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.", - "canonical": true, - "file": "cloud_scheduler.resume_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "ResumeJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - }, - { - "regionTag": "cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async", - "title": "scheduler runJob Sample", - "origin": "API_DEFINITION", - "description": " Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.", - "canonical": true, - "file": "cloud_scheduler.run_job.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "legacy_app_engine_cron", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.scheduler.v1beta1.Job", - "client": { - "shortName": "CloudSchedulerClient", - "fullName": "google.cloud.scheduler.v1beta1.CloudSchedulerClient" - }, - "method": { - "shortName": "RunJob", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", - "service": { - "shortName": "CloudScheduler", - "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts deleted file mode 100644 index 5137a469f2d..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta1 from './v1beta1'; -const CloudSchedulerClient = v1beta1.CloudSchedulerClient; -type CloudSchedulerClient = v1beta1.CloudSchedulerClient; -export {v1beta1, CloudSchedulerClient}; -export default {v1beta1, CloudSchedulerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts deleted file mode 100644 index e6ffe25f901..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client.ts +++ /dev/null @@ -1,1344 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, 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/v1beta1/cloud_scheduler_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_scheduler_client_config.json'; -const version = require('../../../package.json').version; - -/** - * The Cloud Scheduler API allows external entities to reliably - * schedule asynchronous jobs. - * @class - * @memberof v1beta1 - */ -export class CloudSchedulerClient { - 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}; - cloudSchedulerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudSchedulerClient. - * - * @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 CloudSchedulerClient({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 CloudSchedulerClient; - 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}' - ), - }; - - // 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') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.scheduler.v1beta1.CloudScheduler', 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.cloudSchedulerStub) { - return this.cloudSchedulerStub; - } - - // Put together the "service stub" for - // google.cloud.scheduler.v1beta1.CloudScheduler. - this.cloudSchedulerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.scheduler.v1beta1.CloudScheduler') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.scheduler.v1beta1.CloudScheduler, - 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 cloudSchedulerStubMethods = - ['listJobs', 'getJob', 'createJob', 'updateJob', 'deleteJob', 'pauseJob', 'resumeJob', 'runJob']; - for (const methodName of cloudSchedulerStubMethods) { - const callPromise = this.cloudSchedulerStub.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] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.cloudSchedulerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudscheduler.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 'cloudscheduler.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.get_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_GetJob_async - */ - getJob( - request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|undefined, {}|undefined - ]>; - getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; - getJob( - request?: protos.google.cloud.scheduler.v1beta1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.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); - } -/** - * Creates a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The job to add. The user can optionally specify a name for the - * job in {@link google.cloud.scheduler.v1beta1.Job.name|name}. - * {@link google.cloud.scheduler.v1beta1.Job.name|name} cannot be the same as an - * existing job. If a name is not specified then the system will - * generate a random unique name that will be returned - * ({@link google.cloud.scheduler.v1beta1.Job.name|name}) in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.create_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_CreateJob_async - */ - createJob( - request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|undefined, {}|undefined - ]>; - createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; - createJob( - request?: protos.google.cloud.scheduler.v1beta1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.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); - } -/** - * Updates a job. - * - * If successful, the updated {@link google.cloud.scheduler.v1beta1.Job|Job} is - * returned. If the job does not exist, `NOT_FOUND` is returned. - * - * If UpdateJob does not successfully return, it is possible for the - * job to be in an - * {@link google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} - * state. A job in this state may not be executed. If this happens, retry the - * UpdateJob request until a successful response is received. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The new job properties. - * {@link google.cloud.scheduler.v1beta1.Job.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateJob. - * Any value specified for an output only field will be ignored. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the job are being updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.update_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_UpdateJob_async - */ - updateJob( - request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|undefined, {}|undefined - ]>; - updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; - updateJob( - request?: protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IUpdateJobRequest|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({ - 'job.name': request.job!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateJob(request, options, callback); - } -/** - * Deletes a job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be deleted instead. - * @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 [Empty]{@link google.protobuf.Empty}. - * 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/v1beta1/cloud_scheduler.delete_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_DeleteJob_async - */ - deleteJob( - request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|undefined, {}|undefined - ]>; - deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; - deleteJob( - request?: protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.scheduler.v1beta1.IDeleteJobRequest|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); - } -/** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via - * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The - * state of the job is stored in - * {@link google.cloud.scheduler.v1beta1.Job.state|state}; if paused it will be set - * to {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A - * job must be in - * {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} to be - * paused. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.pause_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_PauseJob_async - */ - pauseJob( - request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|undefined, {}|undefined - ]>; - pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): void; - pauseJob( - request?: protos.google.cloud.scheduler.v1beta1.IPauseJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IPauseJobRequest|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.pauseJob(request, options, callback); - } -/** - * Resume a job. - * - * This method reenables a job after it has been - * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The - * state of a job is stored in - * {@link google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this - * method it will be set to - * {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A - * job must be in - * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be - * resumed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.resume_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ResumeJob_async - */ - resumeJob( - request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|undefined, {}|undefined - ]>; - resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): void; - resumeJob( - request?: protos.google.cloud.scheduler.v1beta1.IResumeJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IResumeJobRequest|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.resumeJob(request, options, callback); - } -/** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The job name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the job in the __cron - * queue with the corresponding name will be forced to run instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.run_job.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_RunJob_async - */ - runJob( - request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|undefined, {}|undefined - ]>; - runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - callback: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): void; - runJob( - request?: protos.google.cloud.scheduler.v1beta1.IRunJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob, - protos.google.cloud.scheduler.v1beta1.IRunJobRequest|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.runJob(request, options, callback); - } - - /** - * Lists jobs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {string} request.filter - * `filter` can be used to specify a subset of jobs. - * - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is - * an error to switch the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Job]{@link google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob[], - protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse - ]>; - listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): void; - listJobs( - request: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): void; - listJobs( - request?: protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>, - callback?: PaginationCallback< - protos.google.cloud.scheduler.v1beta1.IListJobsRequest, - protos.google.cloud.scheduler.v1beta1.IListJobsResponse|null|undefined, - protos.google.cloud.scheduler.v1beta1.IJob>): - Promise<[ - protos.google.cloud.scheduler.v1beta1.IJob[], - protos.google.cloud.scheduler.v1beta1.IListJobsRequest|null, - protos.google.cloud.scheduler.v1beta1.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 - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {string} request.filter - * `filter` can be used to specify a subset of jobs. - * - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is - * an error to switch the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Job]{@link google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.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 - * Required. The location name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID`. - * @param {string} request.filter - * `filter` can be used to specify a subset of jobs. - * - * If `filter` equals `target_config="HttpConfig"`, then the http - * target jobs are retrieved. If `filter` equals - * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are - * retrieved. If `filter` equals `labels.foo=value1 - * labels.foo=value2` then only jobs which are labeled with - * foo=value1 AND foo=value2 will be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 500. If unspecified, the page size will - * be the maximum. Fewer jobs than requested might be returned, - * even if more jobs exist; use next_page_token to determine if more - * jobs exist. - * @param {string} request.pageToken - * A token identifying a page of results the server will return. To - * request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is - * an error to switch the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while - * iterating through pages. - * @param {boolean} request.legacyAppEngineCron - * This field is used to manage the legacy App Engine Cron jobs using the - * Cloud Scheduler API. If the field is set to true, the jobs in the __cron - * queue will be listed instead. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Job]{@link google.cloud.scheduler.v1beta1.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/v1beta1/cloud_scheduler.list_jobs.js - * region_tag:cloudscheduler_v1beta1_generated_CloudScheduler_ListJobs_async - */ - listJobsAsync( - request?: protos.google.cloud.scheduler.v1beta1.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; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - - // -------------------- - // -- 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; - } - - /** - * 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.cloudSchedulerStub && !this._terminated) { - return this.cloudSchedulerStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json deleted file mode 100644 index 6ded8ffff11..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.scheduler.v1beta1.CloudScheduler": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "ListJobs": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PauseJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ResumeJob": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RunJob": { - "timeout_millis": 600000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json deleted file mode 100644 index a911aaeb80f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/cloud_scheduler_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto", - "../../protos/google/cloud/scheduler/v1beta1/job.proto", - "../../protos/google/cloud/scheduler/v1beta1/target.proto" -] diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index c097889cd1f..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.scheduler.v1beta1", - "libraryPackage": "@google-cloud/scheduler", - "services": { - "CloudScheduler": { - "clients": { - "grpc": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudSchedulerClient", - "rpcs": { - "GetJob": { - "methods": [ - "getJob" - ] - }, - "CreateJob": { - "methods": [ - "createJob" - ] - }, - "UpdateJob": { - "methods": [ - "updateJob" - ] - }, - "DeleteJob": { - "methods": [ - "deleteJob" - ] - }, - "PauseJob": { - "methods": [ - "pauseJob" - ] - }, - "ResumeJob": { - "methods": [ - "resumeJob" - ] - }, - "RunJob": { - "methods": [ - "runJob" - ] - }, - "ListJobs": { - "methods": [ - "listJobs", - "listJobsStream", - "listJobsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index d807e0c860d..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {CloudSchedulerClient} from './cloud_scheduler_client'; diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index c9d7fe466bc..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const scheduler = require('@google-cloud/scheduler'); - -function main() { - const cloudSchedulerClient = new scheduler.CloudSchedulerClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 9fce1cb1ef2..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {CloudSchedulerClient} from '@google-cloud/scheduler'; - -// check that the client class type name can be used -function doStuffWithCloudSchedulerClient(client: CloudSchedulerClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudSchedulerClient = new CloudSchedulerClient(); - doStuffWithCloudSchedulerClient(cloudSchedulerClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts b/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts deleted file mode 100644 index 8f4b686d1dd..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/test/gapic_cloud_scheduler_v1beta1.ts +++ /dev/null @@ -1,1485 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as cloudschedulerModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, 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 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('v1beta1.CloudSchedulerClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudschedulerModule.v1beta1.CloudSchedulerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudschedulerModule.v1beta1.CloudSchedulerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudschedulerModule.v1beta1.CloudSchedulerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - await client.initialize(); - assert(client.cloudSchedulerStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudSchedulerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudSchedulerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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('getJob', () => { - it('invokes getJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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('createJob', () => { - it('invokes createJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateJob(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(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 closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteJob(request), expectedError); - }); - }); - - describe('pauseJob', () => { - it('invokes pauseJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCall(expectedResponse); - const [response] = await client.pauseJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.pauseJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseJob(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.PauseJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.PauseJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseJob(request), expectedError); - }); - }); - - describe('resumeJob', () => { - it('invokes resumeJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCall(expectedResponse); - const [response] = await client.resumeJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.resumeJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeJob(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ResumeJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ResumeJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeJob(request), expectedError); - }); - }); - - describe('runJob', () => { - it('invokes runJob without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCall(expectedResponse); - const [response] = await client.runJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob without error using callback', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.Job() - ); - client.innerApiCalls.runJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runJob( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runJob(request), expectedError); - const actualRequest = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runJob with closed client', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.RunJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.RunJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.runJob(request), expectedError); - }); - }); - - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.scheduler.v1beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - generateSampleMessage(new protos.google.cloud.scheduler.v1beta1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.scheduler.v1beta1.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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.scheduler.v1beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.scheduler.v1beta1.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.scheduler.v1beta1.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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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('Path templates', () => { - - describe('job', () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ - 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)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-scheduler/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/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-scheduler/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-scheduler/v1beta1/webpack.config.js deleted file mode 100644 index d4565464f20..00000000000 --- a/owl-bot-staging/google-cloud-scheduler/v1beta1/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: 'scheduler', - filename: './scheduler.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-scheduler/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto b/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto index 4f86b7a5621..f9a2da03ff2 100644 --- a/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto +++ b/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/cloudscheduler.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT 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"; @@ -35,7 +34,8 @@ option objc_class_prefix = "SCHEDULER"; // schedule asynchronous jobs. service CloudScheduler { option (google.api.default_host) = "cloudscheduler.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; // Lists jobs. rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { @@ -64,13 +64,14 @@ service CloudScheduler { // Updates a job. // - // If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is returned. If the job does - // not exist, `NOT_FOUND` is returned. + // If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is + // returned. If the job does not exist, `NOT_FOUND` is returned. // // If UpdateJob does not successfully return, it is possible for the - // job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] state. A job in this state may - // not be executed. If this happens, retry the UpdateJob request - // until a successful response is received. + // job to be in an + // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] + // state. A job in this state may not be executed. If this happens, retry the + // UpdateJob request until a successful response is received. rpc UpdateJob(UpdateJobRequest) returns (Job) { option (google.api.http) = { patch: "/v1beta1/{job.name=projects/*/locations/*/jobs/*}" @@ -90,10 +91,14 @@ service CloudScheduler { // Pauses a job. // // If a job is paused then the system will stop executing the job - // until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The - // state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it - // will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] - // to be paused. + // until it is re-enabled via + // [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The + // state of the job is stored in + // [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set + // to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A + // job must be in + // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be + // paused. rpc PauseJob(PauseJobRequest) returns (Job) { option (google.api.http) = { post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:pause" @@ -104,10 +109,15 @@ service CloudScheduler { // Resume a job. // - // This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The - // state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it - // will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in - // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed. + // This method reenables a job after it has been + // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The + // state of a job is stored in + // [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this + // method it will be set to + // [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A + // job must be in + // [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be + // resumed. rpc ResumeJob(ResumeJobRequest) returns (Job) { option (google.api.http) = { post: "/v1beta1/{name=projects/*/locations/*/jobs/*}:resume" @@ -129,7 +139,8 @@ service CloudScheduler { } } -// Request message for listing jobs using [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. +// Request message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. message ListJobsRequest { // Required. The location name. For example: // `projects/PROJECT_ID/locations/LOCATION_ID`. @@ -140,6 +151,16 @@ message ListJobsRequest { } ]; + // `filter` can be used to specify a subset of jobs. + // + // If `filter` equals `target_config="HttpConfig"`, then the http + // target jobs are retrieved. If `filter` equals + // `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + // retrieved. If `filter` equals `labels.foo=value1 + // labels.foo=value2` then only jobs which are labeled with + // foo=value1 AND foo=value2 will be returned. + string filter = 4; + // Requested page size. // // The maximum page size is 500. If unspecified, the page size will @@ -151,29 +172,40 @@ message ListJobsRequest { // A token identifying a page of results the server will return. To // request the first page results, page_token must be empty. To // request the next page of results, page_token must be the value of - // [next_page_token][google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token] returned from - // the previous call to [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. It is an error to - // switch the value of [filter][google.cloud.scheduler.v1beta1.ListJobsRequest.filter] or - // [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while iterating through pages. + // [next_page_token][google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token] + // returned from the previous call to + // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. It is + // an error to switch the value of + // [filter][google.cloud.scheduler.v1beta1.ListJobsRequest.filter] or + // [order_by][google.cloud.scheduler.v1beta1.ListJobsRequest.order_by] while + // iterating through pages. string page_token = 6; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the jobs in the __cron + // queue will be listed instead. + bool legacy_app_engine_cron = 7; } -// Response message for listing jobs using [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. +// Response message for listing jobs using +// [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs]. message ListJobsResponse { // The list of jobs. repeated Job jobs = 1; // A token to retrieve next page of results. Pass this value in the - // [page_token][google.cloud.scheduler.v1beta1.ListJobsRequest.page_token] field in the subsequent call to - // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs] to retrieve the next page of results. - // If this is empty it indicates that there are no more results - // through which to paginate. + // [page_token][google.cloud.scheduler.v1beta1.ListJobsRequest.page_token] + // field in the subsequent call to + // [ListJobs][google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs] to + // retrieve the next page of results. If this is empty it indicates that there + // are no more results through which to paginate. // // The page token is valid for only 2 hours. string next_page_token = 2; } -// Request message for [GetJob][google.cloud.scheduler.v1beta1.CloudScheduler.GetJob]. +// Request message for +// [GetJob][google.cloud.scheduler.v1beta1.CloudScheduler.GetJob]. message GetJobRequest { // Required. The job name. For example: // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. @@ -185,7 +217,8 @@ message GetJobRequest { ]; } -// Request message for [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob]. +// Request message for +// [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob]. message CreateJobRequest { // Required. The location name. For example: // `projects/PROJECT_ID/locations/LOCATION_ID`. @@ -197,16 +230,19 @@ message CreateJobRequest { ]; // Required. The job to add. The user can optionally specify a name for the - // job in [name][google.cloud.scheduler.v1beta1.Job.name]. [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an + // job in [name][google.cloud.scheduler.v1beta1.Job.name]. + // [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an // existing job. If a name is not specified then the system will // generate a random unique name that will be returned // ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. Job job = 2 [(google.api.field_behavior) = REQUIRED]; } -// Request message for [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. +// Request message for +// [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. message UpdateJobRequest { - // Required. The new job properties. [name][google.cloud.scheduler.v1beta1.Job.name] must be specified. + // Required. The new job properties. + // [name][google.cloud.scheduler.v1beta1.Job.name] must be specified. // // Output only fields cannot be modified using UpdateJob. // Any value specified for an output only field will be ignored. @@ -227,9 +263,15 @@ message DeleteJobRequest { type: "cloudscheduler.googleapis.com/Job" } ]; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the job in the __cron + // queue with the corresponding name will be deleted instead. + bool legacy_app_engine_cron = 2; } -// Request message for [PauseJob][google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob]. +// Request message for +// [PauseJob][google.cloud.scheduler.v1beta1.CloudScheduler.PauseJob]. message PauseJobRequest { // Required. The job name. For example: // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. @@ -241,7 +283,8 @@ message PauseJobRequest { ]; } -// Request message for [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. +// Request message for +// [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. message ResumeJobRequest { // Required. The job name. For example: // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. @@ -264,4 +307,9 @@ message RunJobRequest { type: "cloudscheduler.googleapis.com/Job" } ]; + + // This field is used to manage the legacy App Engine Cron jobs using the + // Cloud Scheduler API. If the field is set to true, the job in the __cron + // queue with the corresponding name will be forced to run instead. + bool legacy_app_engine_cron = 2; } diff --git a/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/job.proto b/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/job.proto index 4e8e3777fc8..2353beecac8 100644 --- a/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/job.proto +++ b/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/job.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,12 +11,12 @@ // WITHOUT 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.scheduler.v1beta1; +import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/cloud/scheduler/v1beta1/target.proto"; import "google/protobuf/duration.proto"; @@ -29,7 +29,7 @@ option java_outer_classname = "JobProto"; option java_package = "com.google.cloud.scheduler.v1beta1"; // Configuration for a job. -// The maximum allowed size for a job is 100KB. +// The maximum allowed size for a job is 1MB. message Job { option (google.api.resource) = { type: "cloudscheduler.googleapis.com/Job" @@ -53,13 +53,16 @@ message Job { // cannot directly set a job to be disabled. DISABLED = 3; - // The job state resulting from a failed [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] + // The job state resulting from a failed + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] // operation. To recover a job from this state, retry - // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] until a successful response is received. + // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob] + // until a successful response is received. UPDATE_FAILED = 4; } - // Optionally caller-specified in [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after // which it becomes output only. // // The job name. For example: @@ -78,7 +81,8 @@ message Job { // hyphens (-), or underscores (_). The maximum length is 500 characters. string name = 1; - // Optionally caller-specified in [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or + // Optionally caller-specified in + // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. // // A human-readable description for the job. This string must not contain @@ -99,13 +103,14 @@ message Job { HttpTarget http_target = 6; } - // Required, except when used with [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. + // Required, except when used with + // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]. // // Describes the schedule on which the job will be executed. // // The schedule can be either of the following types: // - // * [Crontab](http://en.wikipedia.org/wiki/Cron#Overview) + // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) // * English-like // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) // @@ -118,15 +123,17 @@ message Job { // A scheduled start time will be delayed if the previous // execution has not ended when its scheduled time occurs. // - // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] > 0 and a job attempt fails, - // the job will be tried a total of [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] > + // 0 and a job attempt fails, the job will be tried a total of + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] // times, with exponential backoff, until the next scheduled start // time. string schedule = 20; // Specifies the time zone to be used in interpreting - // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this field must be a time - // zone name from the [tz database](http://en.wikipedia.org/wiki/Tz_database). + // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this + // field must be a time zone name from the [tz + // database](http://en.wikipedia.org/wiki/Tz_database). // // Note that some time zones include a provision for // daylight savings time. The rules for daylight saving time are @@ -161,20 +168,38 @@ message Job { // execution logs. Cloud Scheduler will retry the job according // to the [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. // - // The allowed duration for this deadline is: + // The default and the allowed values depend on the type of target: + // + // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], the + // default is 3 minutes. The deadline must be in the interval [15 seconds, 30 + // minutes]. // - // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], between 15 seconds and 30 minutes. - // * For [App Engine HTTP targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], between 15 - // seconds and 24 hours. - // * For [PubSub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target], this field is ignored. + // * For [App Engine HTTP + // targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], 0 + // indicates that the request has the default deadline. The default deadline + // depends on the scaling type of the service: 10 minutes for standard apps + // with automatic scaling, 24 hours for standard apps with manual and basic + // scaling, and 60 minutes for flex apps. If the request deadline is set, it + // must be in the interval [15 seconds, 24 hours 15 seconds]. + // + // * For [Pub/Sub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target], + // this field is ignored. google.protobuf.Duration attempt_deadline = 22; + + // Immutable. This field is used to manage the legacy App Engine Cron jobs + // using the Cloud Scheduler API. If the field is set to true, the job will be + // considered a legacy job. Note that App Engine Cron jobs have fewer + // features than Cloud Scheduler jobs, e.g., are only limited to App Engine + // targets. + bool legacy_app_engine_cron = 23 [(google.api.field_behavior) = IMMUTABLE]; } // Settings that determine the retry behavior. // // By default, if a job does not complete successfully (meaning that // an acknowledgement is not received from the handler, then it will be retried -// with exponential backoff according to the settings in [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. +// with exponential backoff according to the settings in +// [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig]. message RetryConfig { // The number of attempts that the system will make to run a job using the // exponential backoff procedure described by @@ -196,8 +221,8 @@ message RetryConfig { // The time limit for retrying a failed job, measured from time when an // execution was first attempted. If specified with - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the job will be retried until both - // limits are reached. + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the + // job will be retried until both limits are reached. // // The default value for max_retry_duration is zero, which means retry // duration is unlimited. @@ -218,20 +243,25 @@ message RetryConfig { // The time between retries will double `max_doublings` times. // // A job's retry interval starts at - // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration], then doubles - // `max_doublings` times, then increases linearly, and finally - // retries retries at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] up to - // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] times. - // - // For example, if [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration] is - // 10s, [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] is 300s, and - // `max_doublings` is 3, then the a job will first be retried in 10s. The - // retry interval will double three times, and then increase linearly by - // 2^3 * 10s. Finally, the job will retry at intervals of - // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] until the job has - // been attempted [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] times. Thus, the - // requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, .... + // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration], + // then doubles `max_doublings` times, then increases linearly, and finally + // retries at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // up to [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times. + // + // For example, if + // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration] + // is 10s, + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // is 300s, and `max_doublings` is 3, then the a job will first be retried in + // 10s. The retry interval will double three times, and then increase linearly + // by 2^3 * 10s. Finally, the job will retry at intervals of + // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration] + // until the job has been attempted + // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] + // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, + // 300s, 300s, .... // // The default value of this field is 5. int32 max_doublings = 5; diff --git a/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/target.proto b/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/target.proto index 7f5214f593e..f98f210dc40 100644 --- a/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/target.proto +++ b/packages/google-cloud-scheduler/protos/google/cloud/scheduler/v1beta1/target.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT 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"; @@ -23,10 +22,15 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1bet option java_multiple_files = true; option java_outer_classname = "TargetProto"; option java_package = "com.google.cloud.scheduler.v1beta1"; +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Topic" + pattern: "projects/{project}/topics/{topic}" +}; // Http target. The job will be pushed to the job handler by means of -// an HTTP request via an [http_method][google.cloud.scheduler.v1beta1.HttpTarget.http_method] such as HTTP -// POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// an HTTP request via an +// [http_method][google.cloud.scheduler.v1beta1.HttpTarget.http_method] such as +// HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP // response code in the range [200 - 299]. A failure to receive a response // constitutes a failed execution. For a redirected request, the response // returned by the redirected request is considered. @@ -55,6 +59,11 @@ message HttpTarget { // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. // * `X-Google-*`: Google internal use only. // * `X-AppEngine-*`: Google internal use only. + // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. // // The total size of headers must be less than 80KB. map headers = 3; @@ -66,7 +75,8 @@ message HttpTarget { // The mode for generating an `Authorization` header for HTTP requests. // - // If specified, all `Authorization` headers in the [HttpTarget.headers][google.cloud.scheduler.v1beta1.HttpTarget.headers] + // If specified, all `Authorization` headers in the + // [HttpTarget.headers][google.cloud.scheduler.v1beta1.HttpTarget.headers] // field will be overridden. oneof authorization_header { // If specified, an @@ -91,14 +101,14 @@ message HttpTarget { } // App Engine target. The job will be pushed to a job handler by means -// of an HTTP request via an [http_method][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.http_method] such -// as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an -// HTTP response code in the range [200 - 299]. Error 503 is -// considered an App Engine system error instead of an application -// error. Requests returning error 503 will be retried regardless of -// retry configuration and not counted against retry counts. Any other -// response code, or a failure to receive a response before the -// deadline, constitutes a failed attempt. +// of an HTTP request via an +// [http_method][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.http_method] +// such as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an HTTP +// response code in the range [200 - 299]. Error 503 is considered an App Engine +// system error instead of an application error. Requests returning error 503 +// will be retried regardless of retry configuration and not counted against +// retry counts. Any other response code, or a failure to receive a response +// before the deadline, constitutes a failed attempt. message AppEngineHttpTarget { // The HTTP method to use for the request. PATCH and OPTIONS are not // permitted. @@ -128,9 +138,14 @@ message AppEngineHttpTarget { // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the // modified `User-Agent`. // * `X-CloudScheduler`: This header will be set to true. + // * `X-CloudScheduler-JobName`: This header will contain the job name. + // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in + // the unix-cron format, this header will contain the job schedule time in + // RFC3339 UTC "Zulu" format. // - // If the job has an [body][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.body], Cloud Scheduler sets - // the following headers: + // If the job has an + // [body][google.cloud.scheduler.v1beta1.AppEngineHttpTarget.body], Cloud + // Scheduler sets the following headers: // // * `Content-Type`: By default, the `Content-Type` header is set to // `"application/octet-stream"`. The default can be overridden by explictly @@ -153,7 +168,8 @@ message AppEngineHttpTarget { // // HTTP request body. A request body is allowed only if the HTTP method is // POST or PUT. It will result in invalid argument error to set a body on a - // job with an incompatible [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. + // job with an incompatible + // [HttpMethod][google.cloud.scheduler.v1beta1.HttpMethod]. bytes body = 5; } @@ -162,14 +178,14 @@ message AppEngineHttpTarget { message PubsubTarget { // Required. The name of the Cloud Pub/Sub topic to which messages will // be published when a job is delivered. The topic name must be in the - // same format as required by PubSub's + // same format as required by Pub/Sub's // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), // for example `projects/PROJECT_ID/topics/TOPIC_ID`. // // The topic must be in the same project as the Cloud Scheduler job. - string topic_name = 1 [(google.api.resource_reference) = { - type: "pubsub.googleapis.com/Topic" - }]; + string topic_name = 1 [ + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } + ]; // The message payload for PubsubMessage. // @@ -215,7 +231,7 @@ message AppEngineRouting { // // Requests can only be sent to a specific instance if // [manual scaling is used in App Engine - // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes). + // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). // App Engine Flex does not support instances. For more information, see // [App Engine Standard request // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) @@ -244,43 +260,51 @@ message AppEngineRouting { // example .appspot.com, which is associated with the // job's project ID. // - // * `service =` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // * `service =` + // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] // - // * `version =` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // * `version =` + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] // // * `version_dot_service =` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' +` - // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' + // +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] // - // * `instance =` [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] + // * `instance =` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] // // * `instance_dot_service =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ '.' +` - // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] // // * `instance_dot_version =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ '.' +` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] // // * `instance_dot_version_dot_service =` - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ '.' +` - // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] `+ '.' +` + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] `+ + // '.' +` [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] + // `+ '.' +` // [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] // // - // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] is empty, then the job will be sent - // to the service which is the default service when the job is attempted. + // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service] is + // empty, then the job will be sent to the service which is the default + // service when the job is attempted. // - // If [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] is empty, then the job will be sent - // to the version which is the default version when the job is attempted. + // If [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version] is + // empty, then the job will be sent to the version which is the default + // version when the job is attempted. // - // If [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is empty, then the job will be - // sent to an instance which is available when the job is attempted. + // If [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is + // empty, then the job will be sent to an instance which is available when the + // job is attempted. // // If [service][google.cloud.scheduler.v1beta1.AppEngineRouting.service], // [version][google.cloud.scheduler.v1beta1.AppEngineRouting.version], or - // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is invalid, then the job will be sent - // to the default version of the default service when the job is attempted. + // [instance][google.cloud.scheduler.v1beta1.AppEngineRouting.instance] is + // invalid, then the job will be sent to the default version of the default + // service when the job is attempted. string host = 4; } @@ -345,11 +369,3 @@ message OidcToken { // specified in target will be used. string audience = 2; } - -// The Pub/Sub Topic resource definition is in google/cloud/pubsub/v1/, -// but we do not import that proto directly; therefore, we redefine the -// pattern here. -option (google.api.resource_definition) = { - type: "pubsub.googleapis.com/Topic" - pattern: "projects/{project}/topics/{topic}" -}; diff --git a/packages/google-cloud-scheduler/protos/protos.d.ts b/packages/google-cloud-scheduler/protos/protos.d.ts index c6025b8fd44..753abac7bde 100644 --- a/packages/google-cloud-scheduler/protos/protos.d.ts +++ b/packages/google-cloud-scheduler/protos/protos.d.ts @@ -2327,11 +2327,17 @@ export namespace google { /** ListJobsRequest parent */ parent?: (string|null); + /** ListJobsRequest filter */ + filter?: (string|null); + /** ListJobsRequest pageSize */ pageSize?: (number|null); /** ListJobsRequest pageToken */ pageToken?: (string|null); + + /** ListJobsRequest legacyAppEngineCron */ + legacyAppEngineCron?: (boolean|null); } /** Represents a ListJobsRequest. */ @@ -2346,12 +2352,18 @@ export namespace google { /** ListJobsRequest parent. */ public parent: string; + /** ListJobsRequest filter. */ + public filter: string; + /** ListJobsRequest pageSize. */ public pageSize: number; /** ListJobsRequest pageToken. */ public pageToken: string; + /** ListJobsRequest legacyAppEngineCron. */ + public legacyAppEngineCron: boolean; + /** * Creates a new ListJobsRequest instance using the specified properties. * @param [properties] Properties to set @@ -2841,6 +2853,9 @@ export namespace google { /** DeleteJobRequest name */ name?: (string|null); + + /** DeleteJobRequest legacyAppEngineCron */ + legacyAppEngineCron?: (boolean|null); } /** Represents a DeleteJobRequest. */ @@ -2855,6 +2870,9 @@ export namespace google { /** DeleteJobRequest name. */ public name: string; + /** DeleteJobRequest legacyAppEngineCron. */ + public legacyAppEngineCron: boolean; + /** * Creates a new DeleteJobRequest instance using the specified properties. * @param [properties] Properties to set @@ -3132,6 +3150,9 @@ export namespace google { /** RunJobRequest name */ name?: (string|null); + + /** RunJobRequest legacyAppEngineCron */ + legacyAppEngineCron?: (boolean|null); } /** Represents a RunJobRequest. */ @@ -3146,6 +3167,9 @@ export namespace google { /** RunJobRequest name. */ public name: string; + /** RunJobRequest legacyAppEngineCron. */ + public legacyAppEngineCron: boolean; + /** * Creates a new RunJobRequest instance using the specified properties. * @param [properties] Properties to set @@ -3268,6 +3292,9 @@ export namespace google { /** Job attemptDeadline */ attemptDeadline?: (google.protobuf.IDuration|null); + + /** Job legacyAppEngineCron */ + legacyAppEngineCron?: (boolean|null); } /** Represents a Job. */ @@ -3321,6 +3348,9 @@ export namespace google { /** Job attemptDeadline. */ public attemptDeadline?: (google.protobuf.IDuration|null); + /** Job legacyAppEngineCron. */ + public legacyAppEngineCron: boolean; + /** Job target. */ public target?: ("pubsubTarget"|"appEngineHttpTarget"|"httpTarget"); diff --git a/packages/google-cloud-scheduler/protos/protos.js b/packages/google-cloud-scheduler/protos/protos.js index ab1f99bc4c2..6dbc724169f 100644 --- a/packages/google-cloud-scheduler/protos/protos.js +++ b/packages/google-cloud-scheduler/protos/protos.js @@ -5505,8 +5505,10 @@ * @memberof google.cloud.scheduler.v1beta1 * @interface IListJobsRequest * @property {string|null} [parent] ListJobsRequest parent + * @property {string|null} [filter] ListJobsRequest filter * @property {number|null} [pageSize] ListJobsRequest pageSize * @property {string|null} [pageToken] ListJobsRequest pageToken + * @property {boolean|null} [legacyAppEngineCron] ListJobsRequest legacyAppEngineCron */ /** @@ -5532,6 +5534,14 @@ */ ListJobsRequest.prototype.parent = ""; + /** + * ListJobsRequest filter. + * @member {string} filter + * @memberof google.cloud.scheduler.v1beta1.ListJobsRequest + * @instance + */ + ListJobsRequest.prototype.filter = ""; + /** * ListJobsRequest pageSize. * @member {number} pageSize @@ -5548,6 +5558,14 @@ */ ListJobsRequest.prototype.pageToken = ""; + /** + * ListJobsRequest legacyAppEngineCron. + * @member {boolean} legacyAppEngineCron + * @memberof google.cloud.scheduler.v1beta1.ListJobsRequest + * @instance + */ + ListJobsRequest.prototype.legacyAppEngineCron = false; + /** * Creates a new ListJobsRequest instance using the specified properties. * @function create @@ -5574,10 +5592,14 @@ writer = $Writer.create(); if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.pageSize); if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.pageToken); + if (message.legacyAppEngineCron != null && Object.hasOwnProperty.call(message, "legacyAppEngineCron")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.legacyAppEngineCron); return writer; }; @@ -5616,6 +5638,10 @@ message.parent = reader.string(); break; } + case 4: { + message.filter = reader.string(); + break; + } case 5: { message.pageSize = reader.int32(); break; @@ -5624,6 +5650,10 @@ message.pageToken = reader.string(); break; } + case 7: { + message.legacyAppEngineCron = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -5662,12 +5692,18 @@ if (message.parent != null && message.hasOwnProperty("parent")) if (!$util.isString(message.parent)) return "parent: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; if (message.pageSize != null && message.hasOwnProperty("pageSize")) if (!$util.isInteger(message.pageSize)) return "pageSize: integer expected"; if (message.pageToken != null && message.hasOwnProperty("pageToken")) if (!$util.isString(message.pageToken)) return "pageToken: string expected"; + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + if (typeof message.legacyAppEngineCron !== "boolean") + return "legacyAppEngineCron: boolean expected"; return null; }; @@ -5685,10 +5721,14 @@ var message = new $root.google.cloud.scheduler.v1beta1.ListJobsRequest(); if (object.parent != null) message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); if (object.pageSize != null) message.pageSize = object.pageSize | 0; if (object.pageToken != null) message.pageToken = String(object.pageToken); + if (object.legacyAppEngineCron != null) + message.legacyAppEngineCron = Boolean(object.legacyAppEngineCron); return message; }; @@ -5707,15 +5747,21 @@ var object = {}; if (options.defaults) { object.parent = ""; + object.filter = ""; object.pageSize = 0; object.pageToken = ""; + object.legacyAppEngineCron = false; } if (message.parent != null && message.hasOwnProperty("parent")) object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; if (message.pageSize != null && message.hasOwnProperty("pageSize")) object.pageSize = message.pageSize; if (message.pageToken != null && message.hasOwnProperty("pageToken")) object.pageToken = message.pageToken; + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + object.legacyAppEngineCron = message.legacyAppEngineCron; return object; }; @@ -6675,6 +6721,7 @@ * @memberof google.cloud.scheduler.v1beta1 * @interface IDeleteJobRequest * @property {string|null} [name] DeleteJobRequest name + * @property {boolean|null} [legacyAppEngineCron] DeleteJobRequest legacyAppEngineCron */ /** @@ -6700,6 +6747,14 @@ */ DeleteJobRequest.prototype.name = ""; + /** + * DeleteJobRequest legacyAppEngineCron. + * @member {boolean} legacyAppEngineCron + * @memberof google.cloud.scheduler.v1beta1.DeleteJobRequest + * @instance + */ + DeleteJobRequest.prototype.legacyAppEngineCron = false; + /** * Creates a new DeleteJobRequest instance using the specified properties. * @function create @@ -6726,6 +6781,8 @@ writer = $Writer.create(); if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.legacyAppEngineCron != null && Object.hasOwnProperty.call(message, "legacyAppEngineCron")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.legacyAppEngineCron); return writer; }; @@ -6764,6 +6821,10 @@ message.name = reader.string(); break; } + case 2: { + message.legacyAppEngineCron = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -6802,6 +6863,9 @@ if (message.name != null && message.hasOwnProperty("name")) if (!$util.isString(message.name)) return "name: string expected"; + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + if (typeof message.legacyAppEngineCron !== "boolean") + return "legacyAppEngineCron: boolean expected"; return null; }; @@ -6819,6 +6883,8 @@ var message = new $root.google.cloud.scheduler.v1beta1.DeleteJobRequest(); if (object.name != null) message.name = String(object.name); + if (object.legacyAppEngineCron != null) + message.legacyAppEngineCron = Boolean(object.legacyAppEngineCron); return message; }; @@ -6835,10 +6901,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.name = ""; + object.legacyAppEngineCron = false; + } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + object.legacyAppEngineCron = message.legacyAppEngineCron; return object; }; @@ -7284,6 +7354,7 @@ * @memberof google.cloud.scheduler.v1beta1 * @interface IRunJobRequest * @property {string|null} [name] RunJobRequest name + * @property {boolean|null} [legacyAppEngineCron] RunJobRequest legacyAppEngineCron */ /** @@ -7309,6 +7380,14 @@ */ RunJobRequest.prototype.name = ""; + /** + * RunJobRequest legacyAppEngineCron. + * @member {boolean} legacyAppEngineCron + * @memberof google.cloud.scheduler.v1beta1.RunJobRequest + * @instance + */ + RunJobRequest.prototype.legacyAppEngineCron = false; + /** * Creates a new RunJobRequest instance using the specified properties. * @function create @@ -7335,6 +7414,8 @@ writer = $Writer.create(); if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.legacyAppEngineCron != null && Object.hasOwnProperty.call(message, "legacyAppEngineCron")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.legacyAppEngineCron); return writer; }; @@ -7373,6 +7454,10 @@ message.name = reader.string(); break; } + case 2: { + message.legacyAppEngineCron = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -7411,6 +7496,9 @@ if (message.name != null && message.hasOwnProperty("name")) if (!$util.isString(message.name)) return "name: string expected"; + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + if (typeof message.legacyAppEngineCron !== "boolean") + return "legacyAppEngineCron: boolean expected"; return null; }; @@ -7428,6 +7516,8 @@ var message = new $root.google.cloud.scheduler.v1beta1.RunJobRequest(); if (object.name != null) message.name = String(object.name); + if (object.legacyAppEngineCron != null) + message.legacyAppEngineCron = Boolean(object.legacyAppEngineCron); return message; }; @@ -7444,10 +7534,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.name = ""; + object.legacyAppEngineCron = false; + } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + object.legacyAppEngineCron = message.legacyAppEngineCron; return object; }; @@ -7500,6 +7594,7 @@ * @property {google.protobuf.ITimestamp|null} [lastAttemptTime] Job lastAttemptTime * @property {google.cloud.scheduler.v1beta1.IRetryConfig|null} [retryConfig] Job retryConfig * @property {google.protobuf.IDuration|null} [attemptDeadline] Job attemptDeadline + * @property {boolean|null} [legacyAppEngineCron] Job legacyAppEngineCron */ /** @@ -7629,6 +7724,14 @@ */ Job.prototype.attemptDeadline = null; + /** + * Job legacyAppEngineCron. + * @member {boolean} legacyAppEngineCron + * @memberof google.cloud.scheduler.v1beta1.Job + * @instance + */ + Job.prototype.legacyAppEngineCron = false; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -7695,6 +7798,8 @@ writer.uint32(/* id 21, wireType 2 =*/170).string(message.timeZone); if (message.attemptDeadline != null && Object.hasOwnProperty.call(message, "attemptDeadline")) $root.google.protobuf.Duration.encode(message.attemptDeadline, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + if (message.legacyAppEngineCron != null && Object.hasOwnProperty.call(message, "legacyAppEngineCron")) + writer.uint32(/* id 23, wireType 0 =*/184).bool(message.legacyAppEngineCron); return writer; }; @@ -7785,6 +7890,10 @@ message.attemptDeadline = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 23: { + message.legacyAppEngineCron = reader.bool(); + break; + } default: reader.skipType(tag & 7); break; @@ -7902,6 +8011,9 @@ if (error) return "attemptDeadline." + error; } + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + if (typeof message.legacyAppEngineCron !== "boolean") + return "legacyAppEngineCron: boolean expected"; return null; }; @@ -7998,6 +8110,8 @@ throw TypeError(".google.cloud.scheduler.v1beta1.Job.attemptDeadline: object expected"); message.attemptDeadline = $root.google.protobuf.Duration.fromObject(object.attemptDeadline); } + if (object.legacyAppEngineCron != null) + message.legacyAppEngineCron = Boolean(object.legacyAppEngineCron); return message; }; @@ -8026,6 +8140,7 @@ object.schedule = ""; object.timeZone = ""; object.attemptDeadline = null; + object.legacyAppEngineCron = false; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -8064,6 +8179,8 @@ object.timeZone = message.timeZone; if (message.attemptDeadline != null && message.hasOwnProperty("attemptDeadline")) object.attemptDeadline = $root.google.protobuf.Duration.toObject(message.attemptDeadline, options); + if (message.legacyAppEngineCron != null && message.hasOwnProperty("legacyAppEngineCron")) + object.legacyAppEngineCron = message.legacyAppEngineCron; return object; }; diff --git a/packages/google-cloud-scheduler/protos/protos.json b/packages/google-cloud-scheduler/protos/protos.json index f55e341acfc..b3e634937fa 100644 --- a/packages/google-cloud-scheduler/protos/protos.json +++ b/packages/google-cloud-scheduler/protos/protos.json @@ -740,6 +740,10 @@ "(google.api.resource_reference).child_type": "cloudscheduler.googleapis.com/Job" } }, + "filter": { + "type": "string", + "id": 4 + }, "pageSize": { "type": "int32", "id": 5 @@ -747,6 +751,10 @@ "pageToken": { "type": "string", "id": 6 + }, + "legacyAppEngineCron": { + "type": "bool", + "id": 7 } } }, @@ -818,6 +826,10 @@ "(google.api.field_behavior)": "REQUIRED", "(google.api.resource_reference).type": "cloudscheduler.googleapis.com/Job" } + }, + "legacyAppEngineCron": { + "type": "bool", + "id": 2 } } }, @@ -854,6 +866,10 @@ "(google.api.field_behavior)": "REQUIRED", "(google.api.resource_reference).type": "cloudscheduler.googleapis.com/Job" } + }, + "legacyAppEngineCron": { + "type": "bool", + "id": 2 } } }, @@ -927,6 +943,13 @@ "attemptDeadline": { "type": "google.protobuf.Duration", "id": 22 + }, + "legacyAppEngineCron": { + "type": "bool", + "id": 23, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } } }, "nested": { diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.create_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.create_job.js index 6cdf34ced6c..92de5253bd7 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.create_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.create_job.js @@ -35,7 +35,8 @@ function main(parent, job) { // const parent = 'abc123' /** * Required. The job to add. The user can optionally specify a name for the - * job in name google.cloud.scheduler.v1beta1.Job.name. name google.cloud.scheduler.v1beta1.Job.name cannot be the same as an + * job in name google.cloud.scheduler.v1beta1.Job.name. + * name google.cloud.scheduler.v1beta1.Job.name cannot be the same as an * existing job. If a name is not specified then the system will * generate a random unique name that will be returned * (name google.cloud.scheduler.v1beta1.Job.name) in the response. diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.delete_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.delete_job.js index b717956a701..b2d7fd2a8ad 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.delete_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.delete_job.js @@ -33,6 +33,12 @@ function main(name) { * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. */ // const name = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be deleted instead. + */ + // const legacyAppEngineCron = true // Imports the Scheduler library const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.list_jobs.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.list_jobs.js index 1816fd87239..7ae9366e802 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.list_jobs.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.list_jobs.js @@ -33,6 +33,16 @@ function main(parent) { * `projects/PROJECT_ID/locations/LOCATION_ID`. */ // const parent = 'abc123' + /** + * `filter` can be used to specify a subset of jobs. + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. + */ + // const filter = 'abc123' /** * Requested page size. * The maximum page size is 500. If unspecified, the page size will @@ -45,12 +55,21 @@ function main(parent) { * A token identifying a page of results the server will return. To * request the first page results, page_token must be empty. To * request the next page of results, page_token must be the value of - * next_page_token google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token returned from - * the previous call to ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is an error to - * switch the value of filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter or - * order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by while iterating through pages. + * next_page_token google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token + * returned from the previous call to + * ListJobs google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs. It is + * an error to switch the value of + * filter google.cloud.scheduler.v1beta1.ListJobsRequest.filter or + * order_by google.cloud.scheduler.v1beta1.ListJobsRequest.order_by while + * iterating through pages. */ // const pageToken = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. + */ + // const legacyAppEngineCron = true // Imports the Scheduler library const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.run_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.run_job.js index 9679e69cc6c..52f869a91e7 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.run_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.run_job.js @@ -33,6 +33,12 @@ function main(name) { * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. */ // const name = 'abc123' + /** + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be forced to run instead. + */ + // const legacyAppEngineCron = true // Imports the Scheduler library const {CloudSchedulerClient} = require('@google-cloud/scheduler').v1beta1; diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.update_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.update_job.js index e81032ce508..ed9680f11c9 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.update_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.update_job.js @@ -29,7 +29,8 @@ function main(job) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. The new job properties. name google.cloud.scheduler.v1beta1.Job.name must be specified. + * Required. The new job properties. + * name google.cloud.scheduler.v1beta1.Job.name must be specified. * Output only fields cannot be modified using UpdateJob. * Any value specified for an output only field will be ignored. */ diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json b/packages/google-cloud-scheduler/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json index f58952b1741..908708d74f5 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 74, + "end": 93, "type": "FULL" } ], @@ -35,6 +35,10 @@ "name": "parent", "type": "TYPE_STRING" }, + { + "name": "filter", + "type": "TYPE_STRING" + }, { "name": "page_size", "type": "TYPE_INT32" @@ -42,6 +46,10 @@ { "name": "page_token", "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" } ], "resultType": ".google.cloud.scheduler.v1beta1.ListJobsResponse", @@ -110,7 +118,7 @@ "segments": [ { "start": 25, - "end": 63, + "end": 64, "type": "FULL" } ], @@ -154,7 +162,7 @@ "segments": [ { "start": 25, - "end": 59, + "end": 60, "type": "FULL" } ], @@ -198,7 +206,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 60, "type": "FULL" } ], @@ -210,6 +218,10 @@ { "name": "name", "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" } ], "resultType": ".google.protobuf.Empty", @@ -318,7 +330,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 60, "type": "FULL" } ], @@ -330,6 +342,10 @@ { "name": "name", "type": "TYPE_STRING" + }, + { + "name": "legacy_app_engine_cron", + "type": "TYPE_BOOL" } ], "resultType": ".google.cloud.scheduler.v1beta1.Job", diff --git a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts index 8da2f136471..fabf0b72824 100644 --- a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts @@ -121,6 +121,9 @@ export class CloudSchedulerClient { (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; diff --git a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts index 1bc4ecbca0d..d822e93df5c 100644 --- a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts @@ -25,6 +25,8 @@ import type { ClientOptions, PaginationCallback, GaxCall, + LocationsClient, + LocationProtos, } from 'google-gax'; import {Transform} from 'stream'; import * as protos from '../../protos/protos'; @@ -60,6 +62,7 @@ export class CloudSchedulerClient { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; cloudSchedulerStub?: Promise<{[name: string]: Function}>; @@ -121,6 +124,9 @@ export class CloudSchedulerClient { (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; @@ -153,6 +159,10 @@ export class CloudSchedulerClient { 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}`]; @@ -435,7 +445,8 @@ export class CloudSchedulerClient { * `projects/PROJECT_ID/locations/LOCATION_ID`. * @param {google.cloud.scheduler.v1beta1.Job} request.job * Required. The job to add. The user can optionally specify a name for the - * job in {@link google.cloud.scheduler.v1beta1.Job.name|name}. {@link google.cloud.scheduler.v1beta1.Job.name|name} cannot be the same as an + * job in {@link google.cloud.scheduler.v1beta1.Job.name|name}. + * {@link google.cloud.scheduler.v1beta1.Job.name|name} cannot be the same as an * existing job. If a name is not specified then the system will * generate a random unique name that will be returned * ({@link google.cloud.scheduler.v1beta1.Job.name|name}) in the response. @@ -526,18 +537,20 @@ export class CloudSchedulerClient { /** * Updates a job. * - * If successful, the updated {@link google.cloud.scheduler.v1beta1.Job|Job} is returned. If the job does - * not exist, `NOT_FOUND` is returned. + * If successful, the updated {@link google.cloud.scheduler.v1beta1.Job|Job} is + * returned. If the job does not exist, `NOT_FOUND` is returned. * * If UpdateJob does not successfully return, it is possible for the - * job to be in an {@link google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} state. A job in this state may - * not be executed. If this happens, retry the UpdateJob request - * until a successful response is received. + * job to be in an + * {@link google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED|Job.State.UPDATE_FAILED} + * state. A job in this state may not be executed. If this happens, retry the + * UpdateJob request until a successful response is received. * * @param {Object} request * The request object that will be sent. * @param {google.cloud.scheduler.v1beta1.Job} request.job - * Required. The new job properties. {@link google.cloud.scheduler.v1beta1.Job.name|name} must be specified. + * Required. The new job properties. + * {@link google.cloud.scheduler.v1beta1.Job.name|name} must be specified. * * Output only fields cannot be modified using UpdateJob. * Any value specified for an output only field will be ignored. @@ -635,6 +648,10 @@ export class CloudSchedulerClient { * @param {string} request.name * Required. The job name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be deleted instead. * @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. @@ -723,10 +740,14 @@ export class CloudSchedulerClient { * Pauses a job. * * If a job is paused then the system will stop executing the job - * until it is re-enabled via {@link google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The - * state of the job is stored in {@link google.cloud.scheduler.v1beta1.Job.state|state}; if paused it - * will be set to {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A job must be in {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} - * to be paused. + * until it is re-enabled via + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob|ResumeJob}. The + * state of the job is stored in + * {@link google.cloud.scheduler.v1beta1.Job.state|state}; if paused it will be set + * to {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. A + * job must be in + * {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED} to be + * paused. * * @param {Object} request * The request object that will be sent. @@ -814,10 +835,15 @@ export class CloudSchedulerClient { /** * Resume a job. * - * This method reenables a job after it has been {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The - * state of a job is stored in {@link google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this method it - * will be set to {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A job must be in - * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be resumed. + * This method reenables a job after it has been + * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED}. The + * state of a job is stored in + * {@link google.cloud.scheduler.v1beta1.Job.state|Job.state}; after calling this + * method it will be set to + * {@link google.cloud.scheduler.v1beta1.Job.State.ENABLED|Job.State.ENABLED}. A + * job must be in + * {@link google.cloud.scheduler.v1beta1.Job.State.PAUSED|Job.State.PAUSED} to be + * resumed. * * @param {Object} request * The request object that will be sent. @@ -919,6 +945,10 @@ export class CloudSchedulerClient { * @param {string} request.name * Required. The job name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the job in the __cron + * queue with the corresponding name will be forced to run instead. * @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. @@ -1006,6 +1036,15 @@ export class CloudSchedulerClient { * @param {string} request.parent * Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. * @param {number} request.pageSize * Requested page size. * @@ -1017,10 +1056,17 @@ export class CloudSchedulerClient { * A token identifying a page of results the server will return. To * request the first page results, page_token must be empty. To * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. * @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. @@ -1116,6 +1162,15 @@ export class CloudSchedulerClient { * @param {string} request.parent * Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. * @param {number} request.pageSize * Requested page size. * @@ -1127,10 +1182,17 @@ export class CloudSchedulerClient { * A token identifying a page of results the server will return. To * request the first page results, page_token must be empty. To * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1174,6 +1236,15 @@ export class CloudSchedulerClient { * @param {string} request.parent * Required. The location name. For example: * `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param {string} request.filter + * `filter` can be used to specify a subset of jobs. + * + * If `filter` equals `target_config="HttpConfig"`, then the http + * target jobs are retrieved. If `filter` equals + * `target_config="PubSubConfig"`, then the Pub/Sub target jobs are + * retrieved. If `filter` equals `labels.foo=value1 + * labels.foo=value2` then only jobs which are labeled with + * foo=value1 AND foo=value2 will be returned. * @param {number} request.pageSize * Requested page size. * @@ -1185,10 +1256,17 @@ export class CloudSchedulerClient { * A token identifying a page of results the server will return. To * request the first page results, page_token must be empty. To * request the next page of results, page_token must be the value of - * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} returned from - * the previous call to {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is an error to - * switch the value of {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or - * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while iterating through pages. + * {@link google.cloud.scheduler.v1beta1.ListJobsResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link google.cloud.scheduler.v1beta1.CloudScheduler.ListJobs|ListJobs}. It is + * an error to switch the value of + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.filter|filter} or + * {@link google.cloud.scheduler.v1beta1.ListJobsRequest.order_by|order_by} while + * iterating through pages. + * @param {boolean} request.legacyAppEngineCron + * This field is used to manage the legacy App Engine Cron jobs using the + * Cloud Scheduler API. If the field is set to true, the jobs in the __cron + * queue will be listed instead. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} @@ -1223,6 +1301,86 @@ export class CloudSchedulerClient { callSettings ) as AsyncIterable; } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + // -------------------- // -- Path templates -- // -------------------- @@ -1346,6 +1504,7 @@ export class CloudSchedulerClient { return this.cloudSchedulerStub.then(stub => { this._terminated = true; stub.close(); + this.locationsClient.close(); }); } return Promise.resolve(); diff --git a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts index 6a48e9a07c2..f0fcb4d46b5 100644 --- a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts +++ b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts @@ -25,7 +25,7 @@ import * as cloudschedulerModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1419,6 +1419,204 @@ describe('v1beta1.CloudSchedulerClient', () => { ); }); }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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 cloudschedulerModule.v1beta1.CloudSchedulerClient({ + 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('Path templates', () => { describe('job', () => {