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