google_cloudscheduler1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudScheduler related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_cloudscheduler1 as cloudscheduler1;
49/// use cloudscheduler1::api::Job;
50/// use cloudscheduler1::{Result, Error};
51/// # async fn dox() {
52/// use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = CloudScheduler::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Job::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_jobs_patch(req, "name")
99///              .update_mask(FieldMask::new::<&str>(&[]))
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct CloudScheduler<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for CloudScheduler<C> {}
131
132impl<'a, C> CloudScheduler<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> CloudScheduler<C> {
137        CloudScheduler {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://cloudscheduler.googleapis.com/".to_string(),
142            _root_url: "https://cloudscheduler.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://cloudscheduler.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://cloudscheduler.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// App Engine target. The job will be pushed to a job handler by means of an HTTP request via an 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.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct AppEngineHttpTarget {
186    /// App Engine Routing setting for the job.
187    #[serde(rename = "appEngineRouting")]
188    pub app_engine_routing: Option<AppEngineRouting>,
189    /// Body. HTTP request body. A request body is allowed only if the HTTP method is POST or PUT. It will result in invalid argument error to set a body on a job with an incompatible HttpMethod.
190    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
191    pub body: Option<Vec<u8>>,
192    /// HTTP request headers. This map contains the header field names and values. Headers can be set when the job is created. Cloud Scheduler sets some headers to default values: * `User-Agent`: By default, this header is `"AppEngine-Google; (+http://code.google.com/appengine)"`. This header can be modified, but Cloud Scheduler will append `"AppEngine-Google; (+http://code.google.com/appengine)"` to the modified `User-Agent`. * `X-CloudScheduler`: This header will be set to true. * `X-CloudScheduler-JobName`: This header will contain the job name. * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in the unix-cron format, this header will contain the job schedule as an offset of UTC parsed according to RFC3339. If the job has a body and the following headers are not set by the user, Cloud Scheduler sets default values: * `Content-Type`: This will be set to `"application/octet-stream"`. You can override this default by explicitly setting `Content-Type` to a particular media type when creating the job. For example, you can set `Content-Type` to `"application/json"`. The headers below are output only. They cannot be set or overridden: * `Content-Length`: This is computed by Cloud Scheduler. * `X-Google-*`: For Google internal use only. * `X-AppEngine-*`: For Google internal use only. In addition, some App Engine headers, which contain job-specific information, are also be sent to the job handler.
193    pub headers: Option<HashMap<String, String>>,
194    /// The HTTP method to use for the request. PATCH and OPTIONS are not permitted.
195    #[serde(rename = "httpMethod")]
196    pub http_method: Option<String>,
197    /// The relative URI. The relative URL must begin with "/" and must be a valid HTTP relative URL. It can contain a path, query string arguments, and `#` fragments. If the relative URL is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters.
198    #[serde(rename = "relativeUri")]
199    pub relative_uri: Option<String>,
200}
201
202impl common::Part for AppEngineHttpTarget {}
203
204/// App Engine Routing. For more information about services, versions, and instances see [An Overview of App Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), [Microservices Architecture on Google App Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), [App Engine Standard request routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), and [App Engine Flex request routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
205///
206/// This type is not used in any activity, and only used as *part* of another schema.
207///
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct AppEngineRouting {
212    /// Output only. The host that the job is sent to. For more information about how App Engine requests are routed, see [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). The host is constructed as: * `host = [application_domain_name]` `| [service] + '.' + [application_domain_name]` `| [version] + '.' + [application_domain_name]` `| [version_dot_service]+ '.' + [application_domain_name]` `| [instance] + '.' + [application_domain_name]` `| [instance_dot_service] + '.' + [application_domain_name]` `| [instance_dot_version] + '.' + [application_domain_name]` `| [instance_dot_version_dot_service] + '.' + [application_domain_name]` * `application_domain_name` = The domain name of the app, for example .appspot.com, which is associated with the job's project ID. * `service =` service * `version =` version * `version_dot_service =` version `+ '.' +` service * `instance =` instance * `instance_dot_service =` instance `+ '.' +` service * `instance_dot_version =` instance `+ '.' +` version * `instance_dot_version_dot_service =` instance `+ '.' +` version `+ '.' +` service If service is empty, then the job will be sent to the service which is the default service when the job is attempted. If version is empty, then the job will be sent to the version which is the default version when the job is attempted. If instance is empty, then the job will be sent to an instance which is available when the job is attempted. If service, version, or instance is invalid, then the job will be sent to the default version of the default service when the job is attempted.
213    pub host: Option<String>,
214    /// App instance. By default, the job is sent to an instance which is available when the job is attempted. Requests can only be sent to a specific instance if [manual scaling is used in App Engine Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes). App Engine Flex does not support instances. For more information, see [App Engine Standard request routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) and [App Engine Flex request routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
215    pub instance: Option<String>,
216    /// App service. By default, the job is sent to the service which is the default service when the job is attempted.
217    pub service: Option<String>,
218    /// App version. By default, the job is sent to the version which is the default version when the job is attempted.
219    pub version: Option<String>,
220}
221
222impl common::Part for AppEngineRouting {}
223
224/// The request message for Operations.CancelOperation.
225///
226/// # Activities
227///
228/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
229/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
230///
231/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
232#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
233#[serde_with::serde_as]
234#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
235pub struct CancelOperationRequest {
236    _never_set: Option<bool>,
237}
238
239impl common::RequestValue for CancelOperationRequest {}
240
241/// Describes the project/location configuration of Cloud Scheduler Resources.
242///
243/// # Activities
244///
245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
247///
248/// * [locations get cmek config projects](ProjectLocationGetCmekConfigCall) (response)
249/// * [locations update cmek config projects](ProjectLocationUpdateCmekConfigCall) (request)
250#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
251#[serde_with::serde_as]
252#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
253pub struct CmekConfig {
254    /// Optional. Resource name of the Cloud KMS key, of the form `projects/PROJECT_ID/locations/LOCATION_ID/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID`, that will be used to encrypt Jobs in the region. Setting this as blank will turn off CMEK encryption.
255    #[serde(rename = "kmsKeyName")]
256    pub kms_key_name: Option<String>,
257    /// Identifier. The config resource name which includes the project and location and must end in 'cmekConfig', in the format projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig`
258    pub name: Option<String>,
259}
260
261impl common::RequestValue for CmekConfig {}
262impl common::ResponseResult for CmekConfig {}
263
264/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
265///
266/// # Activities
267///
268/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
269/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
270///
271/// * [locations jobs delete projects](ProjectLocationJobDeleteCall) (response)
272/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
273/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
274#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
275#[serde_with::serde_as]
276#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
277pub struct Empty {
278    _never_set: Option<bool>,
279}
280
281impl common::ResponseResult for Empty {}
282
283/// Http target. The job will be pushed to the job handler by means of an HTTP request via an 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.
284///
285/// This type is not used in any activity, and only used as *part* of another schema.
286///
287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
288#[serde_with::serde_as]
289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
290pub struct HttpTarget {
291    /// HTTP request body. A request body is allowed only if the HTTP method is POST, PUT, or PATCH. It is an error to set body on a job with an incompatible HttpMethod.
292    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
293    pub body: Option<Vec<u8>>,
294    /// HTTP request headers. This map contains the header field names and values. The user can specify HTTP request headers to send with the job's HTTP request. Repeated headers are not supported, but a header value can contain commas. The following headers represent a subset of the headers that accompany the job's HTTP request. Some HTTP request headers are ignored or replaced. A partial list of headers that are ignored or replaced is below: * Host: This will be computed by Cloud Scheduler and derived from uri. * `Content-Length`: This will be computed by Cloud Scheduler. * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`. * `X-Google-*`: Google internal use only. * `X-AppEngine-*`: Google internal use only. * `X-CloudScheduler`: This header will be set to true. * `X-CloudScheduler-JobName`: This header will contain the job name. * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in the unix-cron format, this header will contain the job schedule as an offset of UTC parsed according to RFC3339. If the job has a body and the following headers are not set by the user, Cloud Scheduler sets default values: * `Content-Type`: This will be set to `"application/octet-stream"`. You can override this default by explicitly setting `Content-Type` to a particular media type when creating the job. For example, you can set `Content-Type` to `"application/json"`. The total size of headers must be less than 80KB.
295    pub headers: Option<HashMap<String, String>>,
296    /// Which HTTP method to use for the request.
297    #[serde(rename = "httpMethod")]
298    pub http_method: Option<String>,
299    /// If specified, an [OAuth token](https://developers.google.com/identity/protocols/OAuth2) will be generated and attached as an `Authorization` header in the HTTP request. This type of authorization should generally only be used when calling Google APIs hosted on *.googleapis.com.
300    #[serde(rename = "oauthToken")]
301    pub oauth_token: Option<OAuthToken>,
302    /// If specified, an [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) token will be generated and attached as an `Authorization` header in the HTTP request. This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself.
303    #[serde(rename = "oidcToken")]
304    pub oidc_token: Option<OidcToken>,
305    /// Required. The full URI path that the request will be sent to. This string must begin with either "http://" or "https://". Some examples of valid values for uri are: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will encode some characters for safety and compatibility. The maximum allowed URL length is 2083 characters after encoding.
306    pub uri: Option<String>,
307}
308
309impl common::Part for HttpTarget {}
310
311/// Configuration for a job. The maximum allowed size for a job is 1MB.
312///
313/// # Activities
314///
315/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
316/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
317///
318/// * [locations jobs create projects](ProjectLocationJobCreateCall) (request|response)
319/// * [locations jobs get projects](ProjectLocationJobGetCall) (response)
320/// * [locations jobs patch projects](ProjectLocationJobPatchCall) (request|response)
321/// * [locations jobs pause projects](ProjectLocationJobPauseCall) (response)
322/// * [locations jobs resume projects](ProjectLocationJobResumeCall) (response)
323/// * [locations jobs run projects](ProjectLocationJobRunCall) (response)
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct Job {
328    /// App Engine HTTP target.
329    #[serde(rename = "appEngineHttpTarget")]
330    pub app_engine_http_target: Option<AppEngineHttpTarget>,
331    /// The deadline for job attempts. If the request handler does not respond by this deadline then the request is cancelled and the attempt is marked as a `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in execution logs. Cloud Scheduler will retry the job according to the RetryConfig. The default and the allowed values depend on the type of target: * For HTTP targets, the default is 3 minutes. The deadline must be in the interval [15 seconds, 30 minutes]. * For App Engine HTTP targets, 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, this field is ignored.
332    #[serde(rename = "attemptDeadline")]
333    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
334    pub attempt_deadline: Option<chrono::Duration>,
335    /// Optionally caller-specified in CreateJob or UpdateJob. A human-readable description for the job. This string must not contain more than 500 characters.
336    pub description: Option<String>,
337    /// HTTP target.
338    #[serde(rename = "httpTarget")]
339    pub http_target: Option<HttpTarget>,
340    /// Output only. The time the last job attempt started.
341    #[serde(rename = "lastAttemptTime")]
342    pub last_attempt_time: Option<chrono::DateTime<chrono::offset::Utc>>,
343    /// Optionally caller-specified in CreateJob, after which it becomes output only. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. * `PROJECT_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) * `LOCATION_ID` is the canonical ID for the job’s location. The list of available locations can be obtained by calling [locations.list](https://cloud.google.com/scheduler/docs/reference/rest/v1/projects.locations/list). For more information, see [Cloud Scheduler locations](https://cloud.google.com/scheduler/docs/locations). * `JOB_ID` can contain only letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), or underscores (\_). The maximum length is 500 characters.
344    pub name: Option<String>,
345    /// Pub/Sub target.
346    #[serde(rename = "pubsubTarget")]
347    pub pubsub_target: Option<PubsubTarget>,
348    /// Settings that determine the retry behavior.
349    #[serde(rename = "retryConfig")]
350    pub retry_config: Option<RetryConfig>,
351    /// Output only. Whether or not this Job satisfies the requirements of physical zone separation
352    #[serde(rename = "satisfiesPzs")]
353    pub satisfies_pzs: Option<bool>,
354    /// Required, except when used with UpdateJob. Describes the schedule on which the job will be executed. The schedule can be either of the following types: * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview) * English-like [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules) As a general rule, execution `n + 1` of a job will not begin until execution `n` has finished. Cloud Scheduler will never allow two simultaneously outstanding executions. For example, this implies that if the `n+1`th execution is scheduled to run at 16:00 but the `n`th execution takes until 16:15, the `n+1`th execution will not start until `16:15`. A scheduled start time will be delayed if the previous execution has not ended when its scheduled time occurs. If retry_count > 0 and a job attempt fails, the job will be tried a total of retry_count times, with exponential backoff, until the next scheduled start time. If retry_count is 0, a job attempt will not be retried if it fails. Instead the Cloud Scheduler system will wait for the next scheduled execution time. Setting retry_count to 0 does not prevent failed jobs from running according to schedule after the failure.
355    pub schedule: Option<String>,
356    /// Output only. The next time the job is scheduled. Note that this may be a retry of a previously failed attempt or the next execution time according to the schedule.
357    #[serde(rename = "scheduleTime")]
358    pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
359    /// Output only. State of the job.
360    pub state: Option<String>,
361    /// Output only. The response from the target for the last attempted execution.
362    pub status: Option<Status>,
363    /// Specifies the time zone to be used in interpreting schedule. The value of this field must be a time zone name from the [tz database](http://en.wikipedia.org/wiki/Tz_database). Note that some time zones include a provision for daylight savings time. The rules for daylight saving time are determined by the chosen tz. For UTC use the string "utc". If a time zone is not specified, the default will be in UTC (also known as GMT).
364    #[serde(rename = "timeZone")]
365    pub time_zone: Option<String>,
366    /// Output only. The creation time of the job.
367    #[serde(rename = "userUpdateTime")]
368    pub user_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
369}
370
371impl common::RequestValue for Job {}
372impl common::ResponseResult for Job {}
373
374/// Response message for listing jobs using ListJobs.
375///
376/// # Activities
377///
378/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
379/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
380///
381/// * [locations jobs list projects](ProjectLocationJobListCall) (response)
382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
383#[serde_with::serde_as]
384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
385pub struct ListJobsResponse {
386    /// The list of jobs.
387    pub jobs: Option<Vec<Job>>,
388    /// A token to retrieve next page of results. Pass this value in the page_token field in the subsequent call to 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.
389    #[serde(rename = "nextPageToken")]
390    pub next_page_token: Option<String>,
391}
392
393impl common::ResponseResult for ListJobsResponse {}
394
395/// The response message for Locations.ListLocations.
396///
397/// # Activities
398///
399/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
400/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
401///
402/// * [locations list projects](ProjectLocationListCall) (response)
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct ListLocationsResponse {
407    /// A list of locations that matches the specified filter in the request.
408    pub locations: Option<Vec<Location>>,
409    /// The standard List next-page token.
410    #[serde(rename = "nextPageToken")]
411    pub next_page_token: Option<String>,
412}
413
414impl common::ResponseResult for ListLocationsResponse {}
415
416/// The response message for Operations.ListOperations.
417///
418/// # Activities
419///
420/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
421/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
422///
423/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
425#[serde_with::serde_as]
426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
427pub struct ListOperationsResponse {
428    /// The standard List next-page token.
429    #[serde(rename = "nextPageToken")]
430    pub next_page_token: Option<String>,
431    /// A list of operations that matches the specified filter in the request.
432    pub operations: Option<Vec<Operation>>,
433    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
434    pub unreachable: Option<Vec<String>>,
435}
436
437impl common::ResponseResult for ListOperationsResponse {}
438
439/// A resource that represents a Google Cloud location.
440///
441/// # Activities
442///
443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
445///
446/// * [locations get projects](ProjectLocationGetCall) (response)
447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
448#[serde_with::serde_as]
449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
450pub struct Location {
451    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
452    #[serde(rename = "displayName")]
453    pub display_name: Option<String>,
454    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
455    pub labels: Option<HashMap<String, String>>,
456    /// The canonical id for this location. For example: `"us-east1"`.
457    #[serde(rename = "locationId")]
458    pub location_id: Option<String>,
459    /// Service-specific metadata. For example the available capacity at the given location.
460    pub metadata: Option<HashMap<String, serde_json::Value>>,
461    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
462    pub name: Option<String>,
463}
464
465impl common::ResponseResult for Location {}
466
467/// Contains information needed for generating an [OAuth token](https://developers.google.com/identity/protocols/OAuth2). This type of authorization should generally only be used when calling Google APIs hosted on *.googleapis.com.
468///
469/// This type is not used in any activity, and only used as *part* of another schema.
470///
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct OAuthToken {
475    /// OAuth scope to be used for generating OAuth access token. If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used.
476    pub scope: Option<String>,
477    /// [Service account email](https://cloud.google.com/iam/docs/service-accounts) to be used for generating OAuth token. The service account must be within the same project as the job. The caller must have iam.serviceAccounts.actAs permission for the service account.
478    #[serde(rename = "serviceAccountEmail")]
479    pub service_account_email: Option<String>,
480}
481
482impl common::Part for OAuthToken {}
483
484/// Contains information needed for generating an [OpenID Connect token](https://developers.google.com/identity/protocols/OpenIDConnect). This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself.
485///
486/// This type is not used in any activity, and only used as *part* of another schema.
487///
488#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
489#[serde_with::serde_as]
490#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
491pub struct OidcToken {
492    /// Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used.
493    pub audience: Option<String>,
494    /// [Service account email](https://cloud.google.com/iam/docs/service-accounts) to be used for generating OIDC token. The service account must be within the same project as the job. The caller must have iam.serviceAccounts.actAs permission for the service account.
495    #[serde(rename = "serviceAccountEmail")]
496    pub service_account_email: Option<String>,
497}
498
499impl common::Part for OidcToken {}
500
501/// This resource represents a long-running operation that is the result of a network API call.
502///
503/// # Activities
504///
505/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
506/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
507///
508/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
509/// * [locations update cmek config projects](ProjectLocationUpdateCmekConfigCall) (response)
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct Operation {
514    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
515    pub done: Option<bool>,
516    /// The error result of the operation in case of failure or cancellation.
517    pub error: Option<Status>,
518    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
519    pub metadata: Option<HashMap<String, serde_json::Value>>,
520    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
521    pub name: Option<String>,
522    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
523    pub response: Option<HashMap<String, serde_json::Value>>,
524}
525
526impl common::ResponseResult for Operation {}
527
528/// Request message for PauseJob.
529///
530/// # Activities
531///
532/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
533/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
534///
535/// * [locations jobs pause projects](ProjectLocationJobPauseCall) (request)
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct PauseJobRequest {
540    _never_set: Option<bool>,
541}
542
543impl common::RequestValue for PauseJobRequest {}
544
545/// Pub/Sub target. The job will be delivered by publishing a message to the given Pub/Sub topic.
546///
547/// This type is not used in any activity, and only used as *part* of another schema.
548///
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct PubsubTarget {
553    /// Attributes for PubsubMessage. Pubsub message must contain either non-empty data, or at least one attribute.
554    pub attributes: Option<HashMap<String, String>>,
555    /// The message payload for PubsubMessage. Pubsub message must contain either non-empty data, or at least one attribute.
556    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
557    pub data: Option<Vec<u8>>,
558    /// Required. The name of the Cloud Pub/Sub topic to which messages will be published when a job is delivered. The topic name must be in the same format as required by Pub/Sub's [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), for example `projects/PROJECT_ID/topics/TOPIC_ID`. The topic must be in the same project as the Cloud Scheduler job.
559    #[serde(rename = "topicName")]
560    pub topic_name: Option<String>,
561}
562
563impl common::Part for PubsubTarget {}
564
565/// Request message for ResumeJob.
566///
567/// # Activities
568///
569/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
570/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
571///
572/// * [locations jobs resume projects](ProjectLocationJobResumeCall) (request)
573#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
574#[serde_with::serde_as]
575#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
576pub struct ResumeJobRequest {
577    _never_set: Option<bool>,
578}
579
580impl common::RequestValue for ResumeJobRequest {}
581
582/// Settings that determine the retry behavior. For more information, see [Retry jobs](https://cloud.google.com/scheduler/docs/configuring/retry-jobs). 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.
583///
584/// This type is not used in any activity, and only used as *part* of another schema.
585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
586#[serde_with::serde_as]
587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
588pub struct RetryConfig {
589    /// The maximum amount of time to wait before retrying a job after it fails. The default value of this field is 1 hour.
590    #[serde(rename = "maxBackoffDuration")]
591    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
592    pub max_backoff_duration: Option<chrono::Duration>,
593    /// The time between retries will double `max_doublings` times. A job’s retry interval starts at min_backoff_duration, then doubles `max_doublings` times, then increases linearly, and finally retries at intervals of max_backoff_duration up to retry_count times. For examples, see [Retry jobs](https://cloud.google.com/scheduler/docs/configuring/retry-jobs#max-doublings). The default value of this field is 5.
594    #[serde(rename = "maxDoublings")]
595    pub max_doublings: Option<i32>,
596    /// The time limit for retrying a failed job, measured from the time when an execution was first attempted. If specified with 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. However, if retry_count is also 0, a job attempt won't be retried if it fails.
597    #[serde(rename = "maxRetryDuration")]
598    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
599    pub max_retry_duration: Option<chrono::Duration>,
600    /// The minimum amount of time to wait before retrying a job after it fails. The default value of this field is 5 seconds.
601    #[serde(rename = "minBackoffDuration")]
602    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
603    pub min_backoff_duration: Option<chrono::Duration>,
604    /// The number of attempts that the system will make to run a job using the exponential backoff procedure described by max_doublings. The default value of retry_count is zero. If retry_count is 0 (and if max_retry_duration is also 0), a job attempt won't be retried if it fails. Instead, Cloud Scheduler system will wait for the next scheduled execution time. Setting retry_count to 0 doesn't prevent failed jobs from running according to schedule after the failure. If retry_count is set to a non-zero number, Cloud Scheduler will retry the failed job, using exponential backoff, for retry_count times until the job succeeds or the number of retries is exhausted. Note that the next scheduled execution time might be skipped if the retries continue through that time. Values greater than 5 and negative values are not allowed.
605    #[serde(rename = "retryCount")]
606    pub retry_count: Option<i32>,
607}
608
609impl common::Part for RetryConfig {}
610
611/// Request message for forcing a job to run now using RunJob.
612///
613/// # Activities
614///
615/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
616/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
617///
618/// * [locations jobs run projects](ProjectLocationJobRunCall) (request)
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct RunJobRequest {
623    _never_set: Option<bool>,
624}
625
626impl common::RequestValue for RunJobRequest {}
627
628/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
629///
630/// This type is not used in any activity, and only used as *part* of another schema.
631///
632#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
633#[serde_with::serde_as]
634#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
635pub struct Status {
636    /// The status code, which should be an enum value of google.rpc.Code.
637    pub code: Option<i32>,
638    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
639    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
640    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
641    pub message: Option<String>,
642}
643
644impl common::Part for Status {}
645
646// ###################
647// MethodBuilders ###
648// #################
649
650/// A builder providing access to all methods supported on *project* resources.
651/// It is not used directly, but through the [`CloudScheduler`] hub.
652///
653/// # Example
654///
655/// Instantiate a resource builder
656///
657/// ```test_harness,no_run
658/// extern crate hyper;
659/// extern crate hyper_rustls;
660/// extern crate google_cloudscheduler1 as cloudscheduler1;
661///
662/// # async fn dox() {
663/// use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
664///
665/// let secret: yup_oauth2::ApplicationSecret = Default::default();
666/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
667///     .with_native_roots()
668///     .unwrap()
669///     .https_only()
670///     .enable_http2()
671///     .build();
672///
673/// let executor = hyper_util::rt::TokioExecutor::new();
674/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
675///     secret,
676///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
677///     yup_oauth2::client::CustomHyperClientBuilder::from(
678///         hyper_util::client::legacy::Client::builder(executor).build(connector),
679///     ),
680/// ).build().await.unwrap();
681///
682/// let client = hyper_util::client::legacy::Client::builder(
683///     hyper_util::rt::TokioExecutor::new()
684/// )
685/// .build(
686///     hyper_rustls::HttpsConnectorBuilder::new()
687///         .with_native_roots()
688///         .unwrap()
689///         .https_or_http()
690///         .enable_http2()
691///         .build()
692/// );
693/// let mut hub = CloudScheduler::new(client, auth);
694/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
695/// // like `locations_get(...)`, `locations_get_cmek_config(...)`, `locations_jobs_create(...)`, `locations_jobs_delete(...)`, `locations_jobs_get(...)`, `locations_jobs_list(...)`, `locations_jobs_patch(...)`, `locations_jobs_pause(...)`, `locations_jobs_resume(...)`, `locations_jobs_run(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)` and `locations_update_cmek_config(...)`
696/// // to build up your call.
697/// let rb = hub.projects();
698/// # }
699/// ```
700pub struct ProjectMethods<'a, C>
701where
702    C: 'a,
703{
704    hub: &'a CloudScheduler<C>,
705}
706
707impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
708
709impl<'a, C> ProjectMethods<'a, C> {
710    /// Create a builder to help you perform the following task:
711    ///
712    /// Creates a job.
713    ///
714    /// # Arguments
715    ///
716    /// * `request` - No description provided.
717    /// * `parent` - Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
718    pub fn locations_jobs_create(
719        &self,
720        request: Job,
721        parent: &str,
722    ) -> ProjectLocationJobCreateCall<'a, C> {
723        ProjectLocationJobCreateCall {
724            hub: self.hub,
725            _request: request,
726            _parent: parent.to_string(),
727            _delegate: Default::default(),
728            _additional_params: Default::default(),
729            _scopes: Default::default(),
730        }
731    }
732
733    /// Create a builder to help you perform the following task:
734    ///
735    /// Deletes a job.
736    ///
737    /// # Arguments
738    ///
739    /// * `name` - Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
740    pub fn locations_jobs_delete(&self, name: &str) -> ProjectLocationJobDeleteCall<'a, C> {
741        ProjectLocationJobDeleteCall {
742            hub: self.hub,
743            _name: name.to_string(),
744            _delegate: Default::default(),
745            _additional_params: Default::default(),
746            _scopes: Default::default(),
747        }
748    }
749
750    /// Create a builder to help you perform the following task:
751    ///
752    /// Gets a job.
753    ///
754    /// # Arguments
755    ///
756    /// * `name` - Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
757    pub fn locations_jobs_get(&self, name: &str) -> ProjectLocationJobGetCall<'a, C> {
758        ProjectLocationJobGetCall {
759            hub: self.hub,
760            _name: name.to_string(),
761            _delegate: Default::default(),
762            _additional_params: Default::default(),
763            _scopes: Default::default(),
764        }
765    }
766
767    /// Create a builder to help you perform the following task:
768    ///
769    /// Lists jobs.
770    ///
771    /// # Arguments
772    ///
773    /// * `parent` - Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
774    pub fn locations_jobs_list(&self, parent: &str) -> ProjectLocationJobListCall<'a, C> {
775        ProjectLocationJobListCall {
776            hub: self.hub,
777            _parent: parent.to_string(),
778            _page_token: Default::default(),
779            _page_size: Default::default(),
780            _delegate: Default::default(),
781            _additional_params: Default::default(),
782            _scopes: Default::default(),
783        }
784    }
785
786    /// Create a builder to help you perform the following task:
787    ///
788    /// Updates a job. If successful, the updated 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 state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.
789    ///
790    /// # Arguments
791    ///
792    /// * `request` - No description provided.
793    /// * `name` - Optionally caller-specified in CreateJob, after which it becomes output only. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. * `PROJECT_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) * `LOCATION_ID` is the canonical ID for the job’s location. The list of available locations can be obtained by calling [locations.list](https://cloud.google.com/scheduler/docs/reference/rest/v1/projects.locations/list). For more information, see [Cloud Scheduler locations](https://cloud.google.com/scheduler/docs/locations). * `JOB_ID` can contain only letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), or underscores (\_). The maximum length is 500 characters.
794    pub fn locations_jobs_patch(
795        &self,
796        request: Job,
797        name: &str,
798    ) -> ProjectLocationJobPatchCall<'a, C> {
799        ProjectLocationJobPatchCall {
800            hub: self.hub,
801            _request: request,
802            _name: name.to_string(),
803            _update_mask: Default::default(),
804            _delegate: Default::default(),
805            _additional_params: Default::default(),
806            _scopes: Default::default(),
807        }
808    }
809
810    /// Create a builder to help you perform the following task:
811    ///
812    /// Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.
813    ///
814    /// # Arguments
815    ///
816    /// * `request` - No description provided.
817    /// * `name` - Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
818    pub fn locations_jobs_pause(
819        &self,
820        request: PauseJobRequest,
821        name: &str,
822    ) -> ProjectLocationJobPauseCall<'a, C> {
823        ProjectLocationJobPauseCall {
824            hub: self.hub,
825            _request: request,
826            _name: name.to_string(),
827            _delegate: Default::default(),
828            _additional_params: Default::default(),
829            _scopes: Default::default(),
830        }
831    }
832
833    /// Create a builder to help you perform the following task:
834    ///
835    /// Resume a job. This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
836    ///
837    /// # Arguments
838    ///
839    /// * `request` - No description provided.
840    /// * `name` - Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
841    pub fn locations_jobs_resume(
842        &self,
843        request: ResumeJobRequest,
844        name: &str,
845    ) -> ProjectLocationJobResumeCall<'a, C> {
846        ProjectLocationJobResumeCall {
847            hub: self.hub,
848            _request: request,
849            _name: name.to_string(),
850            _delegate: Default::default(),
851            _additional_params: Default::default(),
852            _scopes: Default::default(),
853        }
854    }
855
856    /// Create a builder to help you perform the following task:
857    ///
858    /// Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
859    ///
860    /// # Arguments
861    ///
862    /// * `request` - No description provided.
863    /// * `name` - Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
864    pub fn locations_jobs_run(
865        &self,
866        request: RunJobRequest,
867        name: &str,
868    ) -> ProjectLocationJobRunCall<'a, C> {
869        ProjectLocationJobRunCall {
870            hub: self.hub,
871            _request: request,
872            _name: name.to_string(),
873            _delegate: Default::default(),
874            _additional_params: Default::default(),
875            _scopes: Default::default(),
876        }
877    }
878
879    /// Create a builder to help you perform the following task:
880    ///
881    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
882    ///
883    /// # Arguments
884    ///
885    /// * `request` - No description provided.
886    /// * `name` - The name of the operation resource to be cancelled.
887    pub fn locations_operations_cancel(
888        &self,
889        request: CancelOperationRequest,
890        name: &str,
891    ) -> ProjectLocationOperationCancelCall<'a, C> {
892        ProjectLocationOperationCancelCall {
893            hub: self.hub,
894            _request: request,
895            _name: name.to_string(),
896            _delegate: Default::default(),
897            _additional_params: Default::default(),
898            _scopes: Default::default(),
899        }
900    }
901
902    /// Create a builder to help you perform the following task:
903    ///
904    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
905    ///
906    /// # Arguments
907    ///
908    /// * `name` - The name of the operation resource to be deleted.
909    pub fn locations_operations_delete(
910        &self,
911        name: &str,
912    ) -> ProjectLocationOperationDeleteCall<'a, C> {
913        ProjectLocationOperationDeleteCall {
914            hub: self.hub,
915            _name: name.to_string(),
916            _delegate: Default::default(),
917            _additional_params: Default::default(),
918            _scopes: Default::default(),
919        }
920    }
921
922    /// Create a builder to help you perform the following task:
923    ///
924    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
925    ///
926    /// # Arguments
927    ///
928    /// * `name` - The name of the operation resource.
929    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
930        ProjectLocationOperationGetCall {
931            hub: self.hub,
932            _name: name.to_string(),
933            _delegate: Default::default(),
934            _additional_params: Default::default(),
935            _scopes: Default::default(),
936        }
937    }
938
939    /// Create a builder to help you perform the following task:
940    ///
941    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
942    ///
943    /// # Arguments
944    ///
945    /// * `name` - The name of the operation's parent resource.
946    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
947        ProjectLocationOperationListCall {
948            hub: self.hub,
949            _name: name.to_string(),
950            _return_partial_success: Default::default(),
951            _page_token: Default::default(),
952            _page_size: Default::default(),
953            _filter: Default::default(),
954            _delegate: Default::default(),
955            _additional_params: Default::default(),
956            _scopes: Default::default(),
957        }
958    }
959
960    /// Create a builder to help you perform the following task:
961    ///
962    /// Gets information about a location.
963    ///
964    /// # Arguments
965    ///
966    /// * `name` - Resource name for the location.
967    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
968        ProjectLocationGetCall {
969            hub: self.hub,
970            _name: name.to_string(),
971            _delegate: Default::default(),
972            _additional_params: Default::default(),
973            _scopes: Default::default(),
974        }
975    }
976
977    /// Create a builder to help you perform the following task:
978    ///
979    /// Gets the Scheduler config in the project/region.
980    ///
981    /// # Arguments
982    ///
983    /// * `name` - Required. The config name. For example: projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig
984    pub fn locations_get_cmek_config(&self, name: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
985        ProjectLocationGetCmekConfigCall {
986            hub: self.hub,
987            _name: name.to_string(),
988            _delegate: Default::default(),
989            _additional_params: Default::default(),
990            _scopes: Default::default(),
991        }
992    }
993
994    /// Create a builder to help you perform the following task:
995    ///
996    /// Lists information about the supported locations for this service.
997    ///
998    /// # Arguments
999    ///
1000    /// * `name` - The resource that owns the locations collection, if applicable.
1001    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1002        ProjectLocationListCall {
1003            hub: self.hub,
1004            _name: name.to_string(),
1005            _page_token: Default::default(),
1006            _page_size: Default::default(),
1007            _filter: Default::default(),
1008            _extra_location_types: Default::default(),
1009            _delegate: Default::default(),
1010            _additional_params: Default::default(),
1011            _scopes: Default::default(),
1012        }
1013    }
1014
1015    /// Create a builder to help you perform the following task:
1016    ///
1017    /// Initializes or Updates the a scheduler config.
1018    ///
1019    /// # Arguments
1020    ///
1021    /// * `request` - No description provided.
1022    /// * `name` - Identifier. The config resource name which includes the project and location and must end in 'cmekConfig', in the format projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig`
1023    pub fn locations_update_cmek_config(
1024        &self,
1025        request: CmekConfig,
1026        name: &str,
1027    ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
1028        ProjectLocationUpdateCmekConfigCall {
1029            hub: self.hub,
1030            _request: request,
1031            _name: name.to_string(),
1032            _update_mask: Default::default(),
1033            _delegate: Default::default(),
1034            _additional_params: Default::default(),
1035            _scopes: Default::default(),
1036        }
1037    }
1038}
1039
1040// ###################
1041// CallBuilders   ###
1042// #################
1043
1044/// Creates a job.
1045///
1046/// A builder for the *locations.jobs.create* method supported by a *project* resource.
1047/// It is not used directly, but through a [`ProjectMethods`] instance.
1048///
1049/// # Example
1050///
1051/// Instantiate a resource method builder
1052///
1053/// ```test_harness,no_run
1054/// # extern crate hyper;
1055/// # extern crate hyper_rustls;
1056/// # extern crate google_cloudscheduler1 as cloudscheduler1;
1057/// use cloudscheduler1::api::Job;
1058/// # async fn dox() {
1059/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1060///
1061/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1062/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1063/// #     .with_native_roots()
1064/// #     .unwrap()
1065/// #     .https_only()
1066/// #     .enable_http2()
1067/// #     .build();
1068///
1069/// # let executor = hyper_util::rt::TokioExecutor::new();
1070/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1071/// #     secret,
1072/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1073/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1074/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1075/// #     ),
1076/// # ).build().await.unwrap();
1077///
1078/// # let client = hyper_util::client::legacy::Client::builder(
1079/// #     hyper_util::rt::TokioExecutor::new()
1080/// # )
1081/// # .build(
1082/// #     hyper_rustls::HttpsConnectorBuilder::new()
1083/// #         .with_native_roots()
1084/// #         .unwrap()
1085/// #         .https_or_http()
1086/// #         .enable_http2()
1087/// #         .build()
1088/// # );
1089/// # let mut hub = CloudScheduler::new(client, auth);
1090/// // As the method needs a request, you would usually fill it with the desired information
1091/// // into the respective structure. Some of the parts shown here might not be applicable !
1092/// // Values shown here are possibly random and not representative !
1093/// let mut req = Job::default();
1094///
1095/// // You can configure optional parameters by calling the respective setters at will, and
1096/// // execute the final call using `doit()`.
1097/// // Values shown here are possibly random and not representative !
1098/// let result = hub.projects().locations_jobs_create(req, "parent")
1099///              .doit().await;
1100/// # }
1101/// ```
1102pub struct ProjectLocationJobCreateCall<'a, C>
1103where
1104    C: 'a,
1105{
1106    hub: &'a CloudScheduler<C>,
1107    _request: Job,
1108    _parent: String,
1109    _delegate: Option<&'a mut dyn common::Delegate>,
1110    _additional_params: HashMap<String, String>,
1111    _scopes: BTreeSet<String>,
1112}
1113
1114impl<'a, C> common::CallBuilder for ProjectLocationJobCreateCall<'a, C> {}
1115
1116impl<'a, C> ProjectLocationJobCreateCall<'a, C>
1117where
1118    C: common::Connector,
1119{
1120    /// Perform the operation you have build so far.
1121    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
1122        use std::borrow::Cow;
1123        use std::io::{Read, Seek};
1124
1125        use common::{url::Params, ToParts};
1126        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1127
1128        let mut dd = common::DefaultDelegate;
1129        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1130        dlg.begin(common::MethodInfo {
1131            id: "cloudscheduler.projects.locations.jobs.create",
1132            http_method: hyper::Method::POST,
1133        });
1134
1135        for &field in ["alt", "parent"].iter() {
1136            if self._additional_params.contains_key(field) {
1137                dlg.finished(false);
1138                return Err(common::Error::FieldClash(field));
1139            }
1140        }
1141
1142        let mut params = Params::with_capacity(4 + self._additional_params.len());
1143        params.push("parent", self._parent);
1144
1145        params.extend(self._additional_params.iter());
1146
1147        params.push("alt", "json");
1148        let mut url = self.hub._base_url.clone() + "v1/{+parent}/jobs";
1149        if self._scopes.is_empty() {
1150            self._scopes
1151                .insert(Scope::CloudPlatform.as_ref().to_string());
1152        }
1153
1154        #[allow(clippy::single_element_loop)]
1155        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1156            url = params.uri_replacement(url, param_name, find_this, true);
1157        }
1158        {
1159            let to_remove = ["parent"];
1160            params.remove_params(&to_remove);
1161        }
1162
1163        let url = params.parse_with_url(&url);
1164
1165        let mut json_mime_type = mime::APPLICATION_JSON;
1166        let mut request_value_reader = {
1167            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1168            common::remove_json_null_values(&mut value);
1169            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1170            serde_json::to_writer(&mut dst, &value).unwrap();
1171            dst
1172        };
1173        let request_size = request_value_reader
1174            .seek(std::io::SeekFrom::End(0))
1175            .unwrap();
1176        request_value_reader
1177            .seek(std::io::SeekFrom::Start(0))
1178            .unwrap();
1179
1180        loop {
1181            let token = match self
1182                .hub
1183                .auth
1184                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1185                .await
1186            {
1187                Ok(token) => token,
1188                Err(e) => match dlg.token(e) {
1189                    Ok(token) => token,
1190                    Err(e) => {
1191                        dlg.finished(false);
1192                        return Err(common::Error::MissingToken(e));
1193                    }
1194                },
1195            };
1196            request_value_reader
1197                .seek(std::io::SeekFrom::Start(0))
1198                .unwrap();
1199            let mut req_result = {
1200                let client = &self.hub.client;
1201                dlg.pre_request();
1202                let mut req_builder = hyper::Request::builder()
1203                    .method(hyper::Method::POST)
1204                    .uri(url.as_str())
1205                    .header(USER_AGENT, self.hub._user_agent.clone());
1206
1207                if let Some(token) = token.as_ref() {
1208                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1209                }
1210
1211                let request = req_builder
1212                    .header(CONTENT_TYPE, json_mime_type.to_string())
1213                    .header(CONTENT_LENGTH, request_size as u64)
1214                    .body(common::to_body(
1215                        request_value_reader.get_ref().clone().into(),
1216                    ));
1217
1218                client.request(request.unwrap()).await
1219            };
1220
1221            match req_result {
1222                Err(err) => {
1223                    if let common::Retry::After(d) = dlg.http_error(&err) {
1224                        sleep(d).await;
1225                        continue;
1226                    }
1227                    dlg.finished(false);
1228                    return Err(common::Error::HttpError(err));
1229                }
1230                Ok(res) => {
1231                    let (mut parts, body) = res.into_parts();
1232                    let mut body = common::Body::new(body);
1233                    if !parts.status.is_success() {
1234                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1235                        let error = serde_json::from_str(&common::to_string(&bytes));
1236                        let response = common::to_response(parts, bytes.into());
1237
1238                        if let common::Retry::After(d) =
1239                            dlg.http_failure(&response, error.as_ref().ok())
1240                        {
1241                            sleep(d).await;
1242                            continue;
1243                        }
1244
1245                        dlg.finished(false);
1246
1247                        return Err(match error {
1248                            Ok(value) => common::Error::BadRequest(value),
1249                            _ => common::Error::Failure(response),
1250                        });
1251                    }
1252                    let response = {
1253                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1254                        let encoded = common::to_string(&bytes);
1255                        match serde_json::from_str(&encoded) {
1256                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1257                            Err(error) => {
1258                                dlg.response_json_decode_error(&encoded, &error);
1259                                return Err(common::Error::JsonDecodeError(
1260                                    encoded.to_string(),
1261                                    error,
1262                                ));
1263                            }
1264                        }
1265                    };
1266
1267                    dlg.finished(true);
1268                    return Ok(response);
1269                }
1270            }
1271        }
1272    }
1273
1274    ///
1275    /// Sets the *request* property to the given value.
1276    ///
1277    /// Even though the property as already been set when instantiating this call,
1278    /// we provide this method for API completeness.
1279    pub fn request(mut self, new_value: Job) -> ProjectLocationJobCreateCall<'a, C> {
1280        self._request = new_value;
1281        self
1282    }
1283    /// Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
1284    ///
1285    /// Sets the *parent* path property to the given value.
1286    ///
1287    /// Even though the property as already been set when instantiating this call,
1288    /// we provide this method for API completeness.
1289    pub fn parent(mut self, new_value: &str) -> ProjectLocationJobCreateCall<'a, C> {
1290        self._parent = new_value.to_string();
1291        self
1292    }
1293    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1294    /// while executing the actual API request.
1295    ///
1296    /// ````text
1297    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1298    /// ````
1299    ///
1300    /// Sets the *delegate* property to the given value.
1301    pub fn delegate(
1302        mut self,
1303        new_value: &'a mut dyn common::Delegate,
1304    ) -> ProjectLocationJobCreateCall<'a, C> {
1305        self._delegate = Some(new_value);
1306        self
1307    }
1308
1309    /// Set any additional parameter of the query string used in the request.
1310    /// It should be used to set parameters which are not yet available through their own
1311    /// setters.
1312    ///
1313    /// Please note that this method must not be used to set any of the known parameters
1314    /// which have their own setter method. If done anyway, the request will fail.
1315    ///
1316    /// # Additional Parameters
1317    ///
1318    /// * *$.xgafv* (query-string) - V1 error format.
1319    /// * *access_token* (query-string) - OAuth access token.
1320    /// * *alt* (query-string) - Data format for response.
1321    /// * *callback* (query-string) - JSONP
1322    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1323    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1324    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1325    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1326    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1327    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1328    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1329    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobCreateCall<'a, C>
1330    where
1331        T: AsRef<str>,
1332    {
1333        self._additional_params
1334            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1335        self
1336    }
1337
1338    /// Identifies the authorization scope for the method you are building.
1339    ///
1340    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1341    /// [`Scope::CloudPlatform`].
1342    ///
1343    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1344    /// tokens for more than one scope.
1345    ///
1346    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1347    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1348    /// sufficient, a read-write scope will do as well.
1349    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobCreateCall<'a, C>
1350    where
1351        St: AsRef<str>,
1352    {
1353        self._scopes.insert(String::from(scope.as_ref()));
1354        self
1355    }
1356    /// Identifies the authorization scope(s) for the method you are building.
1357    ///
1358    /// See [`Self::add_scope()`] for details.
1359    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobCreateCall<'a, C>
1360    where
1361        I: IntoIterator<Item = St>,
1362        St: AsRef<str>,
1363    {
1364        self._scopes
1365            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1366        self
1367    }
1368
1369    /// Removes all scopes, and no default scope will be used either.
1370    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1371    /// for details).
1372    pub fn clear_scopes(mut self) -> ProjectLocationJobCreateCall<'a, C> {
1373        self._scopes.clear();
1374        self
1375    }
1376}
1377
1378/// Deletes a job.
1379///
1380/// A builder for the *locations.jobs.delete* method supported by a *project* resource.
1381/// It is not used directly, but through a [`ProjectMethods`] instance.
1382///
1383/// # Example
1384///
1385/// Instantiate a resource method builder
1386///
1387/// ```test_harness,no_run
1388/// # extern crate hyper;
1389/// # extern crate hyper_rustls;
1390/// # extern crate google_cloudscheduler1 as cloudscheduler1;
1391/// # async fn dox() {
1392/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1393///
1394/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1395/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1396/// #     .with_native_roots()
1397/// #     .unwrap()
1398/// #     .https_only()
1399/// #     .enable_http2()
1400/// #     .build();
1401///
1402/// # let executor = hyper_util::rt::TokioExecutor::new();
1403/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1404/// #     secret,
1405/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1406/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1407/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1408/// #     ),
1409/// # ).build().await.unwrap();
1410///
1411/// # let client = hyper_util::client::legacy::Client::builder(
1412/// #     hyper_util::rt::TokioExecutor::new()
1413/// # )
1414/// # .build(
1415/// #     hyper_rustls::HttpsConnectorBuilder::new()
1416/// #         .with_native_roots()
1417/// #         .unwrap()
1418/// #         .https_or_http()
1419/// #         .enable_http2()
1420/// #         .build()
1421/// # );
1422/// # let mut hub = CloudScheduler::new(client, auth);
1423/// // You can configure optional parameters by calling the respective setters at will, and
1424/// // execute the final call using `doit()`.
1425/// // Values shown here are possibly random and not representative !
1426/// let result = hub.projects().locations_jobs_delete("name")
1427///              .doit().await;
1428/// # }
1429/// ```
1430pub struct ProjectLocationJobDeleteCall<'a, C>
1431where
1432    C: 'a,
1433{
1434    hub: &'a CloudScheduler<C>,
1435    _name: String,
1436    _delegate: Option<&'a mut dyn common::Delegate>,
1437    _additional_params: HashMap<String, String>,
1438    _scopes: BTreeSet<String>,
1439}
1440
1441impl<'a, C> common::CallBuilder for ProjectLocationJobDeleteCall<'a, C> {}
1442
1443impl<'a, C> ProjectLocationJobDeleteCall<'a, C>
1444where
1445    C: common::Connector,
1446{
1447    /// Perform the operation you have build so far.
1448    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1449        use std::borrow::Cow;
1450        use std::io::{Read, Seek};
1451
1452        use common::{url::Params, ToParts};
1453        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1454
1455        let mut dd = common::DefaultDelegate;
1456        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1457        dlg.begin(common::MethodInfo {
1458            id: "cloudscheduler.projects.locations.jobs.delete",
1459            http_method: hyper::Method::DELETE,
1460        });
1461
1462        for &field in ["alt", "name"].iter() {
1463            if self._additional_params.contains_key(field) {
1464                dlg.finished(false);
1465                return Err(common::Error::FieldClash(field));
1466            }
1467        }
1468
1469        let mut params = Params::with_capacity(3 + self._additional_params.len());
1470        params.push("name", self._name);
1471
1472        params.extend(self._additional_params.iter());
1473
1474        params.push("alt", "json");
1475        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1476        if self._scopes.is_empty() {
1477            self._scopes
1478                .insert(Scope::CloudPlatform.as_ref().to_string());
1479        }
1480
1481        #[allow(clippy::single_element_loop)]
1482        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1483            url = params.uri_replacement(url, param_name, find_this, true);
1484        }
1485        {
1486            let to_remove = ["name"];
1487            params.remove_params(&to_remove);
1488        }
1489
1490        let url = params.parse_with_url(&url);
1491
1492        loop {
1493            let token = match self
1494                .hub
1495                .auth
1496                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1497                .await
1498            {
1499                Ok(token) => token,
1500                Err(e) => match dlg.token(e) {
1501                    Ok(token) => token,
1502                    Err(e) => {
1503                        dlg.finished(false);
1504                        return Err(common::Error::MissingToken(e));
1505                    }
1506                },
1507            };
1508            let mut req_result = {
1509                let client = &self.hub.client;
1510                dlg.pre_request();
1511                let mut req_builder = hyper::Request::builder()
1512                    .method(hyper::Method::DELETE)
1513                    .uri(url.as_str())
1514                    .header(USER_AGENT, self.hub._user_agent.clone());
1515
1516                if let Some(token) = token.as_ref() {
1517                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1518                }
1519
1520                let request = req_builder
1521                    .header(CONTENT_LENGTH, 0_u64)
1522                    .body(common::to_body::<String>(None));
1523
1524                client.request(request.unwrap()).await
1525            };
1526
1527            match req_result {
1528                Err(err) => {
1529                    if let common::Retry::After(d) = dlg.http_error(&err) {
1530                        sleep(d).await;
1531                        continue;
1532                    }
1533                    dlg.finished(false);
1534                    return Err(common::Error::HttpError(err));
1535                }
1536                Ok(res) => {
1537                    let (mut parts, body) = res.into_parts();
1538                    let mut body = common::Body::new(body);
1539                    if !parts.status.is_success() {
1540                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1541                        let error = serde_json::from_str(&common::to_string(&bytes));
1542                        let response = common::to_response(parts, bytes.into());
1543
1544                        if let common::Retry::After(d) =
1545                            dlg.http_failure(&response, error.as_ref().ok())
1546                        {
1547                            sleep(d).await;
1548                            continue;
1549                        }
1550
1551                        dlg.finished(false);
1552
1553                        return Err(match error {
1554                            Ok(value) => common::Error::BadRequest(value),
1555                            _ => common::Error::Failure(response),
1556                        });
1557                    }
1558                    let response = {
1559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1560                        let encoded = common::to_string(&bytes);
1561                        match serde_json::from_str(&encoded) {
1562                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1563                            Err(error) => {
1564                                dlg.response_json_decode_error(&encoded, &error);
1565                                return Err(common::Error::JsonDecodeError(
1566                                    encoded.to_string(),
1567                                    error,
1568                                ));
1569                            }
1570                        }
1571                    };
1572
1573                    dlg.finished(true);
1574                    return Ok(response);
1575                }
1576            }
1577        }
1578    }
1579
1580    /// Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
1581    ///
1582    /// Sets the *name* path property to the given value.
1583    ///
1584    /// Even though the property as already been set when instantiating this call,
1585    /// we provide this method for API completeness.
1586    pub fn name(mut self, new_value: &str) -> ProjectLocationJobDeleteCall<'a, C> {
1587        self._name = new_value.to_string();
1588        self
1589    }
1590    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1591    /// while executing the actual API request.
1592    ///
1593    /// ````text
1594    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1595    /// ````
1596    ///
1597    /// Sets the *delegate* property to the given value.
1598    pub fn delegate(
1599        mut self,
1600        new_value: &'a mut dyn common::Delegate,
1601    ) -> ProjectLocationJobDeleteCall<'a, C> {
1602        self._delegate = Some(new_value);
1603        self
1604    }
1605
1606    /// Set any additional parameter of the query string used in the request.
1607    /// It should be used to set parameters which are not yet available through their own
1608    /// setters.
1609    ///
1610    /// Please note that this method must not be used to set any of the known parameters
1611    /// which have their own setter method. If done anyway, the request will fail.
1612    ///
1613    /// # Additional Parameters
1614    ///
1615    /// * *$.xgafv* (query-string) - V1 error format.
1616    /// * *access_token* (query-string) - OAuth access token.
1617    /// * *alt* (query-string) - Data format for response.
1618    /// * *callback* (query-string) - JSONP
1619    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1620    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1621    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1622    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1623    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1624    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1625    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1626    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobDeleteCall<'a, C>
1627    where
1628        T: AsRef<str>,
1629    {
1630        self._additional_params
1631            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1632        self
1633    }
1634
1635    /// Identifies the authorization scope for the method you are building.
1636    ///
1637    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1638    /// [`Scope::CloudPlatform`].
1639    ///
1640    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1641    /// tokens for more than one scope.
1642    ///
1643    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1644    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1645    /// sufficient, a read-write scope will do as well.
1646    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobDeleteCall<'a, C>
1647    where
1648        St: AsRef<str>,
1649    {
1650        self._scopes.insert(String::from(scope.as_ref()));
1651        self
1652    }
1653    /// Identifies the authorization scope(s) for the method you are building.
1654    ///
1655    /// See [`Self::add_scope()`] for details.
1656    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobDeleteCall<'a, C>
1657    where
1658        I: IntoIterator<Item = St>,
1659        St: AsRef<str>,
1660    {
1661        self._scopes
1662            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1663        self
1664    }
1665
1666    /// Removes all scopes, and no default scope will be used either.
1667    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1668    /// for details).
1669    pub fn clear_scopes(mut self) -> ProjectLocationJobDeleteCall<'a, C> {
1670        self._scopes.clear();
1671        self
1672    }
1673}
1674
1675/// Gets a job.
1676///
1677/// A builder for the *locations.jobs.get* method supported by a *project* resource.
1678/// It is not used directly, but through a [`ProjectMethods`] instance.
1679///
1680/// # Example
1681///
1682/// Instantiate a resource method builder
1683///
1684/// ```test_harness,no_run
1685/// # extern crate hyper;
1686/// # extern crate hyper_rustls;
1687/// # extern crate google_cloudscheduler1 as cloudscheduler1;
1688/// # async fn dox() {
1689/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1690///
1691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1693/// #     .with_native_roots()
1694/// #     .unwrap()
1695/// #     .https_only()
1696/// #     .enable_http2()
1697/// #     .build();
1698///
1699/// # let executor = hyper_util::rt::TokioExecutor::new();
1700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1701/// #     secret,
1702/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1703/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1704/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1705/// #     ),
1706/// # ).build().await.unwrap();
1707///
1708/// # let client = hyper_util::client::legacy::Client::builder(
1709/// #     hyper_util::rt::TokioExecutor::new()
1710/// # )
1711/// # .build(
1712/// #     hyper_rustls::HttpsConnectorBuilder::new()
1713/// #         .with_native_roots()
1714/// #         .unwrap()
1715/// #         .https_or_http()
1716/// #         .enable_http2()
1717/// #         .build()
1718/// # );
1719/// # let mut hub = CloudScheduler::new(client, auth);
1720/// // You can configure optional parameters by calling the respective setters at will, and
1721/// // execute the final call using `doit()`.
1722/// // Values shown here are possibly random and not representative !
1723/// let result = hub.projects().locations_jobs_get("name")
1724///              .doit().await;
1725/// # }
1726/// ```
1727pub struct ProjectLocationJobGetCall<'a, C>
1728where
1729    C: 'a,
1730{
1731    hub: &'a CloudScheduler<C>,
1732    _name: String,
1733    _delegate: Option<&'a mut dyn common::Delegate>,
1734    _additional_params: HashMap<String, String>,
1735    _scopes: BTreeSet<String>,
1736}
1737
1738impl<'a, C> common::CallBuilder for ProjectLocationJobGetCall<'a, C> {}
1739
1740impl<'a, C> ProjectLocationJobGetCall<'a, C>
1741where
1742    C: common::Connector,
1743{
1744    /// Perform the operation you have build so far.
1745    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
1746        use std::borrow::Cow;
1747        use std::io::{Read, Seek};
1748
1749        use common::{url::Params, ToParts};
1750        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1751
1752        let mut dd = common::DefaultDelegate;
1753        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1754        dlg.begin(common::MethodInfo {
1755            id: "cloudscheduler.projects.locations.jobs.get",
1756            http_method: hyper::Method::GET,
1757        });
1758
1759        for &field in ["alt", "name"].iter() {
1760            if self._additional_params.contains_key(field) {
1761                dlg.finished(false);
1762                return Err(common::Error::FieldClash(field));
1763            }
1764        }
1765
1766        let mut params = Params::with_capacity(3 + self._additional_params.len());
1767        params.push("name", self._name);
1768
1769        params.extend(self._additional_params.iter());
1770
1771        params.push("alt", "json");
1772        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1773        if self._scopes.is_empty() {
1774            self._scopes
1775                .insert(Scope::CloudPlatform.as_ref().to_string());
1776        }
1777
1778        #[allow(clippy::single_element_loop)]
1779        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1780            url = params.uri_replacement(url, param_name, find_this, true);
1781        }
1782        {
1783            let to_remove = ["name"];
1784            params.remove_params(&to_remove);
1785        }
1786
1787        let url = params.parse_with_url(&url);
1788
1789        loop {
1790            let token = match self
1791                .hub
1792                .auth
1793                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1794                .await
1795            {
1796                Ok(token) => token,
1797                Err(e) => match dlg.token(e) {
1798                    Ok(token) => token,
1799                    Err(e) => {
1800                        dlg.finished(false);
1801                        return Err(common::Error::MissingToken(e));
1802                    }
1803                },
1804            };
1805            let mut req_result = {
1806                let client = &self.hub.client;
1807                dlg.pre_request();
1808                let mut req_builder = hyper::Request::builder()
1809                    .method(hyper::Method::GET)
1810                    .uri(url.as_str())
1811                    .header(USER_AGENT, self.hub._user_agent.clone());
1812
1813                if let Some(token) = token.as_ref() {
1814                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1815                }
1816
1817                let request = req_builder
1818                    .header(CONTENT_LENGTH, 0_u64)
1819                    .body(common::to_body::<String>(None));
1820
1821                client.request(request.unwrap()).await
1822            };
1823
1824            match req_result {
1825                Err(err) => {
1826                    if let common::Retry::After(d) = dlg.http_error(&err) {
1827                        sleep(d).await;
1828                        continue;
1829                    }
1830                    dlg.finished(false);
1831                    return Err(common::Error::HttpError(err));
1832                }
1833                Ok(res) => {
1834                    let (mut parts, body) = res.into_parts();
1835                    let mut body = common::Body::new(body);
1836                    if !parts.status.is_success() {
1837                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1838                        let error = serde_json::from_str(&common::to_string(&bytes));
1839                        let response = common::to_response(parts, bytes.into());
1840
1841                        if let common::Retry::After(d) =
1842                            dlg.http_failure(&response, error.as_ref().ok())
1843                        {
1844                            sleep(d).await;
1845                            continue;
1846                        }
1847
1848                        dlg.finished(false);
1849
1850                        return Err(match error {
1851                            Ok(value) => common::Error::BadRequest(value),
1852                            _ => common::Error::Failure(response),
1853                        });
1854                    }
1855                    let response = {
1856                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1857                        let encoded = common::to_string(&bytes);
1858                        match serde_json::from_str(&encoded) {
1859                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1860                            Err(error) => {
1861                                dlg.response_json_decode_error(&encoded, &error);
1862                                return Err(common::Error::JsonDecodeError(
1863                                    encoded.to_string(),
1864                                    error,
1865                                ));
1866                            }
1867                        }
1868                    };
1869
1870                    dlg.finished(true);
1871                    return Ok(response);
1872                }
1873            }
1874        }
1875    }
1876
1877    /// Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
1878    ///
1879    /// Sets the *name* path property to the given value.
1880    ///
1881    /// Even though the property as already been set when instantiating this call,
1882    /// we provide this method for API completeness.
1883    pub fn name(mut self, new_value: &str) -> ProjectLocationJobGetCall<'a, C> {
1884        self._name = new_value.to_string();
1885        self
1886    }
1887    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1888    /// while executing the actual API request.
1889    ///
1890    /// ````text
1891    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1892    /// ````
1893    ///
1894    /// Sets the *delegate* property to the given value.
1895    pub fn delegate(
1896        mut self,
1897        new_value: &'a mut dyn common::Delegate,
1898    ) -> ProjectLocationJobGetCall<'a, C> {
1899        self._delegate = Some(new_value);
1900        self
1901    }
1902
1903    /// Set any additional parameter of the query string used in the request.
1904    /// It should be used to set parameters which are not yet available through their own
1905    /// setters.
1906    ///
1907    /// Please note that this method must not be used to set any of the known parameters
1908    /// which have their own setter method. If done anyway, the request will fail.
1909    ///
1910    /// # Additional Parameters
1911    ///
1912    /// * *$.xgafv* (query-string) - V1 error format.
1913    /// * *access_token* (query-string) - OAuth access token.
1914    /// * *alt* (query-string) - Data format for response.
1915    /// * *callback* (query-string) - JSONP
1916    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1917    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1918    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1919    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1920    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1921    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1922    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1923    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobGetCall<'a, C>
1924    where
1925        T: AsRef<str>,
1926    {
1927        self._additional_params
1928            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1929        self
1930    }
1931
1932    /// Identifies the authorization scope for the method you are building.
1933    ///
1934    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1935    /// [`Scope::CloudPlatform`].
1936    ///
1937    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1938    /// tokens for more than one scope.
1939    ///
1940    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1941    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1942    /// sufficient, a read-write scope will do as well.
1943    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobGetCall<'a, C>
1944    where
1945        St: AsRef<str>,
1946    {
1947        self._scopes.insert(String::from(scope.as_ref()));
1948        self
1949    }
1950    /// Identifies the authorization scope(s) for the method you are building.
1951    ///
1952    /// See [`Self::add_scope()`] for details.
1953    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobGetCall<'a, C>
1954    where
1955        I: IntoIterator<Item = St>,
1956        St: AsRef<str>,
1957    {
1958        self._scopes
1959            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1960        self
1961    }
1962
1963    /// Removes all scopes, and no default scope will be used either.
1964    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1965    /// for details).
1966    pub fn clear_scopes(mut self) -> ProjectLocationJobGetCall<'a, C> {
1967        self._scopes.clear();
1968        self
1969    }
1970}
1971
1972/// Lists jobs.
1973///
1974/// A builder for the *locations.jobs.list* method supported by a *project* resource.
1975/// It is not used directly, but through a [`ProjectMethods`] instance.
1976///
1977/// # Example
1978///
1979/// Instantiate a resource method builder
1980///
1981/// ```test_harness,no_run
1982/// # extern crate hyper;
1983/// # extern crate hyper_rustls;
1984/// # extern crate google_cloudscheduler1 as cloudscheduler1;
1985/// # async fn dox() {
1986/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1987///
1988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1989/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1990/// #     .with_native_roots()
1991/// #     .unwrap()
1992/// #     .https_only()
1993/// #     .enable_http2()
1994/// #     .build();
1995///
1996/// # let executor = hyper_util::rt::TokioExecutor::new();
1997/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1998/// #     secret,
1999/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2000/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2001/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2002/// #     ),
2003/// # ).build().await.unwrap();
2004///
2005/// # let client = hyper_util::client::legacy::Client::builder(
2006/// #     hyper_util::rt::TokioExecutor::new()
2007/// # )
2008/// # .build(
2009/// #     hyper_rustls::HttpsConnectorBuilder::new()
2010/// #         .with_native_roots()
2011/// #         .unwrap()
2012/// #         .https_or_http()
2013/// #         .enable_http2()
2014/// #         .build()
2015/// # );
2016/// # let mut hub = CloudScheduler::new(client, auth);
2017/// // You can configure optional parameters by calling the respective setters at will, and
2018/// // execute the final call using `doit()`.
2019/// // Values shown here are possibly random and not representative !
2020/// let result = hub.projects().locations_jobs_list("parent")
2021///              .page_token("sed")
2022///              .page_size(-2)
2023///              .doit().await;
2024/// # }
2025/// ```
2026pub struct ProjectLocationJobListCall<'a, C>
2027where
2028    C: 'a,
2029{
2030    hub: &'a CloudScheduler<C>,
2031    _parent: String,
2032    _page_token: Option<String>,
2033    _page_size: Option<i32>,
2034    _delegate: Option<&'a mut dyn common::Delegate>,
2035    _additional_params: HashMap<String, String>,
2036    _scopes: BTreeSet<String>,
2037}
2038
2039impl<'a, C> common::CallBuilder for ProjectLocationJobListCall<'a, C> {}
2040
2041impl<'a, C> ProjectLocationJobListCall<'a, C>
2042where
2043    C: common::Connector,
2044{
2045    /// Perform the operation you have build so far.
2046    pub async fn doit(mut self) -> common::Result<(common::Response, ListJobsResponse)> {
2047        use std::borrow::Cow;
2048        use std::io::{Read, Seek};
2049
2050        use common::{url::Params, ToParts};
2051        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2052
2053        let mut dd = common::DefaultDelegate;
2054        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2055        dlg.begin(common::MethodInfo {
2056            id: "cloudscheduler.projects.locations.jobs.list",
2057            http_method: hyper::Method::GET,
2058        });
2059
2060        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2061            if self._additional_params.contains_key(field) {
2062                dlg.finished(false);
2063                return Err(common::Error::FieldClash(field));
2064            }
2065        }
2066
2067        let mut params = Params::with_capacity(5 + self._additional_params.len());
2068        params.push("parent", self._parent);
2069        if let Some(value) = self._page_token.as_ref() {
2070            params.push("pageToken", value);
2071        }
2072        if let Some(value) = self._page_size.as_ref() {
2073            params.push("pageSize", value.to_string());
2074        }
2075
2076        params.extend(self._additional_params.iter());
2077
2078        params.push("alt", "json");
2079        let mut url = self.hub._base_url.clone() + "v1/{+parent}/jobs";
2080        if self._scopes.is_empty() {
2081            self._scopes
2082                .insert(Scope::CloudPlatform.as_ref().to_string());
2083        }
2084
2085        #[allow(clippy::single_element_loop)]
2086        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2087            url = params.uri_replacement(url, param_name, find_this, true);
2088        }
2089        {
2090            let to_remove = ["parent"];
2091            params.remove_params(&to_remove);
2092        }
2093
2094        let url = params.parse_with_url(&url);
2095
2096        loop {
2097            let token = match self
2098                .hub
2099                .auth
2100                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2101                .await
2102            {
2103                Ok(token) => token,
2104                Err(e) => match dlg.token(e) {
2105                    Ok(token) => token,
2106                    Err(e) => {
2107                        dlg.finished(false);
2108                        return Err(common::Error::MissingToken(e));
2109                    }
2110                },
2111            };
2112            let mut req_result = {
2113                let client = &self.hub.client;
2114                dlg.pre_request();
2115                let mut req_builder = hyper::Request::builder()
2116                    .method(hyper::Method::GET)
2117                    .uri(url.as_str())
2118                    .header(USER_AGENT, self.hub._user_agent.clone());
2119
2120                if let Some(token) = token.as_ref() {
2121                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2122                }
2123
2124                let request = req_builder
2125                    .header(CONTENT_LENGTH, 0_u64)
2126                    .body(common::to_body::<String>(None));
2127
2128                client.request(request.unwrap()).await
2129            };
2130
2131            match req_result {
2132                Err(err) => {
2133                    if let common::Retry::After(d) = dlg.http_error(&err) {
2134                        sleep(d).await;
2135                        continue;
2136                    }
2137                    dlg.finished(false);
2138                    return Err(common::Error::HttpError(err));
2139                }
2140                Ok(res) => {
2141                    let (mut parts, body) = res.into_parts();
2142                    let mut body = common::Body::new(body);
2143                    if !parts.status.is_success() {
2144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2145                        let error = serde_json::from_str(&common::to_string(&bytes));
2146                        let response = common::to_response(parts, bytes.into());
2147
2148                        if let common::Retry::After(d) =
2149                            dlg.http_failure(&response, error.as_ref().ok())
2150                        {
2151                            sleep(d).await;
2152                            continue;
2153                        }
2154
2155                        dlg.finished(false);
2156
2157                        return Err(match error {
2158                            Ok(value) => common::Error::BadRequest(value),
2159                            _ => common::Error::Failure(response),
2160                        });
2161                    }
2162                    let response = {
2163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2164                        let encoded = common::to_string(&bytes);
2165                        match serde_json::from_str(&encoded) {
2166                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2167                            Err(error) => {
2168                                dlg.response_json_decode_error(&encoded, &error);
2169                                return Err(common::Error::JsonDecodeError(
2170                                    encoded.to_string(),
2171                                    error,
2172                                ));
2173                            }
2174                        }
2175                    };
2176
2177                    dlg.finished(true);
2178                    return Ok(response);
2179                }
2180            }
2181        }
2182    }
2183
2184    /// Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`.
2185    ///
2186    /// Sets the *parent* path property to the given value.
2187    ///
2188    /// Even though the property as already been set when instantiating this call,
2189    /// we provide this method for API completeness.
2190    pub fn parent(mut self, new_value: &str) -> ProjectLocationJobListCall<'a, C> {
2191        self._parent = new_value.to_string();
2192        self
2193    }
2194    /// 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 returned from the previous call to ListJobs.
2195    ///
2196    /// Sets the *page token* query property to the given value.
2197    pub fn page_token(mut self, new_value: &str) -> ProjectLocationJobListCall<'a, C> {
2198        self._page_token = Some(new_value.to_string());
2199        self
2200    }
2201    /// Requested page size. The maximum page size is 500. If unspecified, the page size will be the maximum. Fewer jobs than requested might be returned, even if more jobs exist; use next_page_token to determine if more jobs exist.
2202    ///
2203    /// Sets the *page size* query property to the given value.
2204    pub fn page_size(mut self, new_value: i32) -> ProjectLocationJobListCall<'a, C> {
2205        self._page_size = Some(new_value);
2206        self
2207    }
2208    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2209    /// while executing the actual API request.
2210    ///
2211    /// ````text
2212    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2213    /// ````
2214    ///
2215    /// Sets the *delegate* property to the given value.
2216    pub fn delegate(
2217        mut self,
2218        new_value: &'a mut dyn common::Delegate,
2219    ) -> ProjectLocationJobListCall<'a, C> {
2220        self._delegate = Some(new_value);
2221        self
2222    }
2223
2224    /// Set any additional parameter of the query string used in the request.
2225    /// It should be used to set parameters which are not yet available through their own
2226    /// setters.
2227    ///
2228    /// Please note that this method must not be used to set any of the known parameters
2229    /// which have their own setter method. If done anyway, the request will fail.
2230    ///
2231    /// # Additional Parameters
2232    ///
2233    /// * *$.xgafv* (query-string) - V1 error format.
2234    /// * *access_token* (query-string) - OAuth access token.
2235    /// * *alt* (query-string) - Data format for response.
2236    /// * *callback* (query-string) - JSONP
2237    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2238    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2239    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2240    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2241    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2242    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2243    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2244    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobListCall<'a, C>
2245    where
2246        T: AsRef<str>,
2247    {
2248        self._additional_params
2249            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2250        self
2251    }
2252
2253    /// Identifies the authorization scope for the method you are building.
2254    ///
2255    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2256    /// [`Scope::CloudPlatform`].
2257    ///
2258    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2259    /// tokens for more than one scope.
2260    ///
2261    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2262    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2263    /// sufficient, a read-write scope will do as well.
2264    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobListCall<'a, C>
2265    where
2266        St: AsRef<str>,
2267    {
2268        self._scopes.insert(String::from(scope.as_ref()));
2269        self
2270    }
2271    /// Identifies the authorization scope(s) for the method you are building.
2272    ///
2273    /// See [`Self::add_scope()`] for details.
2274    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobListCall<'a, C>
2275    where
2276        I: IntoIterator<Item = St>,
2277        St: AsRef<str>,
2278    {
2279        self._scopes
2280            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2281        self
2282    }
2283
2284    /// Removes all scopes, and no default scope will be used either.
2285    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2286    /// for details).
2287    pub fn clear_scopes(mut self) -> ProjectLocationJobListCall<'a, C> {
2288        self._scopes.clear();
2289        self
2290    }
2291}
2292
2293/// Updates a job. If successful, the updated 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 state. A job in this state may not be executed. If this happens, retry the UpdateJob request until a successful response is received.
2294///
2295/// A builder for the *locations.jobs.patch* method supported by a *project* resource.
2296/// It is not used directly, but through a [`ProjectMethods`] instance.
2297///
2298/// # Example
2299///
2300/// Instantiate a resource method builder
2301///
2302/// ```test_harness,no_run
2303/// # extern crate hyper;
2304/// # extern crate hyper_rustls;
2305/// # extern crate google_cloudscheduler1 as cloudscheduler1;
2306/// use cloudscheduler1::api::Job;
2307/// # async fn dox() {
2308/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2309///
2310/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2311/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2312/// #     .with_native_roots()
2313/// #     .unwrap()
2314/// #     .https_only()
2315/// #     .enable_http2()
2316/// #     .build();
2317///
2318/// # let executor = hyper_util::rt::TokioExecutor::new();
2319/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2320/// #     secret,
2321/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2322/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2323/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2324/// #     ),
2325/// # ).build().await.unwrap();
2326///
2327/// # let client = hyper_util::client::legacy::Client::builder(
2328/// #     hyper_util::rt::TokioExecutor::new()
2329/// # )
2330/// # .build(
2331/// #     hyper_rustls::HttpsConnectorBuilder::new()
2332/// #         .with_native_roots()
2333/// #         .unwrap()
2334/// #         .https_or_http()
2335/// #         .enable_http2()
2336/// #         .build()
2337/// # );
2338/// # let mut hub = CloudScheduler::new(client, auth);
2339/// // As the method needs a request, you would usually fill it with the desired information
2340/// // into the respective structure. Some of the parts shown here might not be applicable !
2341/// // Values shown here are possibly random and not representative !
2342/// let mut req = Job::default();
2343///
2344/// // You can configure optional parameters by calling the respective setters at will, and
2345/// // execute the final call using `doit()`.
2346/// // Values shown here are possibly random and not representative !
2347/// let result = hub.projects().locations_jobs_patch(req, "name")
2348///              .update_mask(FieldMask::new::<&str>(&[]))
2349///              .doit().await;
2350/// # }
2351/// ```
2352pub struct ProjectLocationJobPatchCall<'a, C>
2353where
2354    C: 'a,
2355{
2356    hub: &'a CloudScheduler<C>,
2357    _request: Job,
2358    _name: String,
2359    _update_mask: Option<common::FieldMask>,
2360    _delegate: Option<&'a mut dyn common::Delegate>,
2361    _additional_params: HashMap<String, String>,
2362    _scopes: BTreeSet<String>,
2363}
2364
2365impl<'a, C> common::CallBuilder for ProjectLocationJobPatchCall<'a, C> {}
2366
2367impl<'a, C> ProjectLocationJobPatchCall<'a, C>
2368where
2369    C: common::Connector,
2370{
2371    /// Perform the operation you have build so far.
2372    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
2373        use std::borrow::Cow;
2374        use std::io::{Read, Seek};
2375
2376        use common::{url::Params, ToParts};
2377        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2378
2379        let mut dd = common::DefaultDelegate;
2380        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2381        dlg.begin(common::MethodInfo {
2382            id: "cloudscheduler.projects.locations.jobs.patch",
2383            http_method: hyper::Method::PATCH,
2384        });
2385
2386        for &field in ["alt", "name", "updateMask"].iter() {
2387            if self._additional_params.contains_key(field) {
2388                dlg.finished(false);
2389                return Err(common::Error::FieldClash(field));
2390            }
2391        }
2392
2393        let mut params = Params::with_capacity(5 + self._additional_params.len());
2394        params.push("name", self._name);
2395        if let Some(value) = self._update_mask.as_ref() {
2396            params.push("updateMask", value.to_string());
2397        }
2398
2399        params.extend(self._additional_params.iter());
2400
2401        params.push("alt", "json");
2402        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2403        if self._scopes.is_empty() {
2404            self._scopes
2405                .insert(Scope::CloudPlatform.as_ref().to_string());
2406        }
2407
2408        #[allow(clippy::single_element_loop)]
2409        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2410            url = params.uri_replacement(url, param_name, find_this, true);
2411        }
2412        {
2413            let to_remove = ["name"];
2414            params.remove_params(&to_remove);
2415        }
2416
2417        let url = params.parse_with_url(&url);
2418
2419        let mut json_mime_type = mime::APPLICATION_JSON;
2420        let mut request_value_reader = {
2421            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2422            common::remove_json_null_values(&mut value);
2423            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2424            serde_json::to_writer(&mut dst, &value).unwrap();
2425            dst
2426        };
2427        let request_size = request_value_reader
2428            .seek(std::io::SeekFrom::End(0))
2429            .unwrap();
2430        request_value_reader
2431            .seek(std::io::SeekFrom::Start(0))
2432            .unwrap();
2433
2434        loop {
2435            let token = match self
2436                .hub
2437                .auth
2438                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2439                .await
2440            {
2441                Ok(token) => token,
2442                Err(e) => match dlg.token(e) {
2443                    Ok(token) => token,
2444                    Err(e) => {
2445                        dlg.finished(false);
2446                        return Err(common::Error::MissingToken(e));
2447                    }
2448                },
2449            };
2450            request_value_reader
2451                .seek(std::io::SeekFrom::Start(0))
2452                .unwrap();
2453            let mut req_result = {
2454                let client = &self.hub.client;
2455                dlg.pre_request();
2456                let mut req_builder = hyper::Request::builder()
2457                    .method(hyper::Method::PATCH)
2458                    .uri(url.as_str())
2459                    .header(USER_AGENT, self.hub._user_agent.clone());
2460
2461                if let Some(token) = token.as_ref() {
2462                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2463                }
2464
2465                let request = req_builder
2466                    .header(CONTENT_TYPE, json_mime_type.to_string())
2467                    .header(CONTENT_LENGTH, request_size as u64)
2468                    .body(common::to_body(
2469                        request_value_reader.get_ref().clone().into(),
2470                    ));
2471
2472                client.request(request.unwrap()).await
2473            };
2474
2475            match req_result {
2476                Err(err) => {
2477                    if let common::Retry::After(d) = dlg.http_error(&err) {
2478                        sleep(d).await;
2479                        continue;
2480                    }
2481                    dlg.finished(false);
2482                    return Err(common::Error::HttpError(err));
2483                }
2484                Ok(res) => {
2485                    let (mut parts, body) = res.into_parts();
2486                    let mut body = common::Body::new(body);
2487                    if !parts.status.is_success() {
2488                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2489                        let error = serde_json::from_str(&common::to_string(&bytes));
2490                        let response = common::to_response(parts, bytes.into());
2491
2492                        if let common::Retry::After(d) =
2493                            dlg.http_failure(&response, error.as_ref().ok())
2494                        {
2495                            sleep(d).await;
2496                            continue;
2497                        }
2498
2499                        dlg.finished(false);
2500
2501                        return Err(match error {
2502                            Ok(value) => common::Error::BadRequest(value),
2503                            _ => common::Error::Failure(response),
2504                        });
2505                    }
2506                    let response = {
2507                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2508                        let encoded = common::to_string(&bytes);
2509                        match serde_json::from_str(&encoded) {
2510                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2511                            Err(error) => {
2512                                dlg.response_json_decode_error(&encoded, &error);
2513                                return Err(common::Error::JsonDecodeError(
2514                                    encoded.to_string(),
2515                                    error,
2516                                ));
2517                            }
2518                        }
2519                    };
2520
2521                    dlg.finished(true);
2522                    return Ok(response);
2523                }
2524            }
2525        }
2526    }
2527
2528    ///
2529    /// Sets the *request* property to the given value.
2530    ///
2531    /// Even though the property as already been set when instantiating this call,
2532    /// we provide this method for API completeness.
2533    pub fn request(mut self, new_value: Job) -> ProjectLocationJobPatchCall<'a, C> {
2534        self._request = new_value;
2535        self
2536    }
2537    /// Optionally caller-specified in CreateJob, after which it becomes output only. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. * `PROJECT_ID` can contain letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), colons (:), or periods (.). For more information, see [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) * `LOCATION_ID` is the canonical ID for the job’s location. The list of available locations can be obtained by calling [locations.list](https://cloud.google.com/scheduler/docs/reference/rest/v1/projects.locations/list). For more information, see [Cloud Scheduler locations](https://cloud.google.com/scheduler/docs/locations). * `JOB_ID` can contain only letters (\[A-Za-z\]), numbers (\[0-9\]), hyphens (-), or underscores (\_). The maximum length is 500 characters.
2538    ///
2539    /// Sets the *name* path property to the given value.
2540    ///
2541    /// Even though the property as already been set when instantiating this call,
2542    /// we provide this method for API completeness.
2543    pub fn name(mut self, new_value: &str) -> ProjectLocationJobPatchCall<'a, C> {
2544        self._name = new_value.to_string();
2545        self
2546    }
2547    /// A mask used to specify which fields of the job are being updated.
2548    ///
2549    /// Sets the *update mask* query property to the given value.
2550    pub fn update_mask(
2551        mut self,
2552        new_value: common::FieldMask,
2553    ) -> ProjectLocationJobPatchCall<'a, C> {
2554        self._update_mask = Some(new_value);
2555        self
2556    }
2557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2558    /// while executing the actual API request.
2559    ///
2560    /// ````text
2561    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2562    /// ````
2563    ///
2564    /// Sets the *delegate* property to the given value.
2565    pub fn delegate(
2566        mut self,
2567        new_value: &'a mut dyn common::Delegate,
2568    ) -> ProjectLocationJobPatchCall<'a, C> {
2569        self._delegate = Some(new_value);
2570        self
2571    }
2572
2573    /// Set any additional parameter of the query string used in the request.
2574    /// It should be used to set parameters which are not yet available through their own
2575    /// setters.
2576    ///
2577    /// Please note that this method must not be used to set any of the known parameters
2578    /// which have their own setter method. If done anyway, the request will fail.
2579    ///
2580    /// # Additional Parameters
2581    ///
2582    /// * *$.xgafv* (query-string) - V1 error format.
2583    /// * *access_token* (query-string) - OAuth access token.
2584    /// * *alt* (query-string) - Data format for response.
2585    /// * *callback* (query-string) - JSONP
2586    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2587    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2588    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2589    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2590    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2591    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2592    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2593    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobPatchCall<'a, C>
2594    where
2595        T: AsRef<str>,
2596    {
2597        self._additional_params
2598            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2599        self
2600    }
2601
2602    /// Identifies the authorization scope for the method you are building.
2603    ///
2604    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2605    /// [`Scope::CloudPlatform`].
2606    ///
2607    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2608    /// tokens for more than one scope.
2609    ///
2610    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2611    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2612    /// sufficient, a read-write scope will do as well.
2613    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobPatchCall<'a, C>
2614    where
2615        St: AsRef<str>,
2616    {
2617        self._scopes.insert(String::from(scope.as_ref()));
2618        self
2619    }
2620    /// Identifies the authorization scope(s) for the method you are building.
2621    ///
2622    /// See [`Self::add_scope()`] for details.
2623    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobPatchCall<'a, C>
2624    where
2625        I: IntoIterator<Item = St>,
2626        St: AsRef<str>,
2627    {
2628        self._scopes
2629            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2630        self
2631    }
2632
2633    /// Removes all scopes, and no default scope will be used either.
2634    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2635    /// for details).
2636    pub fn clear_scopes(mut self) -> ProjectLocationJobPatchCall<'a, C> {
2637        self._scopes.clear();
2638        self
2639    }
2640}
2641
2642/// Pauses a job. If a job is paused then the system will stop executing the job until it is re-enabled via ResumeJob. The state of the job is stored in state; if paused it will be set to Job.State.PAUSED. A job must be in Job.State.ENABLED to be paused.
2643///
2644/// A builder for the *locations.jobs.pause* method supported by a *project* resource.
2645/// It is not used directly, but through a [`ProjectMethods`] instance.
2646///
2647/// # Example
2648///
2649/// Instantiate a resource method builder
2650///
2651/// ```test_harness,no_run
2652/// # extern crate hyper;
2653/// # extern crate hyper_rustls;
2654/// # extern crate google_cloudscheduler1 as cloudscheduler1;
2655/// use cloudscheduler1::api::PauseJobRequest;
2656/// # async fn dox() {
2657/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2658///
2659/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2660/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2661/// #     .with_native_roots()
2662/// #     .unwrap()
2663/// #     .https_only()
2664/// #     .enable_http2()
2665/// #     .build();
2666///
2667/// # let executor = hyper_util::rt::TokioExecutor::new();
2668/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2669/// #     secret,
2670/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2671/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2672/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2673/// #     ),
2674/// # ).build().await.unwrap();
2675///
2676/// # let client = hyper_util::client::legacy::Client::builder(
2677/// #     hyper_util::rt::TokioExecutor::new()
2678/// # )
2679/// # .build(
2680/// #     hyper_rustls::HttpsConnectorBuilder::new()
2681/// #         .with_native_roots()
2682/// #         .unwrap()
2683/// #         .https_or_http()
2684/// #         .enable_http2()
2685/// #         .build()
2686/// # );
2687/// # let mut hub = CloudScheduler::new(client, auth);
2688/// // As the method needs a request, you would usually fill it with the desired information
2689/// // into the respective structure. Some of the parts shown here might not be applicable !
2690/// // Values shown here are possibly random and not representative !
2691/// let mut req = PauseJobRequest::default();
2692///
2693/// // You can configure optional parameters by calling the respective setters at will, and
2694/// // execute the final call using `doit()`.
2695/// // Values shown here are possibly random and not representative !
2696/// let result = hub.projects().locations_jobs_pause(req, "name")
2697///              .doit().await;
2698/// # }
2699/// ```
2700pub struct ProjectLocationJobPauseCall<'a, C>
2701where
2702    C: 'a,
2703{
2704    hub: &'a CloudScheduler<C>,
2705    _request: PauseJobRequest,
2706    _name: String,
2707    _delegate: Option<&'a mut dyn common::Delegate>,
2708    _additional_params: HashMap<String, String>,
2709    _scopes: BTreeSet<String>,
2710}
2711
2712impl<'a, C> common::CallBuilder for ProjectLocationJobPauseCall<'a, C> {}
2713
2714impl<'a, C> ProjectLocationJobPauseCall<'a, C>
2715where
2716    C: common::Connector,
2717{
2718    /// Perform the operation you have build so far.
2719    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
2720        use std::borrow::Cow;
2721        use std::io::{Read, Seek};
2722
2723        use common::{url::Params, ToParts};
2724        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2725
2726        let mut dd = common::DefaultDelegate;
2727        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2728        dlg.begin(common::MethodInfo {
2729            id: "cloudscheduler.projects.locations.jobs.pause",
2730            http_method: hyper::Method::POST,
2731        });
2732
2733        for &field in ["alt", "name"].iter() {
2734            if self._additional_params.contains_key(field) {
2735                dlg.finished(false);
2736                return Err(common::Error::FieldClash(field));
2737            }
2738        }
2739
2740        let mut params = Params::with_capacity(4 + self._additional_params.len());
2741        params.push("name", self._name);
2742
2743        params.extend(self._additional_params.iter());
2744
2745        params.push("alt", "json");
2746        let mut url = self.hub._base_url.clone() + "v1/{+name}:pause";
2747        if self._scopes.is_empty() {
2748            self._scopes
2749                .insert(Scope::CloudPlatform.as_ref().to_string());
2750        }
2751
2752        #[allow(clippy::single_element_loop)]
2753        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2754            url = params.uri_replacement(url, param_name, find_this, true);
2755        }
2756        {
2757            let to_remove = ["name"];
2758            params.remove_params(&to_remove);
2759        }
2760
2761        let url = params.parse_with_url(&url);
2762
2763        let mut json_mime_type = mime::APPLICATION_JSON;
2764        let mut request_value_reader = {
2765            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2766            common::remove_json_null_values(&mut value);
2767            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2768            serde_json::to_writer(&mut dst, &value).unwrap();
2769            dst
2770        };
2771        let request_size = request_value_reader
2772            .seek(std::io::SeekFrom::End(0))
2773            .unwrap();
2774        request_value_reader
2775            .seek(std::io::SeekFrom::Start(0))
2776            .unwrap();
2777
2778        loop {
2779            let token = match self
2780                .hub
2781                .auth
2782                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2783                .await
2784            {
2785                Ok(token) => token,
2786                Err(e) => match dlg.token(e) {
2787                    Ok(token) => token,
2788                    Err(e) => {
2789                        dlg.finished(false);
2790                        return Err(common::Error::MissingToken(e));
2791                    }
2792                },
2793            };
2794            request_value_reader
2795                .seek(std::io::SeekFrom::Start(0))
2796                .unwrap();
2797            let mut req_result = {
2798                let client = &self.hub.client;
2799                dlg.pre_request();
2800                let mut req_builder = hyper::Request::builder()
2801                    .method(hyper::Method::POST)
2802                    .uri(url.as_str())
2803                    .header(USER_AGENT, self.hub._user_agent.clone());
2804
2805                if let Some(token) = token.as_ref() {
2806                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2807                }
2808
2809                let request = req_builder
2810                    .header(CONTENT_TYPE, json_mime_type.to_string())
2811                    .header(CONTENT_LENGTH, request_size as u64)
2812                    .body(common::to_body(
2813                        request_value_reader.get_ref().clone().into(),
2814                    ));
2815
2816                client.request(request.unwrap()).await
2817            };
2818
2819            match req_result {
2820                Err(err) => {
2821                    if let common::Retry::After(d) = dlg.http_error(&err) {
2822                        sleep(d).await;
2823                        continue;
2824                    }
2825                    dlg.finished(false);
2826                    return Err(common::Error::HttpError(err));
2827                }
2828                Ok(res) => {
2829                    let (mut parts, body) = res.into_parts();
2830                    let mut body = common::Body::new(body);
2831                    if !parts.status.is_success() {
2832                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2833                        let error = serde_json::from_str(&common::to_string(&bytes));
2834                        let response = common::to_response(parts, bytes.into());
2835
2836                        if let common::Retry::After(d) =
2837                            dlg.http_failure(&response, error.as_ref().ok())
2838                        {
2839                            sleep(d).await;
2840                            continue;
2841                        }
2842
2843                        dlg.finished(false);
2844
2845                        return Err(match error {
2846                            Ok(value) => common::Error::BadRequest(value),
2847                            _ => common::Error::Failure(response),
2848                        });
2849                    }
2850                    let response = {
2851                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2852                        let encoded = common::to_string(&bytes);
2853                        match serde_json::from_str(&encoded) {
2854                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2855                            Err(error) => {
2856                                dlg.response_json_decode_error(&encoded, &error);
2857                                return Err(common::Error::JsonDecodeError(
2858                                    encoded.to_string(),
2859                                    error,
2860                                ));
2861                            }
2862                        }
2863                    };
2864
2865                    dlg.finished(true);
2866                    return Ok(response);
2867                }
2868            }
2869        }
2870    }
2871
2872    ///
2873    /// Sets the *request* property to the given value.
2874    ///
2875    /// Even though the property as already been set when instantiating this call,
2876    /// we provide this method for API completeness.
2877    pub fn request(mut self, new_value: PauseJobRequest) -> ProjectLocationJobPauseCall<'a, C> {
2878        self._request = new_value;
2879        self
2880    }
2881    /// Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
2882    ///
2883    /// Sets the *name* path property to the given value.
2884    ///
2885    /// Even though the property as already been set when instantiating this call,
2886    /// we provide this method for API completeness.
2887    pub fn name(mut self, new_value: &str) -> ProjectLocationJobPauseCall<'a, C> {
2888        self._name = new_value.to_string();
2889        self
2890    }
2891    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2892    /// while executing the actual API request.
2893    ///
2894    /// ````text
2895    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2896    /// ````
2897    ///
2898    /// Sets the *delegate* property to the given value.
2899    pub fn delegate(
2900        mut self,
2901        new_value: &'a mut dyn common::Delegate,
2902    ) -> ProjectLocationJobPauseCall<'a, C> {
2903        self._delegate = Some(new_value);
2904        self
2905    }
2906
2907    /// Set any additional parameter of the query string used in the request.
2908    /// It should be used to set parameters which are not yet available through their own
2909    /// setters.
2910    ///
2911    /// Please note that this method must not be used to set any of the known parameters
2912    /// which have their own setter method. If done anyway, the request will fail.
2913    ///
2914    /// # Additional Parameters
2915    ///
2916    /// * *$.xgafv* (query-string) - V1 error format.
2917    /// * *access_token* (query-string) - OAuth access token.
2918    /// * *alt* (query-string) - Data format for response.
2919    /// * *callback* (query-string) - JSONP
2920    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2921    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2922    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2923    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2924    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2925    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2926    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2927    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobPauseCall<'a, C>
2928    where
2929        T: AsRef<str>,
2930    {
2931        self._additional_params
2932            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2933        self
2934    }
2935
2936    /// Identifies the authorization scope for the method you are building.
2937    ///
2938    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2939    /// [`Scope::CloudPlatform`].
2940    ///
2941    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2942    /// tokens for more than one scope.
2943    ///
2944    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2945    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2946    /// sufficient, a read-write scope will do as well.
2947    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobPauseCall<'a, C>
2948    where
2949        St: AsRef<str>,
2950    {
2951        self._scopes.insert(String::from(scope.as_ref()));
2952        self
2953    }
2954    /// Identifies the authorization scope(s) for the method you are building.
2955    ///
2956    /// See [`Self::add_scope()`] for details.
2957    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobPauseCall<'a, C>
2958    where
2959        I: IntoIterator<Item = St>,
2960        St: AsRef<str>,
2961    {
2962        self._scopes
2963            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2964        self
2965    }
2966
2967    /// Removes all scopes, and no default scope will be used either.
2968    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2969    /// for details).
2970    pub fn clear_scopes(mut self) -> ProjectLocationJobPauseCall<'a, C> {
2971        self._scopes.clear();
2972        self
2973    }
2974}
2975
2976/// Resume a job. This method reenables a job after it has been Job.State.PAUSED. The state of a job is stored in Job.state; after calling this method it will be set to Job.State.ENABLED. A job must be in Job.State.PAUSED to be resumed.
2977///
2978/// A builder for the *locations.jobs.resume* method supported by a *project* resource.
2979/// It is not used directly, but through a [`ProjectMethods`] instance.
2980///
2981/// # Example
2982///
2983/// Instantiate a resource method builder
2984///
2985/// ```test_harness,no_run
2986/// # extern crate hyper;
2987/// # extern crate hyper_rustls;
2988/// # extern crate google_cloudscheduler1 as cloudscheduler1;
2989/// use cloudscheduler1::api::ResumeJobRequest;
2990/// # async fn dox() {
2991/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2992///
2993/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2994/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2995/// #     .with_native_roots()
2996/// #     .unwrap()
2997/// #     .https_only()
2998/// #     .enable_http2()
2999/// #     .build();
3000///
3001/// # let executor = hyper_util::rt::TokioExecutor::new();
3002/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3003/// #     secret,
3004/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3005/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3006/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3007/// #     ),
3008/// # ).build().await.unwrap();
3009///
3010/// # let client = hyper_util::client::legacy::Client::builder(
3011/// #     hyper_util::rt::TokioExecutor::new()
3012/// # )
3013/// # .build(
3014/// #     hyper_rustls::HttpsConnectorBuilder::new()
3015/// #         .with_native_roots()
3016/// #         .unwrap()
3017/// #         .https_or_http()
3018/// #         .enable_http2()
3019/// #         .build()
3020/// # );
3021/// # let mut hub = CloudScheduler::new(client, auth);
3022/// // As the method needs a request, you would usually fill it with the desired information
3023/// // into the respective structure. Some of the parts shown here might not be applicable !
3024/// // Values shown here are possibly random and not representative !
3025/// let mut req = ResumeJobRequest::default();
3026///
3027/// // You can configure optional parameters by calling the respective setters at will, and
3028/// // execute the final call using `doit()`.
3029/// // Values shown here are possibly random and not representative !
3030/// let result = hub.projects().locations_jobs_resume(req, "name")
3031///              .doit().await;
3032/// # }
3033/// ```
3034pub struct ProjectLocationJobResumeCall<'a, C>
3035where
3036    C: 'a,
3037{
3038    hub: &'a CloudScheduler<C>,
3039    _request: ResumeJobRequest,
3040    _name: String,
3041    _delegate: Option<&'a mut dyn common::Delegate>,
3042    _additional_params: HashMap<String, String>,
3043    _scopes: BTreeSet<String>,
3044}
3045
3046impl<'a, C> common::CallBuilder for ProjectLocationJobResumeCall<'a, C> {}
3047
3048impl<'a, C> ProjectLocationJobResumeCall<'a, C>
3049where
3050    C: common::Connector,
3051{
3052    /// Perform the operation you have build so far.
3053    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
3054        use std::borrow::Cow;
3055        use std::io::{Read, Seek};
3056
3057        use common::{url::Params, ToParts};
3058        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3059
3060        let mut dd = common::DefaultDelegate;
3061        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3062        dlg.begin(common::MethodInfo {
3063            id: "cloudscheduler.projects.locations.jobs.resume",
3064            http_method: hyper::Method::POST,
3065        });
3066
3067        for &field in ["alt", "name"].iter() {
3068            if self._additional_params.contains_key(field) {
3069                dlg.finished(false);
3070                return Err(common::Error::FieldClash(field));
3071            }
3072        }
3073
3074        let mut params = Params::with_capacity(4 + self._additional_params.len());
3075        params.push("name", self._name);
3076
3077        params.extend(self._additional_params.iter());
3078
3079        params.push("alt", "json");
3080        let mut url = self.hub._base_url.clone() + "v1/{+name}:resume";
3081        if self._scopes.is_empty() {
3082            self._scopes
3083                .insert(Scope::CloudPlatform.as_ref().to_string());
3084        }
3085
3086        #[allow(clippy::single_element_loop)]
3087        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3088            url = params.uri_replacement(url, param_name, find_this, true);
3089        }
3090        {
3091            let to_remove = ["name"];
3092            params.remove_params(&to_remove);
3093        }
3094
3095        let url = params.parse_with_url(&url);
3096
3097        let mut json_mime_type = mime::APPLICATION_JSON;
3098        let mut request_value_reader = {
3099            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3100            common::remove_json_null_values(&mut value);
3101            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3102            serde_json::to_writer(&mut dst, &value).unwrap();
3103            dst
3104        };
3105        let request_size = request_value_reader
3106            .seek(std::io::SeekFrom::End(0))
3107            .unwrap();
3108        request_value_reader
3109            .seek(std::io::SeekFrom::Start(0))
3110            .unwrap();
3111
3112        loop {
3113            let token = match self
3114                .hub
3115                .auth
3116                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3117                .await
3118            {
3119                Ok(token) => token,
3120                Err(e) => match dlg.token(e) {
3121                    Ok(token) => token,
3122                    Err(e) => {
3123                        dlg.finished(false);
3124                        return Err(common::Error::MissingToken(e));
3125                    }
3126                },
3127            };
3128            request_value_reader
3129                .seek(std::io::SeekFrom::Start(0))
3130                .unwrap();
3131            let mut req_result = {
3132                let client = &self.hub.client;
3133                dlg.pre_request();
3134                let mut req_builder = hyper::Request::builder()
3135                    .method(hyper::Method::POST)
3136                    .uri(url.as_str())
3137                    .header(USER_AGENT, self.hub._user_agent.clone());
3138
3139                if let Some(token) = token.as_ref() {
3140                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3141                }
3142
3143                let request = req_builder
3144                    .header(CONTENT_TYPE, json_mime_type.to_string())
3145                    .header(CONTENT_LENGTH, request_size as u64)
3146                    .body(common::to_body(
3147                        request_value_reader.get_ref().clone().into(),
3148                    ));
3149
3150                client.request(request.unwrap()).await
3151            };
3152
3153            match req_result {
3154                Err(err) => {
3155                    if let common::Retry::After(d) = dlg.http_error(&err) {
3156                        sleep(d).await;
3157                        continue;
3158                    }
3159                    dlg.finished(false);
3160                    return Err(common::Error::HttpError(err));
3161                }
3162                Ok(res) => {
3163                    let (mut parts, body) = res.into_parts();
3164                    let mut body = common::Body::new(body);
3165                    if !parts.status.is_success() {
3166                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3167                        let error = serde_json::from_str(&common::to_string(&bytes));
3168                        let response = common::to_response(parts, bytes.into());
3169
3170                        if let common::Retry::After(d) =
3171                            dlg.http_failure(&response, error.as_ref().ok())
3172                        {
3173                            sleep(d).await;
3174                            continue;
3175                        }
3176
3177                        dlg.finished(false);
3178
3179                        return Err(match error {
3180                            Ok(value) => common::Error::BadRequest(value),
3181                            _ => common::Error::Failure(response),
3182                        });
3183                    }
3184                    let response = {
3185                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3186                        let encoded = common::to_string(&bytes);
3187                        match serde_json::from_str(&encoded) {
3188                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3189                            Err(error) => {
3190                                dlg.response_json_decode_error(&encoded, &error);
3191                                return Err(common::Error::JsonDecodeError(
3192                                    encoded.to_string(),
3193                                    error,
3194                                ));
3195                            }
3196                        }
3197                    };
3198
3199                    dlg.finished(true);
3200                    return Ok(response);
3201                }
3202            }
3203        }
3204    }
3205
3206    ///
3207    /// Sets the *request* property to the given value.
3208    ///
3209    /// Even though the property as already been set when instantiating this call,
3210    /// we provide this method for API completeness.
3211    pub fn request(mut self, new_value: ResumeJobRequest) -> ProjectLocationJobResumeCall<'a, C> {
3212        self._request = new_value;
3213        self
3214    }
3215    /// Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
3216    ///
3217    /// Sets the *name* path property to the given value.
3218    ///
3219    /// Even though the property as already been set when instantiating this call,
3220    /// we provide this method for API completeness.
3221    pub fn name(mut self, new_value: &str) -> ProjectLocationJobResumeCall<'a, C> {
3222        self._name = new_value.to_string();
3223        self
3224    }
3225    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3226    /// while executing the actual API request.
3227    ///
3228    /// ````text
3229    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3230    /// ````
3231    ///
3232    /// Sets the *delegate* property to the given value.
3233    pub fn delegate(
3234        mut self,
3235        new_value: &'a mut dyn common::Delegate,
3236    ) -> ProjectLocationJobResumeCall<'a, C> {
3237        self._delegate = Some(new_value);
3238        self
3239    }
3240
3241    /// Set any additional parameter of the query string used in the request.
3242    /// It should be used to set parameters which are not yet available through their own
3243    /// setters.
3244    ///
3245    /// Please note that this method must not be used to set any of the known parameters
3246    /// which have their own setter method. If done anyway, the request will fail.
3247    ///
3248    /// # Additional Parameters
3249    ///
3250    /// * *$.xgafv* (query-string) - V1 error format.
3251    /// * *access_token* (query-string) - OAuth access token.
3252    /// * *alt* (query-string) - Data format for response.
3253    /// * *callback* (query-string) - JSONP
3254    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3255    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3256    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3257    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3258    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3259    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3260    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3261    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobResumeCall<'a, C>
3262    where
3263        T: AsRef<str>,
3264    {
3265        self._additional_params
3266            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3267        self
3268    }
3269
3270    /// Identifies the authorization scope for the method you are building.
3271    ///
3272    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3273    /// [`Scope::CloudPlatform`].
3274    ///
3275    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3276    /// tokens for more than one scope.
3277    ///
3278    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3279    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3280    /// sufficient, a read-write scope will do as well.
3281    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobResumeCall<'a, C>
3282    where
3283        St: AsRef<str>,
3284    {
3285        self._scopes.insert(String::from(scope.as_ref()));
3286        self
3287    }
3288    /// Identifies the authorization scope(s) for the method you are building.
3289    ///
3290    /// See [`Self::add_scope()`] for details.
3291    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobResumeCall<'a, C>
3292    where
3293        I: IntoIterator<Item = St>,
3294        St: AsRef<str>,
3295    {
3296        self._scopes
3297            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3298        self
3299    }
3300
3301    /// Removes all scopes, and no default scope will be used either.
3302    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3303    /// for details).
3304    pub fn clear_scopes(mut self) -> ProjectLocationJobResumeCall<'a, C> {
3305        self._scopes.clear();
3306        self
3307    }
3308}
3309
3310/// Forces a job to run now. When this method is called, Cloud Scheduler will dispatch the job, even if the job is already running.
3311///
3312/// A builder for the *locations.jobs.run* method supported by a *project* resource.
3313/// It is not used directly, but through a [`ProjectMethods`] instance.
3314///
3315/// # Example
3316///
3317/// Instantiate a resource method builder
3318///
3319/// ```test_harness,no_run
3320/// # extern crate hyper;
3321/// # extern crate hyper_rustls;
3322/// # extern crate google_cloudscheduler1 as cloudscheduler1;
3323/// use cloudscheduler1::api::RunJobRequest;
3324/// # async fn dox() {
3325/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3326///
3327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3328/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3329/// #     .with_native_roots()
3330/// #     .unwrap()
3331/// #     .https_only()
3332/// #     .enable_http2()
3333/// #     .build();
3334///
3335/// # let executor = hyper_util::rt::TokioExecutor::new();
3336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3337/// #     secret,
3338/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3339/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3340/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3341/// #     ),
3342/// # ).build().await.unwrap();
3343///
3344/// # let client = hyper_util::client::legacy::Client::builder(
3345/// #     hyper_util::rt::TokioExecutor::new()
3346/// # )
3347/// # .build(
3348/// #     hyper_rustls::HttpsConnectorBuilder::new()
3349/// #         .with_native_roots()
3350/// #         .unwrap()
3351/// #         .https_or_http()
3352/// #         .enable_http2()
3353/// #         .build()
3354/// # );
3355/// # let mut hub = CloudScheduler::new(client, auth);
3356/// // As the method needs a request, you would usually fill it with the desired information
3357/// // into the respective structure. Some of the parts shown here might not be applicable !
3358/// // Values shown here are possibly random and not representative !
3359/// let mut req = RunJobRequest::default();
3360///
3361/// // You can configure optional parameters by calling the respective setters at will, and
3362/// // execute the final call using `doit()`.
3363/// // Values shown here are possibly random and not representative !
3364/// let result = hub.projects().locations_jobs_run(req, "name")
3365///              .doit().await;
3366/// # }
3367/// ```
3368pub struct ProjectLocationJobRunCall<'a, C>
3369where
3370    C: 'a,
3371{
3372    hub: &'a CloudScheduler<C>,
3373    _request: RunJobRequest,
3374    _name: String,
3375    _delegate: Option<&'a mut dyn common::Delegate>,
3376    _additional_params: HashMap<String, String>,
3377    _scopes: BTreeSet<String>,
3378}
3379
3380impl<'a, C> common::CallBuilder for ProjectLocationJobRunCall<'a, C> {}
3381
3382impl<'a, C> ProjectLocationJobRunCall<'a, C>
3383where
3384    C: common::Connector,
3385{
3386    /// Perform the operation you have build so far.
3387    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
3388        use std::borrow::Cow;
3389        use std::io::{Read, Seek};
3390
3391        use common::{url::Params, ToParts};
3392        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3393
3394        let mut dd = common::DefaultDelegate;
3395        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3396        dlg.begin(common::MethodInfo {
3397            id: "cloudscheduler.projects.locations.jobs.run",
3398            http_method: hyper::Method::POST,
3399        });
3400
3401        for &field in ["alt", "name"].iter() {
3402            if self._additional_params.contains_key(field) {
3403                dlg.finished(false);
3404                return Err(common::Error::FieldClash(field));
3405            }
3406        }
3407
3408        let mut params = Params::with_capacity(4 + self._additional_params.len());
3409        params.push("name", self._name);
3410
3411        params.extend(self._additional_params.iter());
3412
3413        params.push("alt", "json");
3414        let mut url = self.hub._base_url.clone() + "v1/{+name}:run";
3415        if self._scopes.is_empty() {
3416            self._scopes
3417                .insert(Scope::CloudPlatform.as_ref().to_string());
3418        }
3419
3420        #[allow(clippy::single_element_loop)]
3421        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3422            url = params.uri_replacement(url, param_name, find_this, true);
3423        }
3424        {
3425            let to_remove = ["name"];
3426            params.remove_params(&to_remove);
3427        }
3428
3429        let url = params.parse_with_url(&url);
3430
3431        let mut json_mime_type = mime::APPLICATION_JSON;
3432        let mut request_value_reader = {
3433            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3434            common::remove_json_null_values(&mut value);
3435            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3436            serde_json::to_writer(&mut dst, &value).unwrap();
3437            dst
3438        };
3439        let request_size = request_value_reader
3440            .seek(std::io::SeekFrom::End(0))
3441            .unwrap();
3442        request_value_reader
3443            .seek(std::io::SeekFrom::Start(0))
3444            .unwrap();
3445
3446        loop {
3447            let token = match self
3448                .hub
3449                .auth
3450                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3451                .await
3452            {
3453                Ok(token) => token,
3454                Err(e) => match dlg.token(e) {
3455                    Ok(token) => token,
3456                    Err(e) => {
3457                        dlg.finished(false);
3458                        return Err(common::Error::MissingToken(e));
3459                    }
3460                },
3461            };
3462            request_value_reader
3463                .seek(std::io::SeekFrom::Start(0))
3464                .unwrap();
3465            let mut req_result = {
3466                let client = &self.hub.client;
3467                dlg.pre_request();
3468                let mut req_builder = hyper::Request::builder()
3469                    .method(hyper::Method::POST)
3470                    .uri(url.as_str())
3471                    .header(USER_AGENT, self.hub._user_agent.clone());
3472
3473                if let Some(token) = token.as_ref() {
3474                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3475                }
3476
3477                let request = req_builder
3478                    .header(CONTENT_TYPE, json_mime_type.to_string())
3479                    .header(CONTENT_LENGTH, request_size as u64)
3480                    .body(common::to_body(
3481                        request_value_reader.get_ref().clone().into(),
3482                    ));
3483
3484                client.request(request.unwrap()).await
3485            };
3486
3487            match req_result {
3488                Err(err) => {
3489                    if let common::Retry::After(d) = dlg.http_error(&err) {
3490                        sleep(d).await;
3491                        continue;
3492                    }
3493                    dlg.finished(false);
3494                    return Err(common::Error::HttpError(err));
3495                }
3496                Ok(res) => {
3497                    let (mut parts, body) = res.into_parts();
3498                    let mut body = common::Body::new(body);
3499                    if !parts.status.is_success() {
3500                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3501                        let error = serde_json::from_str(&common::to_string(&bytes));
3502                        let response = common::to_response(parts, bytes.into());
3503
3504                        if let common::Retry::After(d) =
3505                            dlg.http_failure(&response, error.as_ref().ok())
3506                        {
3507                            sleep(d).await;
3508                            continue;
3509                        }
3510
3511                        dlg.finished(false);
3512
3513                        return Err(match error {
3514                            Ok(value) => common::Error::BadRequest(value),
3515                            _ => common::Error::Failure(response),
3516                        });
3517                    }
3518                    let response = {
3519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3520                        let encoded = common::to_string(&bytes);
3521                        match serde_json::from_str(&encoded) {
3522                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3523                            Err(error) => {
3524                                dlg.response_json_decode_error(&encoded, &error);
3525                                return Err(common::Error::JsonDecodeError(
3526                                    encoded.to_string(),
3527                                    error,
3528                                ));
3529                            }
3530                        }
3531                    };
3532
3533                    dlg.finished(true);
3534                    return Ok(response);
3535                }
3536            }
3537        }
3538    }
3539
3540    ///
3541    /// Sets the *request* property to the given value.
3542    ///
3543    /// Even though the property as already been set when instantiating this call,
3544    /// we provide this method for API completeness.
3545    pub fn request(mut self, new_value: RunJobRequest) -> ProjectLocationJobRunCall<'a, C> {
3546        self._request = new_value;
3547        self
3548    }
3549    /// Required. The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
3550    ///
3551    /// Sets the *name* path property to the given value.
3552    ///
3553    /// Even though the property as already been set when instantiating this call,
3554    /// we provide this method for API completeness.
3555    pub fn name(mut self, new_value: &str) -> ProjectLocationJobRunCall<'a, C> {
3556        self._name = new_value.to_string();
3557        self
3558    }
3559    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3560    /// while executing the actual API request.
3561    ///
3562    /// ````text
3563    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3564    /// ````
3565    ///
3566    /// Sets the *delegate* property to the given value.
3567    pub fn delegate(
3568        mut self,
3569        new_value: &'a mut dyn common::Delegate,
3570    ) -> ProjectLocationJobRunCall<'a, C> {
3571        self._delegate = Some(new_value);
3572        self
3573    }
3574
3575    /// Set any additional parameter of the query string used in the request.
3576    /// It should be used to set parameters which are not yet available through their own
3577    /// setters.
3578    ///
3579    /// Please note that this method must not be used to set any of the known parameters
3580    /// which have their own setter method. If done anyway, the request will fail.
3581    ///
3582    /// # Additional Parameters
3583    ///
3584    /// * *$.xgafv* (query-string) - V1 error format.
3585    /// * *access_token* (query-string) - OAuth access token.
3586    /// * *alt* (query-string) - Data format for response.
3587    /// * *callback* (query-string) - JSONP
3588    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3589    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3590    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3591    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3592    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3593    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3594    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3595    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobRunCall<'a, C>
3596    where
3597        T: AsRef<str>,
3598    {
3599        self._additional_params
3600            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3601        self
3602    }
3603
3604    /// Identifies the authorization scope for the method you are building.
3605    ///
3606    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3607    /// [`Scope::CloudPlatform`].
3608    ///
3609    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3610    /// tokens for more than one scope.
3611    ///
3612    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3613    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3614    /// sufficient, a read-write scope will do as well.
3615    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobRunCall<'a, C>
3616    where
3617        St: AsRef<str>,
3618    {
3619        self._scopes.insert(String::from(scope.as_ref()));
3620        self
3621    }
3622    /// Identifies the authorization scope(s) for the method you are building.
3623    ///
3624    /// See [`Self::add_scope()`] for details.
3625    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobRunCall<'a, C>
3626    where
3627        I: IntoIterator<Item = St>,
3628        St: AsRef<str>,
3629    {
3630        self._scopes
3631            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3632        self
3633    }
3634
3635    /// Removes all scopes, and no default scope will be used either.
3636    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3637    /// for details).
3638    pub fn clear_scopes(mut self) -> ProjectLocationJobRunCall<'a, C> {
3639        self._scopes.clear();
3640        self
3641    }
3642}
3643
3644/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
3645///
3646/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
3647/// It is not used directly, but through a [`ProjectMethods`] instance.
3648///
3649/// # Example
3650///
3651/// Instantiate a resource method builder
3652///
3653/// ```test_harness,no_run
3654/// # extern crate hyper;
3655/// # extern crate hyper_rustls;
3656/// # extern crate google_cloudscheduler1 as cloudscheduler1;
3657/// use cloudscheduler1::api::CancelOperationRequest;
3658/// # async fn dox() {
3659/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3660///
3661/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3662/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3663/// #     .with_native_roots()
3664/// #     .unwrap()
3665/// #     .https_only()
3666/// #     .enable_http2()
3667/// #     .build();
3668///
3669/// # let executor = hyper_util::rt::TokioExecutor::new();
3670/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3671/// #     secret,
3672/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3673/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3674/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3675/// #     ),
3676/// # ).build().await.unwrap();
3677///
3678/// # let client = hyper_util::client::legacy::Client::builder(
3679/// #     hyper_util::rt::TokioExecutor::new()
3680/// # )
3681/// # .build(
3682/// #     hyper_rustls::HttpsConnectorBuilder::new()
3683/// #         .with_native_roots()
3684/// #         .unwrap()
3685/// #         .https_or_http()
3686/// #         .enable_http2()
3687/// #         .build()
3688/// # );
3689/// # let mut hub = CloudScheduler::new(client, auth);
3690/// // As the method needs a request, you would usually fill it with the desired information
3691/// // into the respective structure. Some of the parts shown here might not be applicable !
3692/// // Values shown here are possibly random and not representative !
3693/// let mut req = CancelOperationRequest::default();
3694///
3695/// // You can configure optional parameters by calling the respective setters at will, and
3696/// // execute the final call using `doit()`.
3697/// // Values shown here are possibly random and not representative !
3698/// let result = hub.projects().locations_operations_cancel(req, "name")
3699///              .doit().await;
3700/// # }
3701/// ```
3702pub struct ProjectLocationOperationCancelCall<'a, C>
3703where
3704    C: 'a,
3705{
3706    hub: &'a CloudScheduler<C>,
3707    _request: CancelOperationRequest,
3708    _name: String,
3709    _delegate: Option<&'a mut dyn common::Delegate>,
3710    _additional_params: HashMap<String, String>,
3711    _scopes: BTreeSet<String>,
3712}
3713
3714impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
3715
3716impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
3717where
3718    C: common::Connector,
3719{
3720    /// Perform the operation you have build so far.
3721    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3722        use std::borrow::Cow;
3723        use std::io::{Read, Seek};
3724
3725        use common::{url::Params, ToParts};
3726        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3727
3728        let mut dd = common::DefaultDelegate;
3729        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3730        dlg.begin(common::MethodInfo {
3731            id: "cloudscheduler.projects.locations.operations.cancel",
3732            http_method: hyper::Method::POST,
3733        });
3734
3735        for &field in ["alt", "name"].iter() {
3736            if self._additional_params.contains_key(field) {
3737                dlg.finished(false);
3738                return Err(common::Error::FieldClash(field));
3739            }
3740        }
3741
3742        let mut params = Params::with_capacity(4 + self._additional_params.len());
3743        params.push("name", self._name);
3744
3745        params.extend(self._additional_params.iter());
3746
3747        params.push("alt", "json");
3748        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
3749        if self._scopes.is_empty() {
3750            self._scopes
3751                .insert(Scope::CloudPlatform.as_ref().to_string());
3752        }
3753
3754        #[allow(clippy::single_element_loop)]
3755        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3756            url = params.uri_replacement(url, param_name, find_this, true);
3757        }
3758        {
3759            let to_remove = ["name"];
3760            params.remove_params(&to_remove);
3761        }
3762
3763        let url = params.parse_with_url(&url);
3764
3765        let mut json_mime_type = mime::APPLICATION_JSON;
3766        let mut request_value_reader = {
3767            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3768            common::remove_json_null_values(&mut value);
3769            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3770            serde_json::to_writer(&mut dst, &value).unwrap();
3771            dst
3772        };
3773        let request_size = request_value_reader
3774            .seek(std::io::SeekFrom::End(0))
3775            .unwrap();
3776        request_value_reader
3777            .seek(std::io::SeekFrom::Start(0))
3778            .unwrap();
3779
3780        loop {
3781            let token = match self
3782                .hub
3783                .auth
3784                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3785                .await
3786            {
3787                Ok(token) => token,
3788                Err(e) => match dlg.token(e) {
3789                    Ok(token) => token,
3790                    Err(e) => {
3791                        dlg.finished(false);
3792                        return Err(common::Error::MissingToken(e));
3793                    }
3794                },
3795            };
3796            request_value_reader
3797                .seek(std::io::SeekFrom::Start(0))
3798                .unwrap();
3799            let mut req_result = {
3800                let client = &self.hub.client;
3801                dlg.pre_request();
3802                let mut req_builder = hyper::Request::builder()
3803                    .method(hyper::Method::POST)
3804                    .uri(url.as_str())
3805                    .header(USER_AGENT, self.hub._user_agent.clone());
3806
3807                if let Some(token) = token.as_ref() {
3808                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3809                }
3810
3811                let request = req_builder
3812                    .header(CONTENT_TYPE, json_mime_type.to_string())
3813                    .header(CONTENT_LENGTH, request_size as u64)
3814                    .body(common::to_body(
3815                        request_value_reader.get_ref().clone().into(),
3816                    ));
3817
3818                client.request(request.unwrap()).await
3819            };
3820
3821            match req_result {
3822                Err(err) => {
3823                    if let common::Retry::After(d) = dlg.http_error(&err) {
3824                        sleep(d).await;
3825                        continue;
3826                    }
3827                    dlg.finished(false);
3828                    return Err(common::Error::HttpError(err));
3829                }
3830                Ok(res) => {
3831                    let (mut parts, body) = res.into_parts();
3832                    let mut body = common::Body::new(body);
3833                    if !parts.status.is_success() {
3834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3835                        let error = serde_json::from_str(&common::to_string(&bytes));
3836                        let response = common::to_response(parts, bytes.into());
3837
3838                        if let common::Retry::After(d) =
3839                            dlg.http_failure(&response, error.as_ref().ok())
3840                        {
3841                            sleep(d).await;
3842                            continue;
3843                        }
3844
3845                        dlg.finished(false);
3846
3847                        return Err(match error {
3848                            Ok(value) => common::Error::BadRequest(value),
3849                            _ => common::Error::Failure(response),
3850                        });
3851                    }
3852                    let response = {
3853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3854                        let encoded = common::to_string(&bytes);
3855                        match serde_json::from_str(&encoded) {
3856                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3857                            Err(error) => {
3858                                dlg.response_json_decode_error(&encoded, &error);
3859                                return Err(common::Error::JsonDecodeError(
3860                                    encoded.to_string(),
3861                                    error,
3862                                ));
3863                            }
3864                        }
3865                    };
3866
3867                    dlg.finished(true);
3868                    return Ok(response);
3869                }
3870            }
3871        }
3872    }
3873
3874    ///
3875    /// Sets the *request* property to the given value.
3876    ///
3877    /// Even though the property as already been set when instantiating this call,
3878    /// we provide this method for API completeness.
3879    pub fn request(
3880        mut self,
3881        new_value: CancelOperationRequest,
3882    ) -> ProjectLocationOperationCancelCall<'a, C> {
3883        self._request = new_value;
3884        self
3885    }
3886    /// The name of the operation resource to be cancelled.
3887    ///
3888    /// Sets the *name* path property to the given value.
3889    ///
3890    /// Even though the property as already been set when instantiating this call,
3891    /// we provide this method for API completeness.
3892    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
3893        self._name = new_value.to_string();
3894        self
3895    }
3896    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3897    /// while executing the actual API request.
3898    ///
3899    /// ````text
3900    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3901    /// ````
3902    ///
3903    /// Sets the *delegate* property to the given value.
3904    pub fn delegate(
3905        mut self,
3906        new_value: &'a mut dyn common::Delegate,
3907    ) -> ProjectLocationOperationCancelCall<'a, C> {
3908        self._delegate = Some(new_value);
3909        self
3910    }
3911
3912    /// Set any additional parameter of the query string used in the request.
3913    /// It should be used to set parameters which are not yet available through their own
3914    /// setters.
3915    ///
3916    /// Please note that this method must not be used to set any of the known parameters
3917    /// which have their own setter method. If done anyway, the request will fail.
3918    ///
3919    /// # Additional Parameters
3920    ///
3921    /// * *$.xgafv* (query-string) - V1 error format.
3922    /// * *access_token* (query-string) - OAuth access token.
3923    /// * *alt* (query-string) - Data format for response.
3924    /// * *callback* (query-string) - JSONP
3925    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3926    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3927    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3928    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3929    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3930    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3931    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3932    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
3933    where
3934        T: AsRef<str>,
3935    {
3936        self._additional_params
3937            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3938        self
3939    }
3940
3941    /// Identifies the authorization scope for the method you are building.
3942    ///
3943    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3944    /// [`Scope::CloudPlatform`].
3945    ///
3946    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3947    /// tokens for more than one scope.
3948    ///
3949    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3950    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3951    /// sufficient, a read-write scope will do as well.
3952    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
3953    where
3954        St: AsRef<str>,
3955    {
3956        self._scopes.insert(String::from(scope.as_ref()));
3957        self
3958    }
3959    /// Identifies the authorization scope(s) for the method you are building.
3960    ///
3961    /// See [`Self::add_scope()`] for details.
3962    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
3963    where
3964        I: IntoIterator<Item = St>,
3965        St: AsRef<str>,
3966    {
3967        self._scopes
3968            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3969        self
3970    }
3971
3972    /// Removes all scopes, and no default scope will be used either.
3973    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3974    /// for details).
3975    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
3976        self._scopes.clear();
3977        self
3978    }
3979}
3980
3981/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
3982///
3983/// A builder for the *locations.operations.delete* method supported by a *project* resource.
3984/// It is not used directly, but through a [`ProjectMethods`] instance.
3985///
3986/// # Example
3987///
3988/// Instantiate a resource method builder
3989///
3990/// ```test_harness,no_run
3991/// # extern crate hyper;
3992/// # extern crate hyper_rustls;
3993/// # extern crate google_cloudscheduler1 as cloudscheduler1;
3994/// # async fn dox() {
3995/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3996///
3997/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3998/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3999/// #     .with_native_roots()
4000/// #     .unwrap()
4001/// #     .https_only()
4002/// #     .enable_http2()
4003/// #     .build();
4004///
4005/// # let executor = hyper_util::rt::TokioExecutor::new();
4006/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4007/// #     secret,
4008/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4009/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4010/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4011/// #     ),
4012/// # ).build().await.unwrap();
4013///
4014/// # let client = hyper_util::client::legacy::Client::builder(
4015/// #     hyper_util::rt::TokioExecutor::new()
4016/// # )
4017/// # .build(
4018/// #     hyper_rustls::HttpsConnectorBuilder::new()
4019/// #         .with_native_roots()
4020/// #         .unwrap()
4021/// #         .https_or_http()
4022/// #         .enable_http2()
4023/// #         .build()
4024/// # );
4025/// # let mut hub = CloudScheduler::new(client, auth);
4026/// // You can configure optional parameters by calling the respective setters at will, and
4027/// // execute the final call using `doit()`.
4028/// // Values shown here are possibly random and not representative !
4029/// let result = hub.projects().locations_operations_delete("name")
4030///              .doit().await;
4031/// # }
4032/// ```
4033pub struct ProjectLocationOperationDeleteCall<'a, C>
4034where
4035    C: 'a,
4036{
4037    hub: &'a CloudScheduler<C>,
4038    _name: String,
4039    _delegate: Option<&'a mut dyn common::Delegate>,
4040    _additional_params: HashMap<String, String>,
4041    _scopes: BTreeSet<String>,
4042}
4043
4044impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
4045
4046impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
4047where
4048    C: common::Connector,
4049{
4050    /// Perform the operation you have build so far.
4051    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4052        use std::borrow::Cow;
4053        use std::io::{Read, Seek};
4054
4055        use common::{url::Params, ToParts};
4056        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4057
4058        let mut dd = common::DefaultDelegate;
4059        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4060        dlg.begin(common::MethodInfo {
4061            id: "cloudscheduler.projects.locations.operations.delete",
4062            http_method: hyper::Method::DELETE,
4063        });
4064
4065        for &field in ["alt", "name"].iter() {
4066            if self._additional_params.contains_key(field) {
4067                dlg.finished(false);
4068                return Err(common::Error::FieldClash(field));
4069            }
4070        }
4071
4072        let mut params = Params::with_capacity(3 + self._additional_params.len());
4073        params.push("name", self._name);
4074
4075        params.extend(self._additional_params.iter());
4076
4077        params.push("alt", "json");
4078        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4079        if self._scopes.is_empty() {
4080            self._scopes
4081                .insert(Scope::CloudPlatform.as_ref().to_string());
4082        }
4083
4084        #[allow(clippy::single_element_loop)]
4085        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4086            url = params.uri_replacement(url, param_name, find_this, true);
4087        }
4088        {
4089            let to_remove = ["name"];
4090            params.remove_params(&to_remove);
4091        }
4092
4093        let url = params.parse_with_url(&url);
4094
4095        loop {
4096            let token = match self
4097                .hub
4098                .auth
4099                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4100                .await
4101            {
4102                Ok(token) => token,
4103                Err(e) => match dlg.token(e) {
4104                    Ok(token) => token,
4105                    Err(e) => {
4106                        dlg.finished(false);
4107                        return Err(common::Error::MissingToken(e));
4108                    }
4109                },
4110            };
4111            let mut req_result = {
4112                let client = &self.hub.client;
4113                dlg.pre_request();
4114                let mut req_builder = hyper::Request::builder()
4115                    .method(hyper::Method::DELETE)
4116                    .uri(url.as_str())
4117                    .header(USER_AGENT, self.hub._user_agent.clone());
4118
4119                if let Some(token) = token.as_ref() {
4120                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4121                }
4122
4123                let request = req_builder
4124                    .header(CONTENT_LENGTH, 0_u64)
4125                    .body(common::to_body::<String>(None));
4126
4127                client.request(request.unwrap()).await
4128            };
4129
4130            match req_result {
4131                Err(err) => {
4132                    if let common::Retry::After(d) = dlg.http_error(&err) {
4133                        sleep(d).await;
4134                        continue;
4135                    }
4136                    dlg.finished(false);
4137                    return Err(common::Error::HttpError(err));
4138                }
4139                Ok(res) => {
4140                    let (mut parts, body) = res.into_parts();
4141                    let mut body = common::Body::new(body);
4142                    if !parts.status.is_success() {
4143                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4144                        let error = serde_json::from_str(&common::to_string(&bytes));
4145                        let response = common::to_response(parts, bytes.into());
4146
4147                        if let common::Retry::After(d) =
4148                            dlg.http_failure(&response, error.as_ref().ok())
4149                        {
4150                            sleep(d).await;
4151                            continue;
4152                        }
4153
4154                        dlg.finished(false);
4155
4156                        return Err(match error {
4157                            Ok(value) => common::Error::BadRequest(value),
4158                            _ => common::Error::Failure(response),
4159                        });
4160                    }
4161                    let response = {
4162                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4163                        let encoded = common::to_string(&bytes);
4164                        match serde_json::from_str(&encoded) {
4165                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4166                            Err(error) => {
4167                                dlg.response_json_decode_error(&encoded, &error);
4168                                return Err(common::Error::JsonDecodeError(
4169                                    encoded.to_string(),
4170                                    error,
4171                                ));
4172                            }
4173                        }
4174                    };
4175
4176                    dlg.finished(true);
4177                    return Ok(response);
4178                }
4179            }
4180        }
4181    }
4182
4183    /// The name of the operation resource to be deleted.
4184    ///
4185    /// Sets the *name* path property to the given value.
4186    ///
4187    /// Even though the property as already been set when instantiating this call,
4188    /// we provide this method for API completeness.
4189    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
4190        self._name = new_value.to_string();
4191        self
4192    }
4193    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4194    /// while executing the actual API request.
4195    ///
4196    /// ````text
4197    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4198    /// ````
4199    ///
4200    /// Sets the *delegate* property to the given value.
4201    pub fn delegate(
4202        mut self,
4203        new_value: &'a mut dyn common::Delegate,
4204    ) -> ProjectLocationOperationDeleteCall<'a, C> {
4205        self._delegate = Some(new_value);
4206        self
4207    }
4208
4209    /// Set any additional parameter of the query string used in the request.
4210    /// It should be used to set parameters which are not yet available through their own
4211    /// setters.
4212    ///
4213    /// Please note that this method must not be used to set any of the known parameters
4214    /// which have their own setter method. If done anyway, the request will fail.
4215    ///
4216    /// # Additional Parameters
4217    ///
4218    /// * *$.xgafv* (query-string) - V1 error format.
4219    /// * *access_token* (query-string) - OAuth access token.
4220    /// * *alt* (query-string) - Data format for response.
4221    /// * *callback* (query-string) - JSONP
4222    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4223    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4224    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4225    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4226    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4227    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4228    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4229    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
4230    where
4231        T: AsRef<str>,
4232    {
4233        self._additional_params
4234            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4235        self
4236    }
4237
4238    /// Identifies the authorization scope for the method you are building.
4239    ///
4240    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4241    /// [`Scope::CloudPlatform`].
4242    ///
4243    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4244    /// tokens for more than one scope.
4245    ///
4246    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4247    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4248    /// sufficient, a read-write scope will do as well.
4249    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
4250    where
4251        St: AsRef<str>,
4252    {
4253        self._scopes.insert(String::from(scope.as_ref()));
4254        self
4255    }
4256    /// Identifies the authorization scope(s) for the method you are building.
4257    ///
4258    /// See [`Self::add_scope()`] for details.
4259    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
4260    where
4261        I: IntoIterator<Item = St>,
4262        St: AsRef<str>,
4263    {
4264        self._scopes
4265            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4266        self
4267    }
4268
4269    /// Removes all scopes, and no default scope will be used either.
4270    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4271    /// for details).
4272    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
4273        self._scopes.clear();
4274        self
4275    }
4276}
4277
4278/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
4279///
4280/// A builder for the *locations.operations.get* method supported by a *project* resource.
4281/// It is not used directly, but through a [`ProjectMethods`] instance.
4282///
4283/// # Example
4284///
4285/// Instantiate a resource method builder
4286///
4287/// ```test_harness,no_run
4288/// # extern crate hyper;
4289/// # extern crate hyper_rustls;
4290/// # extern crate google_cloudscheduler1 as cloudscheduler1;
4291/// # async fn dox() {
4292/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4293///
4294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4295/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4296/// #     .with_native_roots()
4297/// #     .unwrap()
4298/// #     .https_only()
4299/// #     .enable_http2()
4300/// #     .build();
4301///
4302/// # let executor = hyper_util::rt::TokioExecutor::new();
4303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4304/// #     secret,
4305/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4306/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4307/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4308/// #     ),
4309/// # ).build().await.unwrap();
4310///
4311/// # let client = hyper_util::client::legacy::Client::builder(
4312/// #     hyper_util::rt::TokioExecutor::new()
4313/// # )
4314/// # .build(
4315/// #     hyper_rustls::HttpsConnectorBuilder::new()
4316/// #         .with_native_roots()
4317/// #         .unwrap()
4318/// #         .https_or_http()
4319/// #         .enable_http2()
4320/// #         .build()
4321/// # );
4322/// # let mut hub = CloudScheduler::new(client, auth);
4323/// // You can configure optional parameters by calling the respective setters at will, and
4324/// // execute the final call using `doit()`.
4325/// // Values shown here are possibly random and not representative !
4326/// let result = hub.projects().locations_operations_get("name")
4327///              .doit().await;
4328/// # }
4329/// ```
4330pub struct ProjectLocationOperationGetCall<'a, C>
4331where
4332    C: 'a,
4333{
4334    hub: &'a CloudScheduler<C>,
4335    _name: String,
4336    _delegate: Option<&'a mut dyn common::Delegate>,
4337    _additional_params: HashMap<String, String>,
4338    _scopes: BTreeSet<String>,
4339}
4340
4341impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
4342
4343impl<'a, C> ProjectLocationOperationGetCall<'a, C>
4344where
4345    C: common::Connector,
4346{
4347    /// Perform the operation you have build so far.
4348    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4349        use std::borrow::Cow;
4350        use std::io::{Read, Seek};
4351
4352        use common::{url::Params, ToParts};
4353        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4354
4355        let mut dd = common::DefaultDelegate;
4356        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4357        dlg.begin(common::MethodInfo {
4358            id: "cloudscheduler.projects.locations.operations.get",
4359            http_method: hyper::Method::GET,
4360        });
4361
4362        for &field in ["alt", "name"].iter() {
4363            if self._additional_params.contains_key(field) {
4364                dlg.finished(false);
4365                return Err(common::Error::FieldClash(field));
4366            }
4367        }
4368
4369        let mut params = Params::with_capacity(3 + self._additional_params.len());
4370        params.push("name", self._name);
4371
4372        params.extend(self._additional_params.iter());
4373
4374        params.push("alt", "json");
4375        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4376        if self._scopes.is_empty() {
4377            self._scopes
4378                .insert(Scope::CloudPlatform.as_ref().to_string());
4379        }
4380
4381        #[allow(clippy::single_element_loop)]
4382        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4383            url = params.uri_replacement(url, param_name, find_this, true);
4384        }
4385        {
4386            let to_remove = ["name"];
4387            params.remove_params(&to_remove);
4388        }
4389
4390        let url = params.parse_with_url(&url);
4391
4392        loop {
4393            let token = match self
4394                .hub
4395                .auth
4396                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4397                .await
4398            {
4399                Ok(token) => token,
4400                Err(e) => match dlg.token(e) {
4401                    Ok(token) => token,
4402                    Err(e) => {
4403                        dlg.finished(false);
4404                        return Err(common::Error::MissingToken(e));
4405                    }
4406                },
4407            };
4408            let mut req_result = {
4409                let client = &self.hub.client;
4410                dlg.pre_request();
4411                let mut req_builder = hyper::Request::builder()
4412                    .method(hyper::Method::GET)
4413                    .uri(url.as_str())
4414                    .header(USER_AGENT, self.hub._user_agent.clone());
4415
4416                if let Some(token) = token.as_ref() {
4417                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4418                }
4419
4420                let request = req_builder
4421                    .header(CONTENT_LENGTH, 0_u64)
4422                    .body(common::to_body::<String>(None));
4423
4424                client.request(request.unwrap()).await
4425            };
4426
4427            match req_result {
4428                Err(err) => {
4429                    if let common::Retry::After(d) = dlg.http_error(&err) {
4430                        sleep(d).await;
4431                        continue;
4432                    }
4433                    dlg.finished(false);
4434                    return Err(common::Error::HttpError(err));
4435                }
4436                Ok(res) => {
4437                    let (mut parts, body) = res.into_parts();
4438                    let mut body = common::Body::new(body);
4439                    if !parts.status.is_success() {
4440                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4441                        let error = serde_json::from_str(&common::to_string(&bytes));
4442                        let response = common::to_response(parts, bytes.into());
4443
4444                        if let common::Retry::After(d) =
4445                            dlg.http_failure(&response, error.as_ref().ok())
4446                        {
4447                            sleep(d).await;
4448                            continue;
4449                        }
4450
4451                        dlg.finished(false);
4452
4453                        return Err(match error {
4454                            Ok(value) => common::Error::BadRequest(value),
4455                            _ => common::Error::Failure(response),
4456                        });
4457                    }
4458                    let response = {
4459                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4460                        let encoded = common::to_string(&bytes);
4461                        match serde_json::from_str(&encoded) {
4462                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4463                            Err(error) => {
4464                                dlg.response_json_decode_error(&encoded, &error);
4465                                return Err(common::Error::JsonDecodeError(
4466                                    encoded.to_string(),
4467                                    error,
4468                                ));
4469                            }
4470                        }
4471                    };
4472
4473                    dlg.finished(true);
4474                    return Ok(response);
4475                }
4476            }
4477        }
4478    }
4479
4480    /// The name of the operation resource.
4481    ///
4482    /// Sets the *name* path property to the given value.
4483    ///
4484    /// Even though the property as already been set when instantiating this call,
4485    /// we provide this method for API completeness.
4486    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
4487        self._name = new_value.to_string();
4488        self
4489    }
4490    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4491    /// while executing the actual API request.
4492    ///
4493    /// ````text
4494    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4495    /// ````
4496    ///
4497    /// Sets the *delegate* property to the given value.
4498    pub fn delegate(
4499        mut self,
4500        new_value: &'a mut dyn common::Delegate,
4501    ) -> ProjectLocationOperationGetCall<'a, C> {
4502        self._delegate = Some(new_value);
4503        self
4504    }
4505
4506    /// Set any additional parameter of the query string used in the request.
4507    /// It should be used to set parameters which are not yet available through their own
4508    /// setters.
4509    ///
4510    /// Please note that this method must not be used to set any of the known parameters
4511    /// which have their own setter method. If done anyway, the request will fail.
4512    ///
4513    /// # Additional Parameters
4514    ///
4515    /// * *$.xgafv* (query-string) - V1 error format.
4516    /// * *access_token* (query-string) - OAuth access token.
4517    /// * *alt* (query-string) - Data format for response.
4518    /// * *callback* (query-string) - JSONP
4519    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4520    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4521    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4522    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4523    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4524    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4525    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4526    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
4527    where
4528        T: AsRef<str>,
4529    {
4530        self._additional_params
4531            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4532        self
4533    }
4534
4535    /// Identifies the authorization scope for the method you are building.
4536    ///
4537    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4538    /// [`Scope::CloudPlatform`].
4539    ///
4540    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4541    /// tokens for more than one scope.
4542    ///
4543    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4544    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4545    /// sufficient, a read-write scope will do as well.
4546    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
4547    where
4548        St: AsRef<str>,
4549    {
4550        self._scopes.insert(String::from(scope.as_ref()));
4551        self
4552    }
4553    /// Identifies the authorization scope(s) for the method you are building.
4554    ///
4555    /// See [`Self::add_scope()`] for details.
4556    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
4557    where
4558        I: IntoIterator<Item = St>,
4559        St: AsRef<str>,
4560    {
4561        self._scopes
4562            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4563        self
4564    }
4565
4566    /// Removes all scopes, and no default scope will be used either.
4567    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4568    /// for details).
4569    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
4570        self._scopes.clear();
4571        self
4572    }
4573}
4574
4575/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4576///
4577/// A builder for the *locations.operations.list* method supported by a *project* resource.
4578/// It is not used directly, but through a [`ProjectMethods`] instance.
4579///
4580/// # Example
4581///
4582/// Instantiate a resource method builder
4583///
4584/// ```test_harness,no_run
4585/// # extern crate hyper;
4586/// # extern crate hyper_rustls;
4587/// # extern crate google_cloudscheduler1 as cloudscheduler1;
4588/// # async fn dox() {
4589/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4590///
4591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4592/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4593/// #     .with_native_roots()
4594/// #     .unwrap()
4595/// #     .https_only()
4596/// #     .enable_http2()
4597/// #     .build();
4598///
4599/// # let executor = hyper_util::rt::TokioExecutor::new();
4600/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4601/// #     secret,
4602/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4603/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4604/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4605/// #     ),
4606/// # ).build().await.unwrap();
4607///
4608/// # let client = hyper_util::client::legacy::Client::builder(
4609/// #     hyper_util::rt::TokioExecutor::new()
4610/// # )
4611/// # .build(
4612/// #     hyper_rustls::HttpsConnectorBuilder::new()
4613/// #         .with_native_roots()
4614/// #         .unwrap()
4615/// #         .https_or_http()
4616/// #         .enable_http2()
4617/// #         .build()
4618/// # );
4619/// # let mut hub = CloudScheduler::new(client, auth);
4620/// // You can configure optional parameters by calling the respective setters at will, and
4621/// // execute the final call using `doit()`.
4622/// // Values shown here are possibly random and not representative !
4623/// let result = hub.projects().locations_operations_list("name")
4624///              .return_partial_success(true)
4625///              .page_token("invidunt")
4626///              .page_size(-47)
4627///              .filter("duo")
4628///              .doit().await;
4629/// # }
4630/// ```
4631pub struct ProjectLocationOperationListCall<'a, C>
4632where
4633    C: 'a,
4634{
4635    hub: &'a CloudScheduler<C>,
4636    _name: String,
4637    _return_partial_success: Option<bool>,
4638    _page_token: Option<String>,
4639    _page_size: Option<i32>,
4640    _filter: Option<String>,
4641    _delegate: Option<&'a mut dyn common::Delegate>,
4642    _additional_params: HashMap<String, String>,
4643    _scopes: BTreeSet<String>,
4644}
4645
4646impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
4647
4648impl<'a, C> ProjectLocationOperationListCall<'a, C>
4649where
4650    C: common::Connector,
4651{
4652    /// Perform the operation you have build so far.
4653    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
4654        use std::borrow::Cow;
4655        use std::io::{Read, Seek};
4656
4657        use common::{url::Params, ToParts};
4658        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4659
4660        let mut dd = common::DefaultDelegate;
4661        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4662        dlg.begin(common::MethodInfo {
4663            id: "cloudscheduler.projects.locations.operations.list",
4664            http_method: hyper::Method::GET,
4665        });
4666
4667        for &field in [
4668            "alt",
4669            "name",
4670            "returnPartialSuccess",
4671            "pageToken",
4672            "pageSize",
4673            "filter",
4674        ]
4675        .iter()
4676        {
4677            if self._additional_params.contains_key(field) {
4678                dlg.finished(false);
4679                return Err(common::Error::FieldClash(field));
4680            }
4681        }
4682
4683        let mut params = Params::with_capacity(7 + self._additional_params.len());
4684        params.push("name", self._name);
4685        if let Some(value) = self._return_partial_success.as_ref() {
4686            params.push("returnPartialSuccess", value.to_string());
4687        }
4688        if let Some(value) = self._page_token.as_ref() {
4689            params.push("pageToken", value);
4690        }
4691        if let Some(value) = self._page_size.as_ref() {
4692            params.push("pageSize", value.to_string());
4693        }
4694        if let Some(value) = self._filter.as_ref() {
4695            params.push("filter", value);
4696        }
4697
4698        params.extend(self._additional_params.iter());
4699
4700        params.push("alt", "json");
4701        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
4702        if self._scopes.is_empty() {
4703            self._scopes
4704                .insert(Scope::CloudPlatform.as_ref().to_string());
4705        }
4706
4707        #[allow(clippy::single_element_loop)]
4708        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4709            url = params.uri_replacement(url, param_name, find_this, true);
4710        }
4711        {
4712            let to_remove = ["name"];
4713            params.remove_params(&to_remove);
4714        }
4715
4716        let url = params.parse_with_url(&url);
4717
4718        loop {
4719            let token = match self
4720                .hub
4721                .auth
4722                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4723                .await
4724            {
4725                Ok(token) => token,
4726                Err(e) => match dlg.token(e) {
4727                    Ok(token) => token,
4728                    Err(e) => {
4729                        dlg.finished(false);
4730                        return Err(common::Error::MissingToken(e));
4731                    }
4732                },
4733            };
4734            let mut req_result = {
4735                let client = &self.hub.client;
4736                dlg.pre_request();
4737                let mut req_builder = hyper::Request::builder()
4738                    .method(hyper::Method::GET)
4739                    .uri(url.as_str())
4740                    .header(USER_AGENT, self.hub._user_agent.clone());
4741
4742                if let Some(token) = token.as_ref() {
4743                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4744                }
4745
4746                let request = req_builder
4747                    .header(CONTENT_LENGTH, 0_u64)
4748                    .body(common::to_body::<String>(None));
4749
4750                client.request(request.unwrap()).await
4751            };
4752
4753            match req_result {
4754                Err(err) => {
4755                    if let common::Retry::After(d) = dlg.http_error(&err) {
4756                        sleep(d).await;
4757                        continue;
4758                    }
4759                    dlg.finished(false);
4760                    return Err(common::Error::HttpError(err));
4761                }
4762                Ok(res) => {
4763                    let (mut parts, body) = res.into_parts();
4764                    let mut body = common::Body::new(body);
4765                    if !parts.status.is_success() {
4766                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4767                        let error = serde_json::from_str(&common::to_string(&bytes));
4768                        let response = common::to_response(parts, bytes.into());
4769
4770                        if let common::Retry::After(d) =
4771                            dlg.http_failure(&response, error.as_ref().ok())
4772                        {
4773                            sleep(d).await;
4774                            continue;
4775                        }
4776
4777                        dlg.finished(false);
4778
4779                        return Err(match error {
4780                            Ok(value) => common::Error::BadRequest(value),
4781                            _ => common::Error::Failure(response),
4782                        });
4783                    }
4784                    let response = {
4785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4786                        let encoded = common::to_string(&bytes);
4787                        match serde_json::from_str(&encoded) {
4788                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4789                            Err(error) => {
4790                                dlg.response_json_decode_error(&encoded, &error);
4791                                return Err(common::Error::JsonDecodeError(
4792                                    encoded.to_string(),
4793                                    error,
4794                                ));
4795                            }
4796                        }
4797                    };
4798
4799                    dlg.finished(true);
4800                    return Ok(response);
4801                }
4802            }
4803        }
4804    }
4805
4806    /// The name of the operation's parent resource.
4807    ///
4808    /// Sets the *name* path property to the given value.
4809    ///
4810    /// Even though the property as already been set when instantiating this call,
4811    /// we provide this method for API completeness.
4812    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4813        self._name = new_value.to_string();
4814        self
4815    }
4816    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
4817    ///
4818    /// Sets the *return partial success* query property to the given value.
4819    pub fn return_partial_success(
4820        mut self,
4821        new_value: bool,
4822    ) -> ProjectLocationOperationListCall<'a, C> {
4823        self._return_partial_success = Some(new_value);
4824        self
4825    }
4826    /// The standard list page token.
4827    ///
4828    /// Sets the *page token* query property to the given value.
4829    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4830        self._page_token = Some(new_value.to_string());
4831        self
4832    }
4833    /// The standard list page size.
4834    ///
4835    /// Sets the *page size* query property to the given value.
4836    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
4837        self._page_size = Some(new_value);
4838        self
4839    }
4840    /// The standard list filter.
4841    ///
4842    /// Sets the *filter* query property to the given value.
4843    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4844        self._filter = Some(new_value.to_string());
4845        self
4846    }
4847    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4848    /// while executing the actual API request.
4849    ///
4850    /// ````text
4851    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4852    /// ````
4853    ///
4854    /// Sets the *delegate* property to the given value.
4855    pub fn delegate(
4856        mut self,
4857        new_value: &'a mut dyn common::Delegate,
4858    ) -> ProjectLocationOperationListCall<'a, C> {
4859        self._delegate = Some(new_value);
4860        self
4861    }
4862
4863    /// Set any additional parameter of the query string used in the request.
4864    /// It should be used to set parameters which are not yet available through their own
4865    /// setters.
4866    ///
4867    /// Please note that this method must not be used to set any of the known parameters
4868    /// which have their own setter method. If done anyway, the request will fail.
4869    ///
4870    /// # Additional Parameters
4871    ///
4872    /// * *$.xgafv* (query-string) - V1 error format.
4873    /// * *access_token* (query-string) - OAuth access token.
4874    /// * *alt* (query-string) - Data format for response.
4875    /// * *callback* (query-string) - JSONP
4876    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4877    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4878    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4879    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4880    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4881    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4882    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4883    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
4884    where
4885        T: AsRef<str>,
4886    {
4887        self._additional_params
4888            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4889        self
4890    }
4891
4892    /// Identifies the authorization scope for the method you are building.
4893    ///
4894    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4895    /// [`Scope::CloudPlatform`].
4896    ///
4897    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4898    /// tokens for more than one scope.
4899    ///
4900    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4901    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4902    /// sufficient, a read-write scope will do as well.
4903    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
4904    where
4905        St: AsRef<str>,
4906    {
4907        self._scopes.insert(String::from(scope.as_ref()));
4908        self
4909    }
4910    /// Identifies the authorization scope(s) for the method you are building.
4911    ///
4912    /// See [`Self::add_scope()`] for details.
4913    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
4914    where
4915        I: IntoIterator<Item = St>,
4916        St: AsRef<str>,
4917    {
4918        self._scopes
4919            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4920        self
4921    }
4922
4923    /// Removes all scopes, and no default scope will be used either.
4924    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4925    /// for details).
4926    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
4927        self._scopes.clear();
4928        self
4929    }
4930}
4931
4932/// Gets information about a location.
4933///
4934/// A builder for the *locations.get* method supported by a *project* resource.
4935/// It is not used directly, but through a [`ProjectMethods`] instance.
4936///
4937/// # Example
4938///
4939/// Instantiate a resource method builder
4940///
4941/// ```test_harness,no_run
4942/// # extern crate hyper;
4943/// # extern crate hyper_rustls;
4944/// # extern crate google_cloudscheduler1 as cloudscheduler1;
4945/// # async fn dox() {
4946/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4947///
4948/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4949/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4950/// #     .with_native_roots()
4951/// #     .unwrap()
4952/// #     .https_only()
4953/// #     .enable_http2()
4954/// #     .build();
4955///
4956/// # let executor = hyper_util::rt::TokioExecutor::new();
4957/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4958/// #     secret,
4959/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4960/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4961/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4962/// #     ),
4963/// # ).build().await.unwrap();
4964///
4965/// # let client = hyper_util::client::legacy::Client::builder(
4966/// #     hyper_util::rt::TokioExecutor::new()
4967/// # )
4968/// # .build(
4969/// #     hyper_rustls::HttpsConnectorBuilder::new()
4970/// #         .with_native_roots()
4971/// #         .unwrap()
4972/// #         .https_or_http()
4973/// #         .enable_http2()
4974/// #         .build()
4975/// # );
4976/// # let mut hub = CloudScheduler::new(client, auth);
4977/// // You can configure optional parameters by calling the respective setters at will, and
4978/// // execute the final call using `doit()`.
4979/// // Values shown here are possibly random and not representative !
4980/// let result = hub.projects().locations_get("name")
4981///              .doit().await;
4982/// # }
4983/// ```
4984pub struct ProjectLocationGetCall<'a, C>
4985where
4986    C: 'a,
4987{
4988    hub: &'a CloudScheduler<C>,
4989    _name: String,
4990    _delegate: Option<&'a mut dyn common::Delegate>,
4991    _additional_params: HashMap<String, String>,
4992    _scopes: BTreeSet<String>,
4993}
4994
4995impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
4996
4997impl<'a, C> ProjectLocationGetCall<'a, C>
4998where
4999    C: common::Connector,
5000{
5001    /// Perform the operation you have build so far.
5002    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
5003        use std::borrow::Cow;
5004        use std::io::{Read, Seek};
5005
5006        use common::{url::Params, ToParts};
5007        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5008
5009        let mut dd = common::DefaultDelegate;
5010        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5011        dlg.begin(common::MethodInfo {
5012            id: "cloudscheduler.projects.locations.get",
5013            http_method: hyper::Method::GET,
5014        });
5015
5016        for &field in ["alt", "name"].iter() {
5017            if self._additional_params.contains_key(field) {
5018                dlg.finished(false);
5019                return Err(common::Error::FieldClash(field));
5020            }
5021        }
5022
5023        let mut params = Params::with_capacity(3 + self._additional_params.len());
5024        params.push("name", self._name);
5025
5026        params.extend(self._additional_params.iter());
5027
5028        params.push("alt", "json");
5029        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5030        if self._scopes.is_empty() {
5031            self._scopes
5032                .insert(Scope::CloudPlatform.as_ref().to_string());
5033        }
5034
5035        #[allow(clippy::single_element_loop)]
5036        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5037            url = params.uri_replacement(url, param_name, find_this, true);
5038        }
5039        {
5040            let to_remove = ["name"];
5041            params.remove_params(&to_remove);
5042        }
5043
5044        let url = params.parse_with_url(&url);
5045
5046        loop {
5047            let token = match self
5048                .hub
5049                .auth
5050                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5051                .await
5052            {
5053                Ok(token) => token,
5054                Err(e) => match dlg.token(e) {
5055                    Ok(token) => token,
5056                    Err(e) => {
5057                        dlg.finished(false);
5058                        return Err(common::Error::MissingToken(e));
5059                    }
5060                },
5061            };
5062            let mut req_result = {
5063                let client = &self.hub.client;
5064                dlg.pre_request();
5065                let mut req_builder = hyper::Request::builder()
5066                    .method(hyper::Method::GET)
5067                    .uri(url.as_str())
5068                    .header(USER_AGENT, self.hub._user_agent.clone());
5069
5070                if let Some(token) = token.as_ref() {
5071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5072                }
5073
5074                let request = req_builder
5075                    .header(CONTENT_LENGTH, 0_u64)
5076                    .body(common::to_body::<String>(None));
5077
5078                client.request(request.unwrap()).await
5079            };
5080
5081            match req_result {
5082                Err(err) => {
5083                    if let common::Retry::After(d) = dlg.http_error(&err) {
5084                        sleep(d).await;
5085                        continue;
5086                    }
5087                    dlg.finished(false);
5088                    return Err(common::Error::HttpError(err));
5089                }
5090                Ok(res) => {
5091                    let (mut parts, body) = res.into_parts();
5092                    let mut body = common::Body::new(body);
5093                    if !parts.status.is_success() {
5094                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5095                        let error = serde_json::from_str(&common::to_string(&bytes));
5096                        let response = common::to_response(parts, bytes.into());
5097
5098                        if let common::Retry::After(d) =
5099                            dlg.http_failure(&response, error.as_ref().ok())
5100                        {
5101                            sleep(d).await;
5102                            continue;
5103                        }
5104
5105                        dlg.finished(false);
5106
5107                        return Err(match error {
5108                            Ok(value) => common::Error::BadRequest(value),
5109                            _ => common::Error::Failure(response),
5110                        });
5111                    }
5112                    let response = {
5113                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5114                        let encoded = common::to_string(&bytes);
5115                        match serde_json::from_str(&encoded) {
5116                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5117                            Err(error) => {
5118                                dlg.response_json_decode_error(&encoded, &error);
5119                                return Err(common::Error::JsonDecodeError(
5120                                    encoded.to_string(),
5121                                    error,
5122                                ));
5123                            }
5124                        }
5125                    };
5126
5127                    dlg.finished(true);
5128                    return Ok(response);
5129                }
5130            }
5131        }
5132    }
5133
5134    /// Resource name for the location.
5135    ///
5136    /// Sets the *name* path property to the given value.
5137    ///
5138    /// Even though the property as already been set when instantiating this call,
5139    /// we provide this method for API completeness.
5140    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
5141        self._name = new_value.to_string();
5142        self
5143    }
5144    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5145    /// while executing the actual API request.
5146    ///
5147    /// ````text
5148    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5149    /// ````
5150    ///
5151    /// Sets the *delegate* property to the given value.
5152    pub fn delegate(
5153        mut self,
5154        new_value: &'a mut dyn common::Delegate,
5155    ) -> ProjectLocationGetCall<'a, C> {
5156        self._delegate = Some(new_value);
5157        self
5158    }
5159
5160    /// Set any additional parameter of the query string used in the request.
5161    /// It should be used to set parameters which are not yet available through their own
5162    /// setters.
5163    ///
5164    /// Please note that this method must not be used to set any of the known parameters
5165    /// which have their own setter method. If done anyway, the request will fail.
5166    ///
5167    /// # Additional Parameters
5168    ///
5169    /// * *$.xgafv* (query-string) - V1 error format.
5170    /// * *access_token* (query-string) - OAuth access token.
5171    /// * *alt* (query-string) - Data format for response.
5172    /// * *callback* (query-string) - JSONP
5173    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5174    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5175    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5176    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5177    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5178    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5179    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5180    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
5181    where
5182        T: AsRef<str>,
5183    {
5184        self._additional_params
5185            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5186        self
5187    }
5188
5189    /// Identifies the authorization scope for the method you are building.
5190    ///
5191    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5192    /// [`Scope::CloudPlatform`].
5193    ///
5194    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5195    /// tokens for more than one scope.
5196    ///
5197    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5198    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5199    /// sufficient, a read-write scope will do as well.
5200    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
5201    where
5202        St: AsRef<str>,
5203    {
5204        self._scopes.insert(String::from(scope.as_ref()));
5205        self
5206    }
5207    /// Identifies the authorization scope(s) for the method you are building.
5208    ///
5209    /// See [`Self::add_scope()`] for details.
5210    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
5211    where
5212        I: IntoIterator<Item = St>,
5213        St: AsRef<str>,
5214    {
5215        self._scopes
5216            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5217        self
5218    }
5219
5220    /// Removes all scopes, and no default scope will be used either.
5221    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5222    /// for details).
5223    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
5224        self._scopes.clear();
5225        self
5226    }
5227}
5228
5229/// Gets the Scheduler config in the project/region.
5230///
5231/// A builder for the *locations.getCmekConfig* method supported by a *project* resource.
5232/// It is not used directly, but through a [`ProjectMethods`] instance.
5233///
5234/// # Example
5235///
5236/// Instantiate a resource method builder
5237///
5238/// ```test_harness,no_run
5239/// # extern crate hyper;
5240/// # extern crate hyper_rustls;
5241/// # extern crate google_cloudscheduler1 as cloudscheduler1;
5242/// # async fn dox() {
5243/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5244///
5245/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5246/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5247/// #     .with_native_roots()
5248/// #     .unwrap()
5249/// #     .https_only()
5250/// #     .enable_http2()
5251/// #     .build();
5252///
5253/// # let executor = hyper_util::rt::TokioExecutor::new();
5254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5255/// #     secret,
5256/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5257/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5258/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5259/// #     ),
5260/// # ).build().await.unwrap();
5261///
5262/// # let client = hyper_util::client::legacy::Client::builder(
5263/// #     hyper_util::rt::TokioExecutor::new()
5264/// # )
5265/// # .build(
5266/// #     hyper_rustls::HttpsConnectorBuilder::new()
5267/// #         .with_native_roots()
5268/// #         .unwrap()
5269/// #         .https_or_http()
5270/// #         .enable_http2()
5271/// #         .build()
5272/// # );
5273/// # let mut hub = CloudScheduler::new(client, auth);
5274/// // You can configure optional parameters by calling the respective setters at will, and
5275/// // execute the final call using `doit()`.
5276/// // Values shown here are possibly random and not representative !
5277/// let result = hub.projects().locations_get_cmek_config("name")
5278///              .doit().await;
5279/// # }
5280/// ```
5281pub struct ProjectLocationGetCmekConfigCall<'a, C>
5282where
5283    C: 'a,
5284{
5285    hub: &'a CloudScheduler<C>,
5286    _name: String,
5287    _delegate: Option<&'a mut dyn common::Delegate>,
5288    _additional_params: HashMap<String, String>,
5289    _scopes: BTreeSet<String>,
5290}
5291
5292impl<'a, C> common::CallBuilder for ProjectLocationGetCmekConfigCall<'a, C> {}
5293
5294impl<'a, C> ProjectLocationGetCmekConfigCall<'a, C>
5295where
5296    C: common::Connector,
5297{
5298    /// Perform the operation you have build so far.
5299    pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
5300        use std::borrow::Cow;
5301        use std::io::{Read, Seek};
5302
5303        use common::{url::Params, ToParts};
5304        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5305
5306        let mut dd = common::DefaultDelegate;
5307        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5308        dlg.begin(common::MethodInfo {
5309            id: "cloudscheduler.projects.locations.getCmekConfig",
5310            http_method: hyper::Method::GET,
5311        });
5312
5313        for &field in ["alt", "name"].iter() {
5314            if self._additional_params.contains_key(field) {
5315                dlg.finished(false);
5316                return Err(common::Error::FieldClash(field));
5317            }
5318        }
5319
5320        let mut params = Params::with_capacity(3 + self._additional_params.len());
5321        params.push("name", self._name);
5322
5323        params.extend(self._additional_params.iter());
5324
5325        params.push("alt", "json");
5326        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5327        if self._scopes.is_empty() {
5328            self._scopes
5329                .insert(Scope::CloudPlatform.as_ref().to_string());
5330        }
5331
5332        #[allow(clippy::single_element_loop)]
5333        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5334            url = params.uri_replacement(url, param_name, find_this, true);
5335        }
5336        {
5337            let to_remove = ["name"];
5338            params.remove_params(&to_remove);
5339        }
5340
5341        let url = params.parse_with_url(&url);
5342
5343        loop {
5344            let token = match self
5345                .hub
5346                .auth
5347                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5348                .await
5349            {
5350                Ok(token) => token,
5351                Err(e) => match dlg.token(e) {
5352                    Ok(token) => token,
5353                    Err(e) => {
5354                        dlg.finished(false);
5355                        return Err(common::Error::MissingToken(e));
5356                    }
5357                },
5358            };
5359            let mut req_result = {
5360                let client = &self.hub.client;
5361                dlg.pre_request();
5362                let mut req_builder = hyper::Request::builder()
5363                    .method(hyper::Method::GET)
5364                    .uri(url.as_str())
5365                    .header(USER_AGENT, self.hub._user_agent.clone());
5366
5367                if let Some(token) = token.as_ref() {
5368                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5369                }
5370
5371                let request = req_builder
5372                    .header(CONTENT_LENGTH, 0_u64)
5373                    .body(common::to_body::<String>(None));
5374
5375                client.request(request.unwrap()).await
5376            };
5377
5378            match req_result {
5379                Err(err) => {
5380                    if let common::Retry::After(d) = dlg.http_error(&err) {
5381                        sleep(d).await;
5382                        continue;
5383                    }
5384                    dlg.finished(false);
5385                    return Err(common::Error::HttpError(err));
5386                }
5387                Ok(res) => {
5388                    let (mut parts, body) = res.into_parts();
5389                    let mut body = common::Body::new(body);
5390                    if !parts.status.is_success() {
5391                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5392                        let error = serde_json::from_str(&common::to_string(&bytes));
5393                        let response = common::to_response(parts, bytes.into());
5394
5395                        if let common::Retry::After(d) =
5396                            dlg.http_failure(&response, error.as_ref().ok())
5397                        {
5398                            sleep(d).await;
5399                            continue;
5400                        }
5401
5402                        dlg.finished(false);
5403
5404                        return Err(match error {
5405                            Ok(value) => common::Error::BadRequest(value),
5406                            _ => common::Error::Failure(response),
5407                        });
5408                    }
5409                    let response = {
5410                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5411                        let encoded = common::to_string(&bytes);
5412                        match serde_json::from_str(&encoded) {
5413                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5414                            Err(error) => {
5415                                dlg.response_json_decode_error(&encoded, &error);
5416                                return Err(common::Error::JsonDecodeError(
5417                                    encoded.to_string(),
5418                                    error,
5419                                ));
5420                            }
5421                        }
5422                    };
5423
5424                    dlg.finished(true);
5425                    return Ok(response);
5426                }
5427            }
5428        }
5429    }
5430
5431    /// Required. The config name. For example: projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig
5432    ///
5433    /// Sets the *name* path property to the given value.
5434    ///
5435    /// Even though the property as already been set when instantiating this call,
5436    /// we provide this method for API completeness.
5437    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
5438        self._name = new_value.to_string();
5439        self
5440    }
5441    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5442    /// while executing the actual API request.
5443    ///
5444    /// ````text
5445    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5446    /// ````
5447    ///
5448    /// Sets the *delegate* property to the given value.
5449    pub fn delegate(
5450        mut self,
5451        new_value: &'a mut dyn common::Delegate,
5452    ) -> ProjectLocationGetCmekConfigCall<'a, C> {
5453        self._delegate = Some(new_value);
5454        self
5455    }
5456
5457    /// Set any additional parameter of the query string used in the request.
5458    /// It should be used to set parameters which are not yet available through their own
5459    /// setters.
5460    ///
5461    /// Please note that this method must not be used to set any of the known parameters
5462    /// which have their own setter method. If done anyway, the request will fail.
5463    ///
5464    /// # Additional Parameters
5465    ///
5466    /// * *$.xgafv* (query-string) - V1 error format.
5467    /// * *access_token* (query-string) - OAuth access token.
5468    /// * *alt* (query-string) - Data format for response.
5469    /// * *callback* (query-string) - JSONP
5470    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5471    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5472    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5473    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5474    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5475    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5476    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5477    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCmekConfigCall<'a, C>
5478    where
5479        T: AsRef<str>,
5480    {
5481        self._additional_params
5482            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5483        self
5484    }
5485
5486    /// Identifies the authorization scope for the method you are building.
5487    ///
5488    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5489    /// [`Scope::CloudPlatform`].
5490    ///
5491    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5492    /// tokens for more than one scope.
5493    ///
5494    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5495    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5496    /// sufficient, a read-write scope will do as well.
5497    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCmekConfigCall<'a, C>
5498    where
5499        St: AsRef<str>,
5500    {
5501        self._scopes.insert(String::from(scope.as_ref()));
5502        self
5503    }
5504    /// Identifies the authorization scope(s) for the method you are building.
5505    ///
5506    /// See [`Self::add_scope()`] for details.
5507    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCmekConfigCall<'a, C>
5508    where
5509        I: IntoIterator<Item = St>,
5510        St: AsRef<str>,
5511    {
5512        self._scopes
5513            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5514        self
5515    }
5516
5517    /// Removes all scopes, and no default scope will be used either.
5518    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5519    /// for details).
5520    pub fn clear_scopes(mut self) -> ProjectLocationGetCmekConfigCall<'a, C> {
5521        self._scopes.clear();
5522        self
5523    }
5524}
5525
5526/// Lists information about the supported locations for this service.
5527///
5528/// A builder for the *locations.list* method supported by a *project* resource.
5529/// It is not used directly, but through a [`ProjectMethods`] instance.
5530///
5531/// # Example
5532///
5533/// Instantiate a resource method builder
5534///
5535/// ```test_harness,no_run
5536/// # extern crate hyper;
5537/// # extern crate hyper_rustls;
5538/// # extern crate google_cloudscheduler1 as cloudscheduler1;
5539/// # async fn dox() {
5540/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5541///
5542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5543/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5544/// #     .with_native_roots()
5545/// #     .unwrap()
5546/// #     .https_only()
5547/// #     .enable_http2()
5548/// #     .build();
5549///
5550/// # let executor = hyper_util::rt::TokioExecutor::new();
5551/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5552/// #     secret,
5553/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5554/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5555/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5556/// #     ),
5557/// # ).build().await.unwrap();
5558///
5559/// # let client = hyper_util::client::legacy::Client::builder(
5560/// #     hyper_util::rt::TokioExecutor::new()
5561/// # )
5562/// # .build(
5563/// #     hyper_rustls::HttpsConnectorBuilder::new()
5564/// #         .with_native_roots()
5565/// #         .unwrap()
5566/// #         .https_or_http()
5567/// #         .enable_http2()
5568/// #         .build()
5569/// # );
5570/// # let mut hub = CloudScheduler::new(client, auth);
5571/// // You can configure optional parameters by calling the respective setters at will, and
5572/// // execute the final call using `doit()`.
5573/// // Values shown here are possibly random and not representative !
5574/// let result = hub.projects().locations_list("name")
5575///              .page_token("gubergren")
5576///              .page_size(-16)
5577///              .filter("est")
5578///              .add_extra_location_types("ipsum")
5579///              .doit().await;
5580/// # }
5581/// ```
5582pub struct ProjectLocationListCall<'a, C>
5583where
5584    C: 'a,
5585{
5586    hub: &'a CloudScheduler<C>,
5587    _name: String,
5588    _page_token: Option<String>,
5589    _page_size: Option<i32>,
5590    _filter: Option<String>,
5591    _extra_location_types: Vec<String>,
5592    _delegate: Option<&'a mut dyn common::Delegate>,
5593    _additional_params: HashMap<String, String>,
5594    _scopes: BTreeSet<String>,
5595}
5596
5597impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
5598
5599impl<'a, C> ProjectLocationListCall<'a, C>
5600where
5601    C: common::Connector,
5602{
5603    /// Perform the operation you have build so far.
5604    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
5605        use std::borrow::Cow;
5606        use std::io::{Read, Seek};
5607
5608        use common::{url::Params, ToParts};
5609        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5610
5611        let mut dd = common::DefaultDelegate;
5612        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5613        dlg.begin(common::MethodInfo {
5614            id: "cloudscheduler.projects.locations.list",
5615            http_method: hyper::Method::GET,
5616        });
5617
5618        for &field in [
5619            "alt",
5620            "name",
5621            "pageToken",
5622            "pageSize",
5623            "filter",
5624            "extraLocationTypes",
5625        ]
5626        .iter()
5627        {
5628            if self._additional_params.contains_key(field) {
5629                dlg.finished(false);
5630                return Err(common::Error::FieldClash(field));
5631            }
5632        }
5633
5634        let mut params = Params::with_capacity(7 + self._additional_params.len());
5635        params.push("name", self._name);
5636        if let Some(value) = self._page_token.as_ref() {
5637            params.push("pageToken", value);
5638        }
5639        if let Some(value) = self._page_size.as_ref() {
5640            params.push("pageSize", value.to_string());
5641        }
5642        if let Some(value) = self._filter.as_ref() {
5643            params.push("filter", value);
5644        }
5645        if !self._extra_location_types.is_empty() {
5646            for f in self._extra_location_types.iter() {
5647                params.push("extraLocationTypes", f);
5648            }
5649        }
5650
5651        params.extend(self._additional_params.iter());
5652
5653        params.push("alt", "json");
5654        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
5655        if self._scopes.is_empty() {
5656            self._scopes
5657                .insert(Scope::CloudPlatform.as_ref().to_string());
5658        }
5659
5660        #[allow(clippy::single_element_loop)]
5661        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5662            url = params.uri_replacement(url, param_name, find_this, true);
5663        }
5664        {
5665            let to_remove = ["name"];
5666            params.remove_params(&to_remove);
5667        }
5668
5669        let url = params.parse_with_url(&url);
5670
5671        loop {
5672            let token = match self
5673                .hub
5674                .auth
5675                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5676                .await
5677            {
5678                Ok(token) => token,
5679                Err(e) => match dlg.token(e) {
5680                    Ok(token) => token,
5681                    Err(e) => {
5682                        dlg.finished(false);
5683                        return Err(common::Error::MissingToken(e));
5684                    }
5685                },
5686            };
5687            let mut req_result = {
5688                let client = &self.hub.client;
5689                dlg.pre_request();
5690                let mut req_builder = hyper::Request::builder()
5691                    .method(hyper::Method::GET)
5692                    .uri(url.as_str())
5693                    .header(USER_AGENT, self.hub._user_agent.clone());
5694
5695                if let Some(token) = token.as_ref() {
5696                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5697                }
5698
5699                let request = req_builder
5700                    .header(CONTENT_LENGTH, 0_u64)
5701                    .body(common::to_body::<String>(None));
5702
5703                client.request(request.unwrap()).await
5704            };
5705
5706            match req_result {
5707                Err(err) => {
5708                    if let common::Retry::After(d) = dlg.http_error(&err) {
5709                        sleep(d).await;
5710                        continue;
5711                    }
5712                    dlg.finished(false);
5713                    return Err(common::Error::HttpError(err));
5714                }
5715                Ok(res) => {
5716                    let (mut parts, body) = res.into_parts();
5717                    let mut body = common::Body::new(body);
5718                    if !parts.status.is_success() {
5719                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5720                        let error = serde_json::from_str(&common::to_string(&bytes));
5721                        let response = common::to_response(parts, bytes.into());
5722
5723                        if let common::Retry::After(d) =
5724                            dlg.http_failure(&response, error.as_ref().ok())
5725                        {
5726                            sleep(d).await;
5727                            continue;
5728                        }
5729
5730                        dlg.finished(false);
5731
5732                        return Err(match error {
5733                            Ok(value) => common::Error::BadRequest(value),
5734                            _ => common::Error::Failure(response),
5735                        });
5736                    }
5737                    let response = {
5738                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5739                        let encoded = common::to_string(&bytes);
5740                        match serde_json::from_str(&encoded) {
5741                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5742                            Err(error) => {
5743                                dlg.response_json_decode_error(&encoded, &error);
5744                                return Err(common::Error::JsonDecodeError(
5745                                    encoded.to_string(),
5746                                    error,
5747                                ));
5748                            }
5749                        }
5750                    };
5751
5752                    dlg.finished(true);
5753                    return Ok(response);
5754                }
5755            }
5756        }
5757    }
5758
5759    /// The resource that owns the locations collection, if applicable.
5760    ///
5761    /// Sets the *name* path property to the given value.
5762    ///
5763    /// Even though the property as already been set when instantiating this call,
5764    /// we provide this method for API completeness.
5765    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5766        self._name = new_value.to_string();
5767        self
5768    }
5769    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
5770    ///
5771    /// Sets the *page token* query property to the given value.
5772    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5773        self._page_token = Some(new_value.to_string());
5774        self
5775    }
5776    /// The maximum number of results to return. If not set, the service selects a default.
5777    ///
5778    /// Sets the *page size* query property to the given value.
5779    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
5780        self._page_size = Some(new_value);
5781        self
5782    }
5783    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
5784    ///
5785    /// Sets the *filter* query property to the given value.
5786    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5787        self._filter = Some(new_value.to_string());
5788        self
5789    }
5790    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
5791    ///
5792    /// Append the given value to the *extra location types* query property.
5793    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5794    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5795        self._extra_location_types.push(new_value.to_string());
5796        self
5797    }
5798    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5799    /// while executing the actual API request.
5800    ///
5801    /// ````text
5802    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5803    /// ````
5804    ///
5805    /// Sets the *delegate* property to the given value.
5806    pub fn delegate(
5807        mut self,
5808        new_value: &'a mut dyn common::Delegate,
5809    ) -> ProjectLocationListCall<'a, C> {
5810        self._delegate = Some(new_value);
5811        self
5812    }
5813
5814    /// Set any additional parameter of the query string used in the request.
5815    /// It should be used to set parameters which are not yet available through their own
5816    /// setters.
5817    ///
5818    /// Please note that this method must not be used to set any of the known parameters
5819    /// which have their own setter method. If done anyway, the request will fail.
5820    ///
5821    /// # Additional Parameters
5822    ///
5823    /// * *$.xgafv* (query-string) - V1 error format.
5824    /// * *access_token* (query-string) - OAuth access token.
5825    /// * *alt* (query-string) - Data format for response.
5826    /// * *callback* (query-string) - JSONP
5827    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5828    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5829    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5830    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5831    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5832    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5833    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5834    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
5835    where
5836        T: AsRef<str>,
5837    {
5838        self._additional_params
5839            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5840        self
5841    }
5842
5843    /// Identifies the authorization scope for the method you are building.
5844    ///
5845    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5846    /// [`Scope::CloudPlatform`].
5847    ///
5848    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5849    /// tokens for more than one scope.
5850    ///
5851    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5852    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5853    /// sufficient, a read-write scope will do as well.
5854    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
5855    where
5856        St: AsRef<str>,
5857    {
5858        self._scopes.insert(String::from(scope.as_ref()));
5859        self
5860    }
5861    /// Identifies the authorization scope(s) for the method you are building.
5862    ///
5863    /// See [`Self::add_scope()`] for details.
5864    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
5865    where
5866        I: IntoIterator<Item = St>,
5867        St: AsRef<str>,
5868    {
5869        self._scopes
5870            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5871        self
5872    }
5873
5874    /// Removes all scopes, and no default scope will be used either.
5875    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5876    /// for details).
5877    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
5878        self._scopes.clear();
5879        self
5880    }
5881}
5882
5883/// Initializes or Updates the a scheduler config.
5884///
5885/// A builder for the *locations.updateCmekConfig* method supported by a *project* resource.
5886/// It is not used directly, but through a [`ProjectMethods`] instance.
5887///
5888/// # Example
5889///
5890/// Instantiate a resource method builder
5891///
5892/// ```test_harness,no_run
5893/// # extern crate hyper;
5894/// # extern crate hyper_rustls;
5895/// # extern crate google_cloudscheduler1 as cloudscheduler1;
5896/// use cloudscheduler1::api::CmekConfig;
5897/// # async fn dox() {
5898/// # use cloudscheduler1::{CloudScheduler, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5899///
5900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5902/// #     .with_native_roots()
5903/// #     .unwrap()
5904/// #     .https_only()
5905/// #     .enable_http2()
5906/// #     .build();
5907///
5908/// # let executor = hyper_util::rt::TokioExecutor::new();
5909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5910/// #     secret,
5911/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5912/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5913/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5914/// #     ),
5915/// # ).build().await.unwrap();
5916///
5917/// # let client = hyper_util::client::legacy::Client::builder(
5918/// #     hyper_util::rt::TokioExecutor::new()
5919/// # )
5920/// # .build(
5921/// #     hyper_rustls::HttpsConnectorBuilder::new()
5922/// #         .with_native_roots()
5923/// #         .unwrap()
5924/// #         .https_or_http()
5925/// #         .enable_http2()
5926/// #         .build()
5927/// # );
5928/// # let mut hub = CloudScheduler::new(client, auth);
5929/// // As the method needs a request, you would usually fill it with the desired information
5930/// // into the respective structure. Some of the parts shown here might not be applicable !
5931/// // Values shown here are possibly random and not representative !
5932/// let mut req = CmekConfig::default();
5933///
5934/// // You can configure optional parameters by calling the respective setters at will, and
5935/// // execute the final call using `doit()`.
5936/// // Values shown here are possibly random and not representative !
5937/// let result = hub.projects().locations_update_cmek_config(req, "name")
5938///              .update_mask(FieldMask::new::<&str>(&[]))
5939///              .doit().await;
5940/// # }
5941/// ```
5942pub struct ProjectLocationUpdateCmekConfigCall<'a, C>
5943where
5944    C: 'a,
5945{
5946    hub: &'a CloudScheduler<C>,
5947    _request: CmekConfig,
5948    _name: String,
5949    _update_mask: Option<common::FieldMask>,
5950    _delegate: Option<&'a mut dyn common::Delegate>,
5951    _additional_params: HashMap<String, String>,
5952    _scopes: BTreeSet<String>,
5953}
5954
5955impl<'a, C> common::CallBuilder for ProjectLocationUpdateCmekConfigCall<'a, C> {}
5956
5957impl<'a, C> ProjectLocationUpdateCmekConfigCall<'a, C>
5958where
5959    C: common::Connector,
5960{
5961    /// Perform the operation you have build so far.
5962    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5963        use std::borrow::Cow;
5964        use std::io::{Read, Seek};
5965
5966        use common::{url::Params, ToParts};
5967        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5968
5969        let mut dd = common::DefaultDelegate;
5970        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5971        dlg.begin(common::MethodInfo {
5972            id: "cloudscheduler.projects.locations.updateCmekConfig",
5973            http_method: hyper::Method::PATCH,
5974        });
5975
5976        for &field in ["alt", "name", "updateMask"].iter() {
5977            if self._additional_params.contains_key(field) {
5978                dlg.finished(false);
5979                return Err(common::Error::FieldClash(field));
5980            }
5981        }
5982
5983        let mut params = Params::with_capacity(5 + self._additional_params.len());
5984        params.push("name", self._name);
5985        if let Some(value) = self._update_mask.as_ref() {
5986            params.push("updateMask", value.to_string());
5987        }
5988
5989        params.extend(self._additional_params.iter());
5990
5991        params.push("alt", "json");
5992        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5993        if self._scopes.is_empty() {
5994            self._scopes
5995                .insert(Scope::CloudPlatform.as_ref().to_string());
5996        }
5997
5998        #[allow(clippy::single_element_loop)]
5999        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6000            url = params.uri_replacement(url, param_name, find_this, true);
6001        }
6002        {
6003            let to_remove = ["name"];
6004            params.remove_params(&to_remove);
6005        }
6006
6007        let url = params.parse_with_url(&url);
6008
6009        let mut json_mime_type = mime::APPLICATION_JSON;
6010        let mut request_value_reader = {
6011            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6012            common::remove_json_null_values(&mut value);
6013            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6014            serde_json::to_writer(&mut dst, &value).unwrap();
6015            dst
6016        };
6017        let request_size = request_value_reader
6018            .seek(std::io::SeekFrom::End(0))
6019            .unwrap();
6020        request_value_reader
6021            .seek(std::io::SeekFrom::Start(0))
6022            .unwrap();
6023
6024        loop {
6025            let token = match self
6026                .hub
6027                .auth
6028                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6029                .await
6030            {
6031                Ok(token) => token,
6032                Err(e) => match dlg.token(e) {
6033                    Ok(token) => token,
6034                    Err(e) => {
6035                        dlg.finished(false);
6036                        return Err(common::Error::MissingToken(e));
6037                    }
6038                },
6039            };
6040            request_value_reader
6041                .seek(std::io::SeekFrom::Start(0))
6042                .unwrap();
6043            let mut req_result = {
6044                let client = &self.hub.client;
6045                dlg.pre_request();
6046                let mut req_builder = hyper::Request::builder()
6047                    .method(hyper::Method::PATCH)
6048                    .uri(url.as_str())
6049                    .header(USER_AGENT, self.hub._user_agent.clone());
6050
6051                if let Some(token) = token.as_ref() {
6052                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6053                }
6054
6055                let request = req_builder
6056                    .header(CONTENT_TYPE, json_mime_type.to_string())
6057                    .header(CONTENT_LENGTH, request_size as u64)
6058                    .body(common::to_body(
6059                        request_value_reader.get_ref().clone().into(),
6060                    ));
6061
6062                client.request(request.unwrap()).await
6063            };
6064
6065            match req_result {
6066                Err(err) => {
6067                    if let common::Retry::After(d) = dlg.http_error(&err) {
6068                        sleep(d).await;
6069                        continue;
6070                    }
6071                    dlg.finished(false);
6072                    return Err(common::Error::HttpError(err));
6073                }
6074                Ok(res) => {
6075                    let (mut parts, body) = res.into_parts();
6076                    let mut body = common::Body::new(body);
6077                    if !parts.status.is_success() {
6078                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6079                        let error = serde_json::from_str(&common::to_string(&bytes));
6080                        let response = common::to_response(parts, bytes.into());
6081
6082                        if let common::Retry::After(d) =
6083                            dlg.http_failure(&response, error.as_ref().ok())
6084                        {
6085                            sleep(d).await;
6086                            continue;
6087                        }
6088
6089                        dlg.finished(false);
6090
6091                        return Err(match error {
6092                            Ok(value) => common::Error::BadRequest(value),
6093                            _ => common::Error::Failure(response),
6094                        });
6095                    }
6096                    let response = {
6097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6098                        let encoded = common::to_string(&bytes);
6099                        match serde_json::from_str(&encoded) {
6100                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6101                            Err(error) => {
6102                                dlg.response_json_decode_error(&encoded, &error);
6103                                return Err(common::Error::JsonDecodeError(
6104                                    encoded.to_string(),
6105                                    error,
6106                                ));
6107                            }
6108                        }
6109                    };
6110
6111                    dlg.finished(true);
6112                    return Ok(response);
6113                }
6114            }
6115        }
6116    }
6117
6118    ///
6119    /// Sets the *request* property to the given value.
6120    ///
6121    /// Even though the property as already been set when instantiating this call,
6122    /// we provide this method for API completeness.
6123    pub fn request(mut self, new_value: CmekConfig) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
6124        self._request = new_value;
6125        self
6126    }
6127    /// Identifier. The config resource name which includes the project and location and must end in 'cmekConfig', in the format projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig`
6128    ///
6129    /// Sets the *name* path property to the given value.
6130    ///
6131    /// Even though the property as already been set when instantiating this call,
6132    /// we provide this method for API completeness.
6133    pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
6134        self._name = new_value.to_string();
6135        self
6136    }
6137    /// Optional. List of fields to be updated in this request.
6138    ///
6139    /// Sets the *update mask* query property to the given value.
6140    pub fn update_mask(
6141        mut self,
6142        new_value: common::FieldMask,
6143    ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
6144        self._update_mask = Some(new_value);
6145        self
6146    }
6147    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6148    /// while executing the actual API request.
6149    ///
6150    /// ````text
6151    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6152    /// ````
6153    ///
6154    /// Sets the *delegate* property to the given value.
6155    pub fn delegate(
6156        mut self,
6157        new_value: &'a mut dyn common::Delegate,
6158    ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
6159        self._delegate = Some(new_value);
6160        self
6161    }
6162
6163    /// Set any additional parameter of the query string used in the request.
6164    /// It should be used to set parameters which are not yet available through their own
6165    /// setters.
6166    ///
6167    /// Please note that this method must not be used to set any of the known parameters
6168    /// which have their own setter method. If done anyway, the request will fail.
6169    ///
6170    /// # Additional Parameters
6171    ///
6172    /// * *$.xgafv* (query-string) - V1 error format.
6173    /// * *access_token* (query-string) - OAuth access token.
6174    /// * *alt* (query-string) - Data format for response.
6175    /// * *callback* (query-string) - JSONP
6176    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6177    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6178    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6179    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6180    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6181    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6182    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6183    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateCmekConfigCall<'a, C>
6184    where
6185        T: AsRef<str>,
6186    {
6187        self._additional_params
6188            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6189        self
6190    }
6191
6192    /// Identifies the authorization scope for the method you are building.
6193    ///
6194    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6195    /// [`Scope::CloudPlatform`].
6196    ///
6197    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6198    /// tokens for more than one scope.
6199    ///
6200    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6201    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6202    /// sufficient, a read-write scope will do as well.
6203    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateCmekConfigCall<'a, C>
6204    where
6205        St: AsRef<str>,
6206    {
6207        self._scopes.insert(String::from(scope.as_ref()));
6208        self
6209    }
6210    /// Identifies the authorization scope(s) for the method you are building.
6211    ///
6212    /// See [`Self::add_scope()`] for details.
6213    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateCmekConfigCall<'a, C>
6214    where
6215        I: IntoIterator<Item = St>,
6216        St: AsRef<str>,
6217    {
6218        self._scopes
6219            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6220        self
6221    }
6222
6223    /// Removes all scopes, and no default scope will be used either.
6224    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6225    /// for details).
6226    pub fn clear_scopes(mut self) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
6227        self._scopes.clear();
6228        self
6229    }
6230}