From 663491f18e9a6c4c1f6ad310fbc589fcfea2c404 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 18 Feb 2022 02:00:52 +0000 Subject: [PATCH] docs(samples): include metadata file, add exclusions for samples to handwritten libraries (#433) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 429395631 Source-Link: https://github.com/googleapis/googleapis/commit/84594b35af0c38efcd6967e8179d801702ad96ff Source-Link: https://github.com/googleapis/googleapis-gen/commit/ed74f970fd82914874e6b27b04763cfa66bafe9b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWQ3NGY5NzBmZDgyOTE0ODc0ZTZiMjdiMDQ3NjNjZmE2NmJhZmU5YiJ9 --- .../v1/cloud_scheduler.create_job.js | 9 +- .../v1/cloud_scheduler.delete_job.js | 9 +- .../generated/v1/cloud_scheduler.get_job.js | 9 +- .../generated/v1/cloud_scheduler.list_jobs.js | 9 +- .../generated/v1/cloud_scheduler.pause_job.js | 9 +- .../v1/cloud_scheduler.resume_job.js | 9 +- .../generated/v1/cloud_scheduler.run_job.js | 9 +- .../v1/cloud_scheduler.update_job.js | 9 +- ...et_metadata.google.cloud.scheduler.v1.json | 351 ++++++++++++++++++ .../v1beta1/cloud_scheduler.create_job.js | 9 +- .../v1beta1/cloud_scheduler.delete_job.js | 9 +- .../v1beta1/cloud_scheduler.get_job.js | 9 +- .../v1beta1/cloud_scheduler.list_jobs.js | 9 +- .../v1beta1/cloud_scheduler.pause_job.js | 9 +- .../v1beta1/cloud_scheduler.resume_job.js | 9 +- .../v1beta1/cloud_scheduler.run_job.js | 9 +- .../v1beta1/cloud_scheduler.update_job.js | 9 +- ...tadata.google.cloud.scheduler.v1beta1.json | 351 ++++++++++++++++++ .../src/v1/cloud_scheduler_client.ts | 5 +- .../src/v1beta1/cloud_scheduler_client.ts | 5 +- .../test/gapic_cloud_scheduler_v1.ts | 132 ++++++- .../test/gapic_cloud_scheduler_v1beta1.ts | 132 ++++++- 22 files changed, 1078 insertions(+), 42 deletions(-) create mode 100644 packages/google-cloud-scheduler/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json create mode 100644 packages/google-cloud-scheduler/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.create_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.create_job.js index 75aa60b3b70..dc4e3298b8e 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.create_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.create_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.delete_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.delete_job.js index e985eefd0b2..2ae2138f29f 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.delete_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.delete_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.get_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.get_job.js index fb58d73397a..703bf350a94 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.get_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.get_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.list_jobs.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.list_jobs.js index c000731cb06..a4d03886fec 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.list_jobs.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.list_jobs.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.pause_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.pause_job.js index c070e05ba1e..0e62ba6b199 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.pause_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.pause_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.resume_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.resume_job.js index 06b60907286..c0f46a383fd 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.resume_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.resume_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.run_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.run_job.js index 3dcef2755b5..0bb49fa3952 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.run_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.run_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.update_job.js b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.update_job.js index 18bc1b4072f..9cc3a2d97bc 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.update_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1/cloud_scheduler.update_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json b/packages/google-cloud-scheduler/samples/generated/v1/snippet_metadata.google.cloud.scheduler.v1.json new file mode 100644 index 00000000000..03cbbd4d215 --- /dev/null +++ b/packages/google-cloud-scheduler/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": 71, + "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": 51, + "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": 60, + "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": 57, + "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": 51, + "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": 51, + "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": 51, + "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": 51, + "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/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 2eec4e3dc3a..5d37a2b781a 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 @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; 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 82c08c64b16..4c014fcdee6 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 @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.get_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.get_job.js index 9f9a8b95abd..d4bd38b5400 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.get_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.get_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; 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 155ecccbecc..8e7cb16926a 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 @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.pause_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.pause_job.js index 69cf16f1523..f41b73a26dc 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.pause_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.pause_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.resume_job.js b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.resume_job.js index 3e19357a8eb..6b25da709d0 100644 --- a/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.resume_job.js +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/cloud_scheduler.resume_job.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; 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 2389c1c3d22..8af730f3e54 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 @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; 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 1bc7258447e..e79d824703d 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 @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; 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 new file mode 100644 index 00000000000..8999f5973e2 --- /dev/null +++ b/packages/google-cloud-scheduler/samples/generated/v1beta1/snippet_metadata.google.cloud.scheduler.v1beta1.json @@ -0,0 +1,351 @@ +{ + "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": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListJobs", + "fullName": "google.cloud.scheduler.v1beta1.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.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": 51, + "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": 60, + "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": 56, + "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": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.DeleteJob", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "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": 51, + "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": 51, + "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": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", + "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": "RunJob", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler.RunJob", + "service": { + "shortName": "CloudScheduler", + "fullName": "google.cloud.scheduler.v1beta1.CloudScheduler" + } + } + } + } + ] +} 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 bbedfcf93ad..d1dbafe92cd 100644 --- a/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1/cloud_scheduler_client.ts @@ -1284,9 +1284,8 @@ export class CloudSchedulerClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.cloudSchedulerStub!.then(stub => { + if (this.cloudSchedulerStub && !this._terminated) { + return this.cloudSchedulerStub.then(stub => { this._terminated = true; stub.close(); }); 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 85517ae4124..3377fd8c1bc 100644 --- a/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts +++ b/packages/google-cloud-scheduler/src/v1beta1/cloud_scheduler_client.ts @@ -1330,9 +1330,8 @@ export class CloudSchedulerClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.cloudSchedulerStub!.then(stub => { + if (this.cloudSchedulerStub && !this._terminated) { + return this.cloudSchedulerStub.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts index c280764e70d..1b06d669d3e 100644 --- a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts +++ b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1.ts @@ -153,12 +153,27 @@ describe('v1.CloudSchedulerClient', () => { assert(client.cloudSchedulerStub); }); - it('has close method', () => { + 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.close(); + 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 () => { @@ -301,6 +316,22 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); }); describe('createJob', () => { @@ -409,6 +440,22 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createJob(request), expectedError); + }); }); describe('updateJob', () => { @@ -520,6 +567,23 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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 = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateJob(request), expectedError); + }); }); describe('deleteJob', () => { @@ -628,6 +692,22 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteJob(request), expectedError); + }); }); describe('pauseJob', () => { @@ -736,6 +816,22 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseJob(request), expectedError); + }); }); describe('resumeJob', () => { @@ -844,6 +940,22 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeJob(request), expectedError); + }); }); describe('runJob', () => { @@ -952,6 +1064,22 @@ describe('v1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runJob(request), expectedError); + }); }); describe('listJobs', () => { 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 d979a3af6f1..0481947680e 100644 --- a/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts +++ b/packages/google-cloud-scheduler/test/gapic_cloud_scheduler_v1beta1.ts @@ -153,12 +153,27 @@ describe('v1beta1.CloudSchedulerClient', () => { assert(client.cloudSchedulerStub); }); - it('has close method', () => { + 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.close(); + 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 () => { @@ -301,6 +316,22 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getJob(request), expectedError); + }); }); describe('createJob', () => { @@ -409,6 +440,22 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createJob(request), expectedError); + }); }); describe('updateJob', () => { @@ -520,6 +567,23 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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 = {}; + request.job.name = ''; + const expectedHeaderRequestParams = 'job.name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateJob(request), expectedError); + }); }); describe('deleteJob', () => { @@ -628,6 +692,22 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteJob(request), expectedError); + }); }); describe('pauseJob', () => { @@ -736,6 +816,22 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseJob(request), expectedError); + }); }); describe('resumeJob', () => { @@ -844,6 +940,22 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeJob(request), expectedError); + }); }); describe('runJob', () => { @@ -952,6 +1064,22 @@ describe('v1beta1.CloudSchedulerClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runJob(request), expectedError); + }); }); describe('listJobs', () => {