From fb1e9d6d4ddd0084ee0850bfb16ffc169b8d47a5 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:10:10 -0800 Subject: [PATCH] feat: Updated Client Libraries for Cloud Scheduler (#3738) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../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 +++++++++++++++- 15 files changed, 830 insertions(+), 157 deletions(-) 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', () => {