google_cloudtasks2_beta2/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 CloudTasks 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_cloudtasks2_beta2 as cloudtasks2_beta2;
49/// use cloudtasks2_beta2::api::Queue;
50/// use cloudtasks2_beta2::{Result, Error};
51/// # async fn dox() {
52/// use cloudtasks2_beta2::{CloudTasks, 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 = CloudTasks::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 = Queue::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_queues_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 CloudTasks<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 CloudTasks<C> {}
131
132impl<'a, C> CloudTasks<C> {
133 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudTasks<C> {
134 CloudTasks {
135 client,
136 auth: Box::new(auth),
137 _user_agent: "google-api-rust-client/7.0.0".to_string(),
138 _base_url: "https://cloudtasks.googleapis.com/".to_string(),
139 _root_url: "https://cloudtasks.googleapis.com/".to_string(),
140 }
141 }
142
143 pub fn api(&'a self) -> ApiMethods<'a, C> {
144 ApiMethods { hub: self }
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://cloudtasks.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://cloudtasks.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/// Request message for acknowledging a task using AcknowledgeTask.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [locations queues tasks acknowledge projects](ProjectLocationQueueTaskAcknowledgeCall) (request)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct AcknowledgeTaskRequest {
190 /// Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease.
191 #[serde(rename = "scheduleTime")]
192 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
193}
194
195impl common::RequestValue for AcknowledgeTaskRequest {}
196
197/// App Engine HTTP request. The message defines the HTTP request that is sent to an App Engine app when the task is dispatched. This proto can only be used for tasks in a queue which has app_engine_http_target set. Using AppEngineHttpRequest requires [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control) Google IAM permission for the project and the following scope: `https://www.googleapis.com/auth/cloud-platform` The task will be delivered to the App Engine app which belongs to the same project as the queue. For more information, see [How Requests are Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) and how routing is affected by [dispatch files](https://cloud.google.com/appengine/docs/python/config/dispatchref). Traffic is encrypted during transport and never leaves Google datacenters. Because this traffic is carried over a communication mechanism internal to Google, you cannot explicitly set the protocol (for example, HTTP or HTTPS). The request to the handler, however, will appear to have used the HTTP protocol. The AppEngineRouting used to construct the URL that the task is delivered to can be set at the queue-level or task-level: * If set, app_engine_routing_override is used for all tasks in the queue, no matter what the setting is for the task-level app_engine_routing. The `url` that the task will be sent to is: * `url =` host `+` relative_url Tasks can be dispatched to secure app handlers, unsecure app handlers, and URIs restricted with [`login: admin`](https://cloud.google.com/appengine/docs/standard/python/config/appref). Because tasks are not run as any user, they cannot be dispatched to URIs restricted with [`login: required`](https://cloud.google.com/appengine/docs/standard/python/config/appref) Task dispatches also do not follow redirects. The task attempt has succeeded if the app's request handler returns an HTTP response code in the range [`200` - `299`]. The task attempt has failed if the app's handler returns a non-2xx response code or Cloud Tasks does not receive response before the deadline. Failed tasks will be retried according to the retry configuration. `503` (Service Unavailable) is considered an App Engine system error instead of an application error and will cause Cloud Tasks' traffic congestion control to temporarily throttle the queue's dispatches. Unlike other types of task targets, a `429` (Too Many Requests) response from an app handler does not cause traffic congestion control to throttle the queue.
198///
199/// This type is not used in any activity, and only used as *part* of another schema.
200///
201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
202#[serde_with::serde_as]
203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
204pub struct AppEngineHttpRequest {
205 /// Task-level setting for App Engine routing. If set, app_engine_routing_override is used for all tasks in the queue, no matter what the setting is for the task-level app_engine_routing.
206 #[serde(rename = "appEngineRouting")]
207 pub app_engine_routing: Option<AppEngineRouting>,
208 /// HTTP request headers. This map contains the header field names and values. Headers can be set when the task is created. Repeated headers are not supported but a header value can contain commas. Cloud Tasks 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 Tasks will append `"AppEngine-Google; (+http://code.google.com/appengine)"` to the modified `User-Agent`. If the task has a payload, Cloud Tasks sets the following headers: * `Content-Type`: By default, the `Content-Type` header is set to `"application/octet-stream"`. The default can be overridden by explicitly setting `Content-Type` to a particular media type when the task is created. For example, `Content-Type` can be set to `"application/json"`. * `Content-Length`: This is computed by Cloud Tasks. This value is output only. It cannot be changed. The headers below cannot be set or overridden: * `Host` * `X-Google-*` * `X-AppEngine-*` In addition, Cloud Tasks sets some headers when the task is dispatched, such as headers containing information about the task; see [request headers](https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-handlers#reading_request_headers). These headers are set only when the task is dispatched, so they are not visible when the task is returned in a Cloud Tasks response. Although there is no specific limit for the maximum number of headers or the size, there is a limit on the maximum size of the Task. For more information, see the CreateTask documentation.
209 pub headers: Option<HashMap<String, String>>,
210 /// The HTTP method to use for the request. The default is POST. The app's request handler for the task's target URL must be able to handle HTTP requests with this http_method, otherwise the task attempt fails with error code 405 (Method Not Allowed). See [Writing a push task request handler](https://cloud.google.com/appengine/docs/java/taskqueue/push/creating-handlers#writing_a_push_task_request_handler) and the App Engine documentation for your runtime on [How Requests are Handled](https://cloud.google.com/appengine/docs/standard/python3/how-requests-are-handled).
211 #[serde(rename = "httpMethod")]
212 pub http_method: Option<String>,
213 /// Payload. The payload will be sent as the HTTP message body. A message body, and thus a payload, is allowed only if the HTTP method is POST or PUT. It is an error to set a data payload on a task with an incompatible HttpMethod.
214 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
215 pub payload: Option<Vec<u8>>,
216 /// The relative URL. The relative URL must begin with "/" and must be a valid HTTP relative URL. It can contain a path and query string arguments. 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.
217 #[serde(rename = "relativeUrl")]
218 pub relative_url: Option<String>,
219}
220
221impl common::Part for AppEngineHttpRequest {}
222
223/// App Engine HTTP target. The task will be delivered to the App Engine application hostname specified by its AppEngineHttpTarget and AppEngineHttpRequest. The documentation for AppEngineHttpRequest explains how the task's host URL is constructed. Using AppEngineHttpTarget requires [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control) Google IAM permission for the project and the following scope: `https://www.googleapis.com/auth/cloud-platform`
224///
225/// This type is not used in any activity, and only used as *part* of another schema.
226///
227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
228#[serde_with::serde_as]
229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
230pub struct AppEngineHttpTarget {
231 /// Overrides for the task-level app_engine_routing. If set, `app_engine_routing_override` is used for all tasks in the queue, no matter what the setting is for the task-level app_engine_routing.
232 #[serde(rename = "appEngineRoutingOverride")]
233 pub app_engine_routing_override: Option<AppEngineRouting>,
234}
235
236impl common::Part for AppEngineHttpTarget {}
237
238/// App Engine Routing. Defines routing characteristics specific to App Engine - service, version, and instance. 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).
239///
240/// This type is not used in any activity, and only used as *part* of another schema.
241///
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct AppEngineRouting {
246 /// Output only. The host that the task is sent to. For more information, see [How Requests are Routed](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 queue's project ID. Some tasks which were created using the App Engine SDK use a custom domain name. * `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 task will be sent to the service which is the default service when the task is attempted. If version is empty, then the task will be sent to the version which is the default version when the task is attempted. If instance is empty, then the task will be sent to an instance which is available when the task is attempted. If service, version, or instance is invalid, then the task will be sent to the default version of the default service when the task is attempted.
247 pub host: Option<String>,
248 /// App instance. By default, the task is sent to an instance which is available when the task is attempted. Requests can only be sent to a specific instance if [manual scaling is used in App Engine Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes). App Engine Flex does not support instances. For more information, see [App Engine Standard request routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) and [App Engine Flex request routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
249 pub instance: Option<String>,
250 /// App service. By default, the task is sent to the service which is the default service when the task is attempted. For some queues or tasks which were created using the App Engine Task Queue API, host is not parsable into service, version, and instance. For example, some tasks which were created using the App Engine SDK use a custom domain name; custom domains are not parsed by Cloud Tasks. If host is not parsable, then service, version, and instance are the empty string.
251 pub service: Option<String>,
252 /// App version. By default, the task is sent to the version which is the default version when the task is attempted. For some queues or tasks which were created using the App Engine Task Queue API, host is not parsable into service, version, and instance. For example, some tasks which were created using the App Engine SDK use a custom domain name; custom domains are not parsed by Cloud Tasks. If host is not parsable, then service, version, and instance are the empty string.
253 pub version: Option<String>,
254}
255
256impl common::Part for AppEngineRouting {}
257
258/// The status of a task attempt.
259///
260/// This type is not used in any activity, and only used as *part* of another schema.
261///
262#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
263#[serde_with::serde_as]
264#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
265pub struct AttemptStatus {
266 /// Output only. The time that this attempt was dispatched. `dispatch_time` will be truncated to the nearest microsecond.
267 #[serde(rename = "dispatchTime")]
268 pub dispatch_time: Option<chrono::DateTime<chrono::offset::Utc>>,
269 /// Output only. The response from the target for this attempt. If the task has not been attempted or the task is currently running then the response status is unset.
270 #[serde(rename = "responseStatus")]
271 pub response_status: Option<Status>,
272 /// Output only. The time that this attempt response was received. `response_time` will be truncated to the nearest microsecond.
273 #[serde(rename = "responseTime")]
274 pub response_time: Option<chrono::DateTime<chrono::offset::Utc>>,
275 /// Output only. The time that this attempt was scheduled. `schedule_time` will be truncated to the nearest microsecond.
276 #[serde(rename = "scheduleTime")]
277 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
278}
279
280impl common::Part for AttemptStatus {}
281
282/// Associates `members`, or principals, with a `role`.
283///
284/// This type is not used in any activity, and only used as *part* of another schema.
285///
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct Binding {
290 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
291 pub condition: Option<Expr>,
292 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
293 pub members: Option<Vec<String>>,
294 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
295 pub role: Option<String>,
296}
297
298impl common::Part for Binding {}
299
300/// Request message for BufferTask.
301///
302/// # Activities
303///
304/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
305/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
306///
307/// * [locations queues tasks buffer projects](ProjectLocationQueueTaskBufferCall) (request)
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct BufferTaskRequest {
312 /// Optional. Body of the HTTP request. The body can take any generic value. The value is written to the HttpRequest of the [Task].
313 pub body: Option<HttpBody>,
314}
315
316impl common::RequestValue for BufferTaskRequest {}
317
318/// Response message for BufferTask.
319///
320/// # Activities
321///
322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
324///
325/// * [locations queues tasks buffer projects](ProjectLocationQueueTaskBufferCall) (response)
326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
327#[serde_with::serde_as]
328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
329pub struct BufferTaskResponse {
330 /// The created task.
331 pub task: Option<Task>,
332}
333
334impl common::ResponseResult for BufferTaskResponse {}
335
336/// Request message for canceling a lease using CancelLease.
337///
338/// # Activities
339///
340/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
341/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
342///
343/// * [locations queues tasks cancel lease projects](ProjectLocationQueueTaskCancelLeaseCall) (request)
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct CancelLeaseRequest {
348 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
349 #[serde(rename = "responseView")]
350 pub response_view: Option<String>,
351 /// Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease.
352 #[serde(rename = "scheduleTime")]
353 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
354}
355
356impl common::RequestValue for CancelLeaseRequest {}
357
358/// Describes the customer-managed encryption key (CMEK) configuration associated with a project and location.
359///
360/// # Activities
361///
362/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
363/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
364///
365/// * [locations get cmek config projects](ProjectLocationGetCmekConfigCall) (response)
366/// * [locations update cmek config projects](ProjectLocationUpdateCmekConfigCall) (request|response)
367#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
368#[serde_with::serde_as]
369#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
370pub struct CmekConfig {
371 /// Resource name of the Cloud KMS key, of the form `projects/PROJECT_ID/locations/LOCATION_ID/keyRings/KEY_RING_ID/cryptoKeys/KEY_ID`, that will be used to encrypt the Queues & Tasks in the region. Setting this as blank will turn off CMEK encryption.
372 #[serde(rename = "kmsKey")]
373 pub kms_key: Option<String>,
374 /// Output only. The config resource name which includes the project and location and must end in 'cmekConfig', in the format projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig`
375 pub name: Option<String>,
376}
377
378impl common::RequestValue for CmekConfig {}
379impl common::ResponseResult for CmekConfig {}
380
381/// Request message for CreateTask.
382///
383/// # Activities
384///
385/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
386/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
387///
388/// * [locations queues tasks create projects](ProjectLocationQueueTaskCreateCall) (request)
389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
390#[serde_with::serde_as]
391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
392pub struct CreateTaskRequest {
393 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
394 #[serde(rename = "responseView")]
395 pub response_view: Option<String>,
396 /// Required. The task to add. Task names have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. The user can optionally specify a task name. If a name is not specified then the system will generate a random unique task id, which will be set in the task returned in the response. If schedule_time is not set or is in the past then Cloud Tasks will set it to the current time. Task De-duplication: Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or completed recently then the call will fail with ALREADY_EXISTS. The IDs of deleted tasks are not immediately available for reuse. It can take up to 24 hours (or 9 days if the task's queue was created using a queue.yaml or queue.xml) for the task ID to be released and made available again. Because there is an extra lookup cost to identify duplicate task names, these CreateTask calls have significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and serve tasks efficiently.
397 pub task: Option<Task>,
398}
399
400impl common::RequestValue for CreateTaskRequest {}
401
402/// 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); }
403///
404/// # Activities
405///
406/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
407/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
408///
409/// * [queue update api](ApiQueueUpdateCall) (response)
410/// * [locations queues tasks acknowledge projects](ProjectLocationQueueTaskAcknowledgeCall) (response)
411/// * [locations queues tasks delete projects](ProjectLocationQueueTaskDeleteCall) (response)
412/// * [locations queues delete projects](ProjectLocationQueueDeleteCall) (response)
413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
414#[serde_with::serde_as]
415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
416pub struct Empty {
417 _never_set: Option<bool>,
418}
419
420impl common::ResponseResult for Empty {}
421
422/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
423///
424/// This type is not used in any activity, and only used as *part* of another schema.
425///
426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
427#[serde_with::serde_as]
428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
429pub struct Expr {
430 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
431 pub description: Option<String>,
432 /// Textual representation of an expression in Common Expression Language syntax.
433 pub expression: Option<String>,
434 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
435 pub location: Option<String>,
436 /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
437 pub title: Option<String>,
438}
439
440impl common::Part for Expr {}
441
442/// Request message for `GetIamPolicy` method.
443///
444/// # Activities
445///
446/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
447/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
448///
449/// * [locations queues get iam policy projects](ProjectLocationQueueGetIamPolicyCall) (request)
450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
451#[serde_with::serde_as]
452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
453pub struct GetIamPolicyRequest {
454 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
455 pub options: Option<GetPolicyOptions>,
456}
457
458impl common::RequestValue for GetIamPolicyRequest {}
459
460/// Encapsulates settings provided to GetIamPolicy.
461///
462/// This type is not used in any activity, and only used as *part* of another schema.
463///
464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
465#[serde_with::serde_as]
466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
467pub struct GetPolicyOptions {
468 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
469 #[serde(rename = "requestedPolicyVersion")]
470 pub requested_policy_version: Option<i32>,
471}
472
473impl common::Part for GetPolicyOptions {}
474
475/// Defines a header message. A header can have a key and a value.
476///
477/// This type is not used in any activity, and only used as *part* of another schema.
478///
479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
480#[serde_with::serde_as]
481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
482pub struct Header {
483 /// The key of the header.
484 pub key: Option<String>,
485 /// The value of the header.
486 pub value: Option<String>,
487}
488
489impl common::Part for Header {}
490
491/// Wraps the Header object.
492///
493/// This type is not used in any activity, and only used as *part* of another schema.
494///
495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
496#[serde_with::serde_as]
497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
498pub struct HeaderOverride {
499 /// Header embodying a key and a value. Do not put business sensitive or personally identifying data in the HTTP Header Override Configuration or other similar fields in accordance with Section 12 (Resource Fields) of the [Service Specific Terms](https://cloud.google.com/terms/service-terms).
500 pub header: Option<Header>,
501}
502
503impl common::Part for HeaderOverride {}
504
505/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
506///
507/// # Activities
508///
509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
511///
512/// * [queue update api](ApiQueueUpdateCall) (request)
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct HttpBody {
517 /// The HTTP Content-Type header value specifying the content type of the body.
518 #[serde(rename = "contentType")]
519 pub content_type: Option<String>,
520 /// The HTTP request/response body as raw binary.
521 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
522 pub data: Option<Vec<u8>>,
523 /// Application specific response metadata. Must be set in the first response for streaming APIs.
524 pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
525}
526
527impl common::RequestValue for HttpBody {}
528
529/// HTTP request. The task will be pushed to the worker as an HTTP request. An HTTP request embodies a url, an http method, headers, body and authorization for the http task.
530///
531/// This type is not used in any activity, and only used as *part* of another schema.
532///
533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
534#[serde_with::serde_as]
535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
536pub struct HttpRequest {
537 /// 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 task with an incompatible HttpMethod.
538 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
539 pub body: Option<Vec<u8>>,
540 /// HTTP request headers. This map contains the header field names and values. Headers can be set when running the task is created or task is created. These headers represent a subset of the headers that will accompany the task's HTTP request. Some HTTP request headers will be ignored or replaced. A partial list of headers that will be ignored or replaced is: * Any header that is prefixed with "X-CloudTasks-" will be treated as service header. Service headers define properties of the task and are predefined in CloudTask. * Host: This will be computed by Cloud Tasks and derived from HttpRequest.url. * Content-Length: This will be computed by Cloud Tasks. * User-Agent: This will be set to `"Google-Cloud-Tasks"`. * `X-Google-*`: Google use only. * `X-AppEngine-*`: Google use only. `Content-Type` won't be set by Cloud Tasks. You can explicitly set `Content-Type` to a media type when the task is created. For example, `Content-Type` can be set to `"application/octet-stream"` or `"application/json"`. Headers which can have multiple values (according to RFC2616) can be specified using comma-separated values. The size of the headers must be less than 80KB.
541 pub headers: Option<HashMap<String, String>>,
542 /// The HTTP method to use for the request. The default is POST.
543 #[serde(rename = "httpMethod")]
544 pub http_method: Option<String>,
545 /// 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.
546 #[serde(rename = "oauthToken")]
547 pub oauth_token: Option<OAuthToken>,
548 /// 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.
549 #[serde(rename = "oidcToken")]
550 pub oidc_token: Option<OidcToken>,
551 /// Required. The full url path that the request will be sent to. This string must begin with either "http://" or "https://". Some examples are: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will encode some characters for safety and compatibility. The maximum allowed URL length is 2083 characters after encoding. The `Location` header response from a redirect response [`300` - `399`] may be followed. The redirect is not counted as a separate attempt.
552 pub url: Option<String>,
553}
554
555impl common::Part for HttpRequest {}
556
557/// HTTP target. When specified as a Queue, all the tasks with [HttpRequest] will be overridden according to the target.
558///
559/// This type is not used in any activity, and only used as *part* of another schema.
560///
561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
562#[serde_with::serde_as]
563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
564pub struct HttpTarget {
565 /// HTTP target headers. This map contains the header field names and values. Headers will be set when running the task is created and/or task is created. These headers represent a subset of the headers that will accompany the task's HTTP request. Some HTTP request headers will be ignored or replaced. A partial list of headers that will be ignored or replaced is: * Any header that is prefixed with "X-CloudTasks-" will be treated as service header. Service headers define properties of the task and are predefined in CloudTask. * Host: This will be computed by Cloud Tasks and derived from HttpRequest.url. * Content-Length: This will be computed by Cloud Tasks. * User-Agent: This will be set to `"Google-CloudTasks"`. * `X-Google-*`: Google use only. * `X-AppEngine-*`: Google use only. `Content-Type` won't be set by Cloud Tasks. You can explicitly set `Content-Type` to a media type when the task is created. For example, `Content-Type` can be set to `"application/octet-stream"` or `"application/json"`. Headers which can have multiple values (according to RFC2616) can be specified using comma-separated values. The size of the headers must be less than 80KB. Queue-level headers to override headers of all the tasks in the queue. Do not put business sensitive or personally identifying data in the HTTP Header Override Configuration or other similar fields in accordance with Section 12 (Resource Fields) of the [Service Specific Terms](https://cloud.google.com/terms/service-terms).
566 #[serde(rename = "headerOverrides")]
567 pub header_overrides: Option<Vec<HeaderOverride>>,
568 /// The HTTP method to use for the request. When specified, it overrides HttpRequest for the task. Note that if the value is set to HttpMethod the HttpRequest of the task will be ignored at execution time.
569 #[serde(rename = "httpMethod")]
570 pub http_method: Option<String>,
571 /// If specified, an [OAuth token](https://developers.google.com/identity/protocols/OAuth2) is generated and attached as an `Authorization` header in the HTTP request. This type of authorization should generally be used only when calling Google APIs hosted on *.googleapis.com. Note that both the service account email and the scope MUST be specified when using the queue-level authorization override.
572 #[serde(rename = "oauthToken")]
573 pub oauth_token: Option<OAuthToken>,
574 /// If specified, an [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) token is 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. Note that both the service account email and the audience MUST be specified when using the queue-level authorization override.
575 #[serde(rename = "oidcToken")]
576 pub oidc_token: Option<OidcToken>,
577 /// Uri override. When specified, overrides the execution Uri for all the tasks in the queue.
578 #[serde(rename = "uriOverride")]
579 pub uri_override: Option<UriOverride>,
580}
581
582impl common::Part for HttpTarget {}
583
584/// Request message for leasing tasks using LeaseTasks.
585///
586/// # Activities
587///
588/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
589/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
590///
591/// * [locations queues tasks lease projects](ProjectLocationQueueTaskLeaseCall) (request)
592#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
593#[serde_with::serde_as]
594#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
595pub struct LeaseTasksRequest {
596 /// `filter` can be used to specify a subset of tasks to lease. When `filter` is set to `tag=` then the response will contain only tasks whose tag is equal to ``. `` must be less than 500 characters. When `filter` is set to `tag_function=oldest_tag()`, only tasks which have the same tag as the task with the oldest schedule_time will be returned. Grammar Syntax: * `filter = "tag=" tag | "tag_function=" function` * `tag = string` * `function = "oldest_tag()"` The `oldest_tag()` function returns tasks which have the same tag as the oldest task (ordered by schedule time). SDK compatibility: Although the SDK allows tags to be either string or [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-), only UTF-8 encoded tags can be used in Cloud Tasks. Tag which aren't UTF-8 encoded can't be used in the filter and the task's tag will be displayed as empty in Cloud Tasks.
597 pub filter: Option<String>,
598 /// Required. The duration of the lease. Each task returned in the response will have its schedule_time set to the current time plus the `lease_duration`. The task is leased until its schedule_time; thus, the task will not be returned to another LeaseTasks call before its schedule_time. After the worker has successfully finished the work associated with the task, the worker must call via AcknowledgeTask before the schedule_time. Otherwise the task will be returned to a later LeaseTasks call so that another worker can retry it. The maximum lease duration is 1 week. `lease_duration` will be truncated to the nearest second.
599 #[serde(rename = "leaseDuration")]
600 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
601 pub lease_duration: Option<chrono::Duration>,
602 /// The maximum number of tasks to lease. The system will make a best effort to return as close to as `max_tasks` as possible. The largest that `max_tasks` can be is 1000. The maximum total size of a lease tasks response is 32 MB. If the sum of all task sizes requested reaches this limit, fewer tasks than requested are returned.
603 #[serde(rename = "maxTasks")]
604 pub max_tasks: Option<i32>,
605 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
606 #[serde(rename = "responseView")]
607 pub response_view: Option<String>,
608}
609
610impl common::RequestValue for LeaseTasksRequest {}
611
612/// Response message for leasing tasks using LeaseTasks.
613///
614/// # Activities
615///
616/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
617/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
618///
619/// * [locations queues tasks lease projects](ProjectLocationQueueTaskLeaseCall) (response)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct LeaseTasksResponse {
624 /// The leased tasks.
625 pub tasks: Option<Vec<Task>>,
626}
627
628impl common::ResponseResult for LeaseTasksResponse {}
629
630/// The response message for Locations.ListLocations.
631///
632/// # Activities
633///
634/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
635/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
636///
637/// * [locations list projects](ProjectLocationListCall) (response)
638#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
639#[serde_with::serde_as]
640#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
641pub struct ListLocationsResponse {
642 /// A list of locations that matches the specified filter in the request.
643 pub locations: Option<Vec<Location>>,
644 /// The standard List next-page token.
645 #[serde(rename = "nextPageToken")]
646 pub next_page_token: Option<String>,
647}
648
649impl common::ResponseResult for ListLocationsResponse {}
650
651/// Response message for ListQueues.
652///
653/// # Activities
654///
655/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
656/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
657///
658/// * [locations queues list projects](ProjectLocationQueueListCall) (response)
659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
660#[serde_with::serde_as]
661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
662pub struct ListQueuesResponse {
663 /// A token to retrieve next page of results. To return the next page of results, call ListQueues with this value as the page_token. If the next_page_token is empty, there are no more results. The page token is valid for only 2 hours.
664 #[serde(rename = "nextPageToken")]
665 pub next_page_token: Option<String>,
666 /// The list of queues.
667 pub queues: Option<Vec<Queue>>,
668}
669
670impl common::ResponseResult for ListQueuesResponse {}
671
672/// Response message for listing tasks using ListTasks.
673///
674/// # Activities
675///
676/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
677/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
678///
679/// * [locations queues tasks list projects](ProjectLocationQueueTaskListCall) (response)
680#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
681#[serde_with::serde_as]
682#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
683pub struct ListTasksResponse {
684 /// A token to retrieve next page of results. To return the next page of results, call ListTasks with this value as the page_token. If the next_page_token is empty, there are no more results.
685 #[serde(rename = "nextPageToken")]
686 pub next_page_token: Option<String>,
687 /// The list of tasks.
688 pub tasks: Option<Vec<Task>>,
689}
690
691impl common::ResponseResult for ListTasksResponse {}
692
693/// A resource that represents a Google Cloud location.
694///
695/// # Activities
696///
697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
699///
700/// * [locations get projects](ProjectLocationGetCall) (response)
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct Location {
705 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
706 #[serde(rename = "displayName")]
707 pub display_name: Option<String>,
708 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
709 pub labels: Option<HashMap<String, String>>,
710 /// The canonical id for this location. For example: `"us-east1"`.
711 #[serde(rename = "locationId")]
712 pub location_id: Option<String>,
713 /// Service-specific metadata. For example the available capacity at the given location.
714 pub metadata: Option<HashMap<String, serde_json::Value>>,
715 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
716 pub name: Option<String>,
717}
718
719impl common::ResponseResult for Location {}
720
721/// 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.
722///
723/// This type is not used in any activity, and only used as *part* of another schema.
724///
725#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
726#[serde_with::serde_as]
727#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
728pub struct OAuthToken {
729 /// OAuth scope to be used for generating OAuth access token. If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used.
730 pub scope: Option<String>,
731 /// [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 queue. The caller must have iam.serviceAccounts.actAs permission for the service account.
732 #[serde(rename = "serviceAccountEmail")]
733 pub service_account_email: Option<String>,
734}
735
736impl common::Part for OAuthToken {}
737
738/// 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.
739///
740/// This type is not used in any activity, and only used as *part* of another schema.
741///
742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
743#[serde_with::serde_as]
744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
745pub struct OidcToken {
746 /// Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used.
747 pub audience: Option<String>,
748 /// [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 queue. The caller must have iam.serviceAccounts.actAs permission for the service account.
749 #[serde(rename = "serviceAccountEmail")]
750 pub service_account_email: Option<String>,
751}
752
753impl common::Part for OidcToken {}
754
755/// PathOverride. Path message defines path override for HTTP targets.
756///
757/// This type is not used in any activity, and only used as *part* of another schema.
758///
759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
760#[serde_with::serde_as]
761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
762pub struct PathOverride {
763 /// The URI path (e.g., /users/1234). Default is an empty string.
764 pub path: Option<String>,
765}
766
767impl common::Part for PathOverride {}
768
769/// Request message for PauseQueue.
770///
771/// # Activities
772///
773/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
774/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
775///
776/// * [locations queues pause projects](ProjectLocationQueuePauseCall) (request)
777#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
778#[serde_with::serde_as]
779#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
780pub struct PauseQueueRequest {
781 _never_set: Option<bool>,
782}
783
784impl common::RequestValue for PauseQueueRequest {}
785
786/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
787///
788/// # Activities
789///
790/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
791/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
792///
793/// * [locations queues get iam policy projects](ProjectLocationQueueGetIamPolicyCall) (response)
794/// * [locations queues set iam policy projects](ProjectLocationQueueSetIamPolicyCall) (response)
795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
796#[serde_with::serde_as]
797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
798pub struct Policy {
799 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
800 pub bindings: Option<Vec<Binding>>,
801 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
802 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
803 pub etag: Option<Vec<u8>>,
804 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
805 pub version: Option<i32>,
806}
807
808impl common::ResponseResult for Policy {}
809
810/// The pull message contains data that can be used by the caller of LeaseTasks to process the task. This proto can only be used for tasks in a queue which has pull_target set.
811///
812/// This type is not used in any activity, and only used as *part* of another schema.
813///
814#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
815#[serde_with::serde_as]
816#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
817pub struct PullMessage {
818 /// A data payload consumed by the worker to execute the task.
819 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
820 pub payload: Option<Vec<u8>>,
821 /// The task's tag. Tags allow similar tasks to be processed in a batch. If you label tasks with a tag, your worker can lease tasks with the same tag using filter. For example, if you want to aggregate the events associated with a specific user once a day, you could tag tasks with the user ID. The task's tag can only be set when the task is created. The tag must be less than 500 characters. SDK compatibility: Although the SDK allows tags to be either string or [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-), only UTF-8 encoded tags can be used in Cloud Tasks. If a tag isn't UTF-8 encoded, the tag will be empty when the task is returned by Cloud Tasks.
822 pub tag: Option<String>,
823}
824
825impl common::Part for PullMessage {}
826
827/// Pull target.
828///
829/// This type is not used in any activity, and only used as *part* of another schema.
830///
831#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
832#[serde_with::serde_as]
833#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
834pub struct PullTarget {
835 _never_set: Option<bool>,
836}
837
838impl common::Part for PullTarget {}
839
840/// Request message for PurgeQueue.
841///
842/// # Activities
843///
844/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
845/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
846///
847/// * [locations queues purge projects](ProjectLocationQueuePurgeCall) (request)
848#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
849#[serde_with::serde_as]
850#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
851pub struct PurgeQueueRequest {
852 _never_set: Option<bool>,
853}
854
855impl common::RequestValue for PurgeQueueRequest {}
856
857/// QueryOverride. Query message defines query override for HTTP targets.
858///
859/// This type is not used in any activity, and only used as *part* of another schema.
860///
861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
862#[serde_with::serde_as]
863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
864pub struct QueryOverride {
865 /// The query parameters (e.g., qparam1=123&qparam2=456). Default is an empty string.
866 #[serde(rename = "queryParams")]
867 pub query_params: Option<String>,
868}
869
870impl common::Part for QueryOverride {}
871
872/// A queue is a container of related tasks. Queues are configured to manage how those tasks are dispatched. Configurable properties include rate limits, retry options, target types, and others.
873///
874/// # Activities
875///
876/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
877/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
878///
879/// * [locations queues create projects](ProjectLocationQueueCreateCall) (request|response)
880/// * [locations queues get projects](ProjectLocationQueueGetCall) (response)
881/// * [locations queues patch projects](ProjectLocationQueuePatchCall) (request|response)
882/// * [locations queues pause projects](ProjectLocationQueuePauseCall) (response)
883/// * [locations queues purge projects](ProjectLocationQueuePurgeCall) (response)
884/// * [locations queues resume projects](ProjectLocationQueueResumeCall) (response)
885#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
886#[serde_with::serde_as]
887#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
888pub struct Queue {
889 /// App Engine HTTP target. An App Engine queue is a queue that has an AppEngineHttpTarget.
890 #[serde(rename = "appEngineHttpTarget")]
891 pub app_engine_http_target: Option<AppEngineHttpTarget>,
892 /// An http_target is used to override the target values for HTTP tasks.
893 #[serde(rename = "httpTarget")]
894 pub http_target: Option<HttpTarget>,
895 /// Caller-specified and required in CreateQueue, after which it becomes output only. The queue name. The queue name must have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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 queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters.
896 pub name: Option<String>,
897 /// Pull target. A pull queue is a queue that has a PullTarget.
898 #[serde(rename = "pullTarget")]
899 pub pull_target: Option<PullTarget>,
900 /// Output only. The last time this queue was purged. All tasks that were created before this time were purged. A queue can be purged using PurgeQueue, the [App Engine Task Queue SDK, or the Cloud Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue). Purge time will be truncated to the nearest microsecond. Purge time will be unset if the queue has never been purged.
901 #[serde(rename = "purgeTime")]
902 pub purge_time: Option<chrono::DateTime<chrono::offset::Utc>>,
903 /// Rate limits for task dispatches. rate_limits and retry_config are related because they both control task attempts however they control how tasks are attempted in different ways: * rate_limits controls the total rate of dispatches from a queue (i.e. all traffic dispatched from the queue, regardless of whether the dispatch is from a first attempt or a retry). * retry_config controls what happens to particular a task after its first attempt fails. That is, retry_config controls task retries (the second attempt, third attempt, etc).
904 #[serde(rename = "rateLimits")]
905 pub rate_limits: Option<RateLimits>,
906 /// Settings that determine the retry behavior. * For tasks created using Cloud Tasks: the queue-level retry settings apply to all tasks in the queue that were created using Cloud Tasks. Retry settings cannot be set on individual tasks. * For tasks created using the App Engine SDK: the queue-level retry settings apply to all tasks in the queue which do not have retry settings explicitly set on the task and were created by the App Engine SDK. See [App Engine documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).
907 #[serde(rename = "retryConfig")]
908 pub retry_config: Option<RetryConfig>,
909 /// Output only. The state of the queue. `state` can only be changed by called PauseQueue, ResumeQueue, or uploading [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref). UpdateQueue cannot be used to change `state`.
910 pub state: Option<String>,
911 /// Output only. The realtime, informational statistics for a queue. In order to receive the statistics the caller should include this field in the FieldMask.
912 pub stats: Option<QueueStats>,
913 /// The maximum amount of time that a task will be retained in this queue. Queues created by Cloud Tasks have a default `task_ttl` of 31 days. After a task has lived for `task_ttl`, the task will be deleted regardless of whether it was dispatched or not. The `task_ttl` for queues created via queue.yaml/xml is equal to the maximum duration because there is a [storage quota](https://cloud.google.com/appengine/quotas#Task_Queue) for these queues. To view the maximum valid duration, see the documentation for Duration.
914 #[serde(rename = "taskTtl")]
915 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
916 pub task_ttl: Option<chrono::Duration>,
917 /// The task tombstone time to live (TTL). After a task is deleted or completed, the task's tombstone is retained for the length of time specified by `tombstone_ttl`. The tombstone is used by task de-duplication; another task with the same name can't be created until the tombstone has expired. For more information about task de-duplication, see the documentation for CreateTaskRequest. Queues created by Cloud Tasks have a default `tombstone_ttl` of 1 hour.
918 #[serde(rename = "tombstoneTtl")]
919 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
920 pub tombstone_ttl: Option<chrono::Duration>,
921}
922
923impl common::RequestValue for Queue {}
924impl common::ResponseResult for Queue {}
925
926/// Statistics for a queue.
927///
928/// This type is not used in any activity, and only used as *part* of another schema.
929///
930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
931#[serde_with::serde_as]
932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
933pub struct QueueStats {
934 /// Output only. The number of requests that the queue has dispatched but has not received a reply for yet.
935 #[serde(rename = "concurrentDispatchesCount")]
936 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
937 pub concurrent_dispatches_count: Option<i64>,
938 /// Output only. The current maximum number of tasks per second executed by the queue. The maximum value of this variable is controlled by the RateLimits of the Queue. However, this value could be less to avoid overloading the endpoints tasks in the queue are targeting.
939 #[serde(rename = "effectiveExecutionRate")]
940 pub effective_execution_rate: Option<f64>,
941 /// Output only. The number of tasks that the queue has dispatched and received a reply for during the last minute. This variable counts both successful and non-successful executions.
942 #[serde(rename = "executedLastMinuteCount")]
943 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
944 pub executed_last_minute_count: Option<i64>,
945 /// Output only. An estimation of the nearest time in the future where a task in the queue is scheduled to be executed.
946 #[serde(rename = "oldestEstimatedArrivalTime")]
947 pub oldest_estimated_arrival_time: Option<chrono::DateTime<chrono::offset::Utc>>,
948 /// Output only. An estimation of the number of tasks in the queue, that is, the tasks in the queue that haven't been executed, the tasks in the queue which the queue has dispatched but has not yet received a reply for, and the failed tasks that the queue is retrying.
949 #[serde(rename = "tasksCount")]
950 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
951 pub tasks_count: Option<i64>,
952}
953
954impl common::Part for QueueStats {}
955
956/// Rate limits. This message determines the maximum rate that tasks can be dispatched by a queue, regardless of whether the dispatch is a first task attempt or a retry. Note: The debugging command, RunTask, will run a task even if the queue has reached its RateLimits.
957///
958/// This type is not used in any activity, and only used as *part* of another schema.
959///
960#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
961#[serde_with::serde_as]
962#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
963pub struct RateLimits {
964 /// The max burst size. Max burst size limits how fast tasks in queue are processed when many tasks are in the queue and the rate is high. This field allows the queue to have a high rate so processing starts shortly after a task is enqueued, but still limits resource usage when many tasks are enqueued in a short period of time. The [token bucket](https://wikipedia.org/wiki/Token_Bucket) algorithm is used to control the rate of task dispatches. Each queue has a token bucket that holds tokens, up to the maximum specified by `max_burst_size`. Each time a task is dispatched, a token is removed from the bucket. Tasks will be dispatched until the queue's bucket runs out of tokens. The bucket will be continuously refilled with new tokens based on max_dispatches_per_second. The default value of `max_burst_size` is picked by Cloud Tasks based on the value of max_dispatches_per_second. The maximum value of `max_burst_size` is 500. For App Engine queues that were created or updated using `queue.yaml/xml`, `max_burst_size` is equal to [bucket_size](https://cloud.google.com/appengine/docs/standard/python/config/queueref#bucket_size). If UpdateQueue is called on a queue without explicitly setting a value for `max_burst_size`, `max_burst_size` value will get updated if UpdateQueue is updating max_dispatches_per_second.
965 #[serde(rename = "maxBurstSize")]
966 pub max_burst_size: Option<i32>,
967 /// The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched for this queue. After this threshold has been reached, Cloud Tasks stops dispatching tasks until the number of concurrent requests decreases. If unspecified when the queue is created, Cloud Tasks will pick the default. The maximum allowed value is 5,000. This field is output only for pull queues and always -1, which indicates no limit. No other queue types can have `max_concurrent_tasks` set to -1. This field has the same meaning as [max_concurrent_requests in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#max_concurrent_requests).
968 #[serde(rename = "maxConcurrentTasks")]
969 pub max_concurrent_tasks: Option<i32>,
970 /// The maximum rate at which tasks are dispatched from this queue. If unspecified when the queue is created, Cloud Tasks will pick the default. * For App Engine queues, the maximum allowed value is 500. * This field is output only for pull queues. In addition to the `max_tasks_dispatched_per_second` limit, a maximum of 10 QPS of LeaseTasks requests are allowed per pull queue. This field has the same meaning as [rate in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate).
971 #[serde(rename = "maxTasksDispatchedPerSecond")]
972 pub max_tasks_dispatched_per_second: Option<f64>,
973}
974
975impl common::Part for RateLimits {}
976
977/// Request message for renewing a lease using RenewLease.
978///
979/// # Activities
980///
981/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
982/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
983///
984/// * [locations queues tasks renew lease projects](ProjectLocationQueueTaskRenewLeaseCall) (request)
985#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
986#[serde_with::serde_as]
987#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
988pub struct RenewLeaseRequest {
989 /// Required. The desired new lease duration, starting from now. The maximum lease duration is 1 week. `lease_duration` will be truncated to the nearest second.
990 #[serde(rename = "leaseDuration")]
991 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
992 pub lease_duration: Option<chrono::Duration>,
993 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
994 #[serde(rename = "responseView")]
995 pub response_view: Option<String>,
996 /// Required. The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease.
997 #[serde(rename = "scheduleTime")]
998 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
999}
1000
1001impl common::RequestValue for RenewLeaseRequest {}
1002
1003/// Request message for ResumeQueue.
1004///
1005/// # Activities
1006///
1007/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1008/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1009///
1010/// * [locations queues resume projects](ProjectLocationQueueResumeCall) (request)
1011#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1012#[serde_with::serde_as]
1013#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1014pub struct ResumeQueueRequest {
1015 _never_set: Option<bool>,
1016}
1017
1018impl common::RequestValue for ResumeQueueRequest {}
1019
1020/// Retry config. These settings determine how a failed task attempt is retried.
1021///
1022/// This type is not used in any activity, and only used as *part* of another schema.
1023///
1024#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1025#[serde_with::serde_as]
1026#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1027pub struct RetryConfig {
1028 /// The maximum number of attempts for a task. Cloud Tasks will attempt the task `max_attempts` times (that is, if the first attempt fails, then there will be `max_attempts - 1` retries). Must be > 0.
1029 #[serde(rename = "maxAttempts")]
1030 pub max_attempts: Option<i32>,
1031 /// A task will be scheduled for retry between min_backoff and max_backoff duration after it fails, if the queue's RetryConfig specifies that the task should be retried. If unspecified when the queue is created, Cloud Tasks will pick the default. This field is output only for pull queues. `max_backoff` will be truncated to the nearest second. This field has the same meaning as [max_backoff_seconds in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1032 #[serde(rename = "maxBackoff")]
1033 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1034 pub max_backoff: Option<chrono::Duration>,
1035 /// The time between retries will double `max_doublings` times. A task's retry interval starts at min_backoff, then doubles `max_doublings` times, then increases linearly, and finally retries at intervals of max_backoff up to max_attempts times. For example, if min_backoff is 10s, max_backoff is 300s, and `max_doublings` is 3, then the a task will first be retried in 10s. The retry interval will double three times, and then increase linearly by 2^3 * 10s. Finally, the task will retry at intervals of max_backoff until the task has been attempted max_attempts times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, .... If unspecified when the queue is created, Cloud Tasks will pick the default. This field is output only for pull queues. This field has the same meaning as [max_doublings in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1036 #[serde(rename = "maxDoublings")]
1037 pub max_doublings: Option<i32>,
1038 /// If positive, `max_retry_duration` specifies the time limit for retrying a failed task, measured from when the task was first attempted. Once `max_retry_duration` time has passed *and* the task has been attempted max_attempts times, no further attempts will be made and the task will be deleted. If zero, then the task age is unlimited. If unspecified when the queue is created, Cloud Tasks will pick the default. This field is output only for pull queues. `max_retry_duration` will be truncated to the nearest second. This field has the same meaning as [task_age_limit in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1039 #[serde(rename = "maxRetryDuration")]
1040 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1041 pub max_retry_duration: Option<chrono::Duration>,
1042 /// A task will be scheduled for retry between min_backoff and max_backoff duration after it fails, if the queue's RetryConfig specifies that the task should be retried. If unspecified when the queue is created, Cloud Tasks will pick the default. This field is output only for pull queues. `min_backoff` will be truncated to the nearest second. This field has the same meaning as [min_backoff_seconds in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1043 #[serde(rename = "minBackoff")]
1044 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1045 pub min_backoff: Option<chrono::Duration>,
1046 /// If true, then the number of attempts is unlimited.
1047 #[serde(rename = "unlimitedAttempts")]
1048 pub unlimited_attempts: Option<bool>,
1049}
1050
1051impl common::Part for RetryConfig {}
1052
1053/// Request message for forcing a task to run now using RunTask.
1054///
1055/// # Activities
1056///
1057/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1058/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1059///
1060/// * [locations queues tasks run projects](ProjectLocationQueueTaskRunCall) (request)
1061#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1062#[serde_with::serde_as]
1063#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1064pub struct RunTaskRequest {
1065 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
1066 #[serde(rename = "responseView")]
1067 pub response_view: Option<String>,
1068}
1069
1070impl common::RequestValue for RunTaskRequest {}
1071
1072/// Request message for `SetIamPolicy` method.
1073///
1074/// # Activities
1075///
1076/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1077/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1078///
1079/// * [locations queues set iam policy projects](ProjectLocationQueueSetIamPolicyCall) (request)
1080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1081#[serde_with::serde_as]
1082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1083pub struct SetIamPolicyRequest {
1084 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
1085 pub policy: Option<Policy>,
1086}
1087
1088impl common::RequestValue for SetIamPolicyRequest {}
1089
1090/// 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).
1091///
1092/// This type is not used in any activity, and only used as *part* of another schema.
1093///
1094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1095#[serde_with::serde_as]
1096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1097pub struct Status {
1098 /// The status code, which should be an enum value of google.rpc.Code.
1099 pub code: Option<i32>,
1100 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1101 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1102 /// 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.
1103 pub message: Option<String>,
1104}
1105
1106impl common::Part for Status {}
1107
1108/// A unit of scheduled work.
1109///
1110/// # Activities
1111///
1112/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1113/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1114///
1115/// * [locations queues tasks cancel lease projects](ProjectLocationQueueTaskCancelLeaseCall) (response)
1116/// * [locations queues tasks create projects](ProjectLocationQueueTaskCreateCall) (response)
1117/// * [locations queues tasks get projects](ProjectLocationQueueTaskGetCall) (response)
1118/// * [locations queues tasks renew lease projects](ProjectLocationQueueTaskRenewLeaseCall) (response)
1119/// * [locations queues tasks run projects](ProjectLocationQueueTaskRunCall) (response)
1120#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1121#[serde_with::serde_as]
1122#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1123pub struct Task {
1124 /// App Engine HTTP request that is sent to the task's target. Can be set only if app_engine_http_target is set on the queue. An App Engine task is a task that has AppEngineHttpRequest set.
1125 #[serde(rename = "appEngineHttpRequest")]
1126 pub app_engine_http_request: Option<AppEngineHttpRequest>,
1127 /// Output only. The time that the task was created. `create_time` will be truncated to the nearest second.
1128 #[serde(rename = "createTime")]
1129 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1130 /// HTTP request that is sent to the task's target. An HTTP task is a task that has HttpRequest set.
1131 #[serde(rename = "httpRequest")]
1132 pub http_request: Option<HttpRequest>,
1133 /// Optionally caller-specified in CreateTask. The task name. The task name must have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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 task's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters. * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), hyphens (-), or underscores (_). The maximum length is 500 characters.
1134 pub name: Option<String>,
1135 /// LeaseTasks to process the task. Can be set only if pull_target is set on the queue. A pull task is a task that has PullMessage set.
1136 #[serde(rename = "pullMessage")]
1137 pub pull_message: Option<PullMessage>,
1138 /// The time when the task is scheduled to be attempted. For App Engine queues, this is when the task will be attempted or retried. For pull queues, this is the time when the task is available to be leased; if a task is currently leased, this is the time when the current lease expires, that is, the time that the task was leased plus the lease_duration. `schedule_time` will be truncated to the nearest microsecond.
1139 #[serde(rename = "scheduleTime")]
1140 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1141 /// Output only. The task status.
1142 pub status: Option<TaskStatus>,
1143 /// Output only. The view specifies which subset of the Task has been returned.
1144 pub view: Option<String>,
1145}
1146
1147impl common::ResponseResult for Task {}
1148
1149/// Status of the task.
1150///
1151/// This type is not used in any activity, and only used as *part* of another schema.
1152///
1153#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1154#[serde_with::serde_as]
1155#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1156pub struct TaskStatus {
1157 /// Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response.
1158 #[serde(rename = "attemptDispatchCount")]
1159 pub attempt_dispatch_count: Option<i32>,
1160 /// Output only. The number of attempts which have received a response. This field is not calculated for pull tasks.
1161 #[serde(rename = "attemptResponseCount")]
1162 pub attempt_response_count: Option<i32>,
1163 /// Output only. The status of the task's first attempt. Only dispatch_time will be set. The other AttemptStatus information is not retained by Cloud Tasks. This field is not calculated for pull tasks.
1164 #[serde(rename = "firstAttemptStatus")]
1165 pub first_attempt_status: Option<AttemptStatus>,
1166 /// Output only. The status of the task's last attempt. This field is not calculated for pull tasks.
1167 #[serde(rename = "lastAttemptStatus")]
1168 pub last_attempt_status: Option<AttemptStatus>,
1169}
1170
1171impl common::Part for TaskStatus {}
1172
1173/// Request message for `TestIamPermissions` method.
1174///
1175/// # Activities
1176///
1177/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1178/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1179///
1180/// * [locations queues test iam permissions projects](ProjectLocationQueueTestIamPermissionCall) (request)
1181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1182#[serde_with::serde_as]
1183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1184pub struct TestIamPermissionsRequest {
1185 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1186 pub permissions: Option<Vec<String>>,
1187}
1188
1189impl common::RequestValue for TestIamPermissionsRequest {}
1190
1191/// Response message for `TestIamPermissions` method.
1192///
1193/// # Activities
1194///
1195/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1196/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1197///
1198/// * [locations queues test iam permissions projects](ProjectLocationQueueTestIamPermissionCall) (response)
1199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1200#[serde_with::serde_as]
1201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1202pub struct TestIamPermissionsResponse {
1203 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1204 pub permissions: Option<Vec<String>>,
1205}
1206
1207impl common::ResponseResult for TestIamPermissionsResponse {}
1208
1209/// Uri Override. When specified, all the HTTP tasks inside the queue will be partially or fully overridden depending on the configured values.
1210///
1211/// This type is not used in any activity, and only used as *part* of another schema.
1212///
1213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1214#[serde_with::serde_as]
1215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1216pub struct UriOverride {
1217 /// Host override. When specified, replaces the host part of the task URL. For example, if the task URL is "https://www.google.com," and host value is set to "example.net", the overridden URI will be changed to "https://example.net." Host value cannot be an empty string (INVALID_ARGUMENT).
1218 pub host: Option<String>,
1219 /// URI path. When specified, replaces the existing path of the task URL. Setting the path value to an empty string clears the URI path segment.
1220 #[serde(rename = "pathOverride")]
1221 pub path_override: Option<PathOverride>,
1222 /// Port override. When specified, replaces the port part of the task URI. For instance, for a URI "https://www.example.com/example" and port=123, the overridden URI becomes "https://www.example.com:123/example". Note that the port value must be a positive integer. Setting the port to 0 (Zero) clears the URI port.
1223 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1224 pub port: Option<i64>,
1225 /// URI Query. When specified, replaces the query part of the task URI. Setting the query value to an empty string clears the URI query segment.
1226 #[serde(rename = "queryOverride")]
1227 pub query_override: Option<QueryOverride>,
1228 /// Scheme override. When specified, the task URI scheme is replaced by the provided value (HTTP or HTTPS).
1229 pub scheme: Option<String>,
1230 /// URI Override Enforce Mode When specified, determines the Target UriOverride mode. If not specified, it defaults to ALWAYS.
1231 #[serde(rename = "uriOverrideEnforceMode")]
1232 pub uri_override_enforce_mode: Option<String>,
1233}
1234
1235impl common::Part for UriOverride {}
1236
1237// ###################
1238// MethodBuilders ###
1239// #################
1240
1241/// A builder providing access to all methods supported on *api* resources.
1242/// It is not used directly, but through the [`CloudTasks`] hub.
1243///
1244/// # Example
1245///
1246/// Instantiate a resource builder
1247///
1248/// ```test_harness,no_run
1249/// extern crate hyper;
1250/// extern crate hyper_rustls;
1251/// extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
1252///
1253/// # async fn dox() {
1254/// use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1255///
1256/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1257/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1258/// .with_native_roots()
1259/// .unwrap()
1260/// .https_only()
1261/// .enable_http2()
1262/// .build();
1263///
1264/// let executor = hyper_util::rt::TokioExecutor::new();
1265/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1266/// secret,
1267/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1268/// yup_oauth2::client::CustomHyperClientBuilder::from(
1269/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1270/// ),
1271/// ).build().await.unwrap();
1272///
1273/// let client = hyper_util::client::legacy::Client::builder(
1274/// hyper_util::rt::TokioExecutor::new()
1275/// )
1276/// .build(
1277/// hyper_rustls::HttpsConnectorBuilder::new()
1278/// .with_native_roots()
1279/// .unwrap()
1280/// .https_or_http()
1281/// .enable_http2()
1282/// .build()
1283/// );
1284/// let mut hub = CloudTasks::new(client, auth);
1285/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1286/// // like `queue_update(...)`
1287/// // to build up your call.
1288/// let rb = hub.api();
1289/// # }
1290/// ```
1291pub struct ApiMethods<'a, C>
1292where
1293 C: 'a,
1294{
1295 hub: &'a CloudTasks<C>,
1296}
1297
1298impl<'a, C> common::MethodsBuilder for ApiMethods<'a, C> {}
1299
1300impl<'a, C> ApiMethods<'a, C> {
1301 /// Create a builder to help you perform the following task:
1302 ///
1303 /// Update queue list by uploading a queue.yaml file. The queue.yaml file is supplied in the request body as a YAML encoded string. This method was added to support gcloud clients versions before 322.0.0. New clients should use CreateQueue instead of this method.
1304 ///
1305 /// # Arguments
1306 ///
1307 /// * `request` - No description provided.
1308 pub fn queue_update(&self, request: HttpBody) -> ApiQueueUpdateCall<'a, C> {
1309 ApiQueueUpdateCall {
1310 hub: self.hub,
1311 _request: request,
1312 _app_id: Default::default(),
1313 _delegate: Default::default(),
1314 _additional_params: Default::default(),
1315 _scopes: Default::default(),
1316 }
1317 }
1318}
1319
1320/// A builder providing access to all methods supported on *project* resources.
1321/// It is not used directly, but through the [`CloudTasks`] hub.
1322///
1323/// # Example
1324///
1325/// Instantiate a resource builder
1326///
1327/// ```test_harness,no_run
1328/// extern crate hyper;
1329/// extern crate hyper_rustls;
1330/// extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
1331///
1332/// # async fn dox() {
1333/// use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1334///
1335/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1336/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1337/// .with_native_roots()
1338/// .unwrap()
1339/// .https_only()
1340/// .enable_http2()
1341/// .build();
1342///
1343/// let executor = hyper_util::rt::TokioExecutor::new();
1344/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1345/// secret,
1346/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1347/// yup_oauth2::client::CustomHyperClientBuilder::from(
1348/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1349/// ),
1350/// ).build().await.unwrap();
1351///
1352/// let client = hyper_util::client::legacy::Client::builder(
1353/// hyper_util::rt::TokioExecutor::new()
1354/// )
1355/// .build(
1356/// hyper_rustls::HttpsConnectorBuilder::new()
1357/// .with_native_roots()
1358/// .unwrap()
1359/// .https_or_http()
1360/// .enable_http2()
1361/// .build()
1362/// );
1363/// let mut hub = CloudTasks::new(client, auth);
1364/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1365/// // like `locations_get(...)`, `locations_get_cmek_config(...)`, `locations_list(...)`, `locations_queues_create(...)`, `locations_queues_delete(...)`, `locations_queues_get(...)`, `locations_queues_get_iam_policy(...)`, `locations_queues_list(...)`, `locations_queues_patch(...)`, `locations_queues_pause(...)`, `locations_queues_purge(...)`, `locations_queues_resume(...)`, `locations_queues_set_iam_policy(...)`, `locations_queues_tasks_acknowledge(...)`, `locations_queues_tasks_buffer(...)`, `locations_queues_tasks_cancel_lease(...)`, `locations_queues_tasks_create(...)`, `locations_queues_tasks_delete(...)`, `locations_queues_tasks_get(...)`, `locations_queues_tasks_lease(...)`, `locations_queues_tasks_list(...)`, `locations_queues_tasks_renew_lease(...)`, `locations_queues_tasks_run(...)`, `locations_queues_test_iam_permissions(...)` and `locations_update_cmek_config(...)`
1366/// // to build up your call.
1367/// let rb = hub.projects();
1368/// # }
1369/// ```
1370pub struct ProjectMethods<'a, C>
1371where
1372 C: 'a,
1373{
1374 hub: &'a CloudTasks<C>,
1375}
1376
1377impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1378
1379impl<'a, C> ProjectMethods<'a, C> {
1380 /// Create a builder to help you perform the following task:
1381 ///
1382 /// Acknowledges a pull task. The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished. The worker must acknowledge a task within the lease_duration or the lease will expire and the task will become available to be leased again. After the task is acknowledged, it will not be returned by a later LeaseTasks, GetTask, or ListTasks.
1383 ///
1384 /// # Arguments
1385 ///
1386 /// * `request` - No description provided.
1387 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1388 pub fn locations_queues_tasks_acknowledge(
1389 &self,
1390 request: AcknowledgeTaskRequest,
1391 name: &str,
1392 ) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
1393 ProjectLocationQueueTaskAcknowledgeCall {
1394 hub: self.hub,
1395 _request: request,
1396 _name: name.to_string(),
1397 _delegate: Default::default(),
1398 _additional_params: Default::default(),
1399 _scopes: Default::default(),
1400 }
1401 }
1402
1403 /// Create a builder to help you perform the following task:
1404 ///
1405 /// Creates and buffers a new task without the need to explicitly define a Task message. The queue must have HTTP target. To create the task with a custom ID, use the following format and set TASK_ID to your desired ID: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer To create the task with an automatically generated ID, use the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer.
1406 ///
1407 /// # Arguments
1408 ///
1409 /// * `request` - No description provided.
1410 /// * `queue` - Required. The parent queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1411 /// * `taskId` - Optional. Task ID for the task being created. If not provided, a random task ID is assigned to the task.
1412 pub fn locations_queues_tasks_buffer(
1413 &self,
1414 request: BufferTaskRequest,
1415 queue: &str,
1416 task_id: &str,
1417 ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1418 ProjectLocationQueueTaskBufferCall {
1419 hub: self.hub,
1420 _request: request,
1421 _queue: queue.to_string(),
1422 _task_id: task_id.to_string(),
1423 _delegate: Default::default(),
1424 _additional_params: Default::default(),
1425 _scopes: Default::default(),
1426 }
1427 }
1428
1429 /// Create a builder to help you perform the following task:
1430 ///
1431 /// Cancel a pull task's lease. The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.
1432 ///
1433 /// # Arguments
1434 ///
1435 /// * `request` - No description provided.
1436 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1437 pub fn locations_queues_tasks_cancel_lease(
1438 &self,
1439 request: CancelLeaseRequest,
1440 name: &str,
1441 ) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
1442 ProjectLocationQueueTaskCancelLeaseCall {
1443 hub: self.hub,
1444 _request: request,
1445 _name: name.to_string(),
1446 _delegate: Default::default(),
1447 _additional_params: Default::default(),
1448 _scopes: Default::default(),
1449 }
1450 }
1451
1452 /// Create a builder to help you perform the following task:
1453 ///
1454 /// Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command. * For App Engine queues, the maximum task size is 100KB. * For pull queues, the maximum task size is 1MB.
1455 ///
1456 /// # Arguments
1457 ///
1458 /// * `request` - No description provided.
1459 /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1460 pub fn locations_queues_tasks_create(
1461 &self,
1462 request: CreateTaskRequest,
1463 parent: &str,
1464 ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
1465 ProjectLocationQueueTaskCreateCall {
1466 hub: self.hub,
1467 _request: request,
1468 _parent: parent.to_string(),
1469 _delegate: Default::default(),
1470 _additional_params: Default::default(),
1471 _scopes: Default::default(),
1472 }
1473 }
1474
1475 /// Create a builder to help you perform the following task:
1476 ///
1477 /// Deletes a task. A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has completed successfully or permanently failed.
1478 ///
1479 /// # Arguments
1480 ///
1481 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1482 pub fn locations_queues_tasks_delete(
1483 &self,
1484 name: &str,
1485 ) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
1486 ProjectLocationQueueTaskDeleteCall {
1487 hub: self.hub,
1488 _name: name.to_string(),
1489 _delegate: Default::default(),
1490 _additional_params: Default::default(),
1491 _scopes: Default::default(),
1492 }
1493 }
1494
1495 /// Create a builder to help you perform the following task:
1496 ///
1497 /// Gets a task.
1498 ///
1499 /// # Arguments
1500 ///
1501 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1502 pub fn locations_queues_tasks_get(&self, name: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
1503 ProjectLocationQueueTaskGetCall {
1504 hub: self.hub,
1505 _name: name.to_string(),
1506 _response_view: Default::default(),
1507 _delegate: Default::default(),
1508 _additional_params: Default::default(),
1509 _scopes: Default::default(),
1510 }
1511 }
1512
1513 /// Create a builder to help you perform the following task:
1514 ///
1515 /// Leases tasks from a pull queue for lease_duration. This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task. The payload is intended to store data that the worker needs to perform the work associated with the task. To return the payloads in the response, set response_view to FULL. A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.
1516 ///
1517 /// # Arguments
1518 ///
1519 /// * `request` - No description provided.
1520 /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1521 pub fn locations_queues_tasks_lease(
1522 &self,
1523 request: LeaseTasksRequest,
1524 parent: &str,
1525 ) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
1526 ProjectLocationQueueTaskLeaseCall {
1527 hub: self.hub,
1528 _request: request,
1529 _parent: parent.to_string(),
1530 _delegate: Default::default(),
1531 _additional_params: Default::default(),
1532 _scopes: Default::default(),
1533 }
1534 }
1535
1536 /// Create a builder to help you perform the following task:
1537 ///
1538 /// Lists the tasks in a queue. By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned. The tasks may be returned in any order. The ordering may change at any time.
1539 ///
1540 /// # Arguments
1541 ///
1542 /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1543 pub fn locations_queues_tasks_list(
1544 &self,
1545 parent: &str,
1546 ) -> ProjectLocationQueueTaskListCall<'a, C> {
1547 ProjectLocationQueueTaskListCall {
1548 hub: self.hub,
1549 _parent: parent.to_string(),
1550 _response_view: Default::default(),
1551 _page_token: Default::default(),
1552 _page_size: Default::default(),
1553 _delegate: Default::default(),
1554 _additional_params: Default::default(),
1555 _scopes: Default::default(),
1556 }
1557 }
1558
1559 /// Create a builder to help you perform the following task:
1560 ///
1561 /// Renew the current lease of a pull task. The worker can use this method to extend the lease by a new duration, starting from now. The new task lease will be returned in the task's schedule_time.
1562 ///
1563 /// # Arguments
1564 ///
1565 /// * `request` - No description provided.
1566 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1567 pub fn locations_queues_tasks_renew_lease(
1568 &self,
1569 request: RenewLeaseRequest,
1570 name: &str,
1571 ) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
1572 ProjectLocationQueueTaskRenewLeaseCall {
1573 hub: self.hub,
1574 _request: request,
1575 _name: name.to_string(),
1576 _delegate: Default::default(),
1577 _additional_params: Default::default(),
1578 _scopes: Default::default(),
1579 }
1580 }
1581
1582 /// Create a builder to help you perform the following task:
1583 ///
1584 /// Forces a task to run now. When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED. This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now. The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target. If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig. RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed. RunTask cannot be called on a pull task.
1585 ///
1586 /// # Arguments
1587 ///
1588 /// * `request` - No description provided.
1589 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1590 pub fn locations_queues_tasks_run(
1591 &self,
1592 request: RunTaskRequest,
1593 name: &str,
1594 ) -> ProjectLocationQueueTaskRunCall<'a, C> {
1595 ProjectLocationQueueTaskRunCall {
1596 hub: self.hub,
1597 _request: request,
1598 _name: name.to_string(),
1599 _delegate: Default::default(),
1600 _additional_params: Default::default(),
1601 _scopes: Default::default(),
1602 }
1603 }
1604
1605 /// Create a builder to help you perform the following task:
1606 ///
1607 /// Creates a queue. Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not. WARNING: Using this method may have unintended side effects if you are using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
1608 ///
1609 /// # Arguments
1610 ///
1611 /// * `request` - No description provided.
1612 /// * `parent` - Required. The location name in which the queue will be created. For example: `projects/PROJECT_ID/locations/LOCATION_ID` The list of allowed locations can be obtained by calling Cloud Tasks' implementation of ListLocations.
1613 pub fn locations_queues_create(
1614 &self,
1615 request: Queue,
1616 parent: &str,
1617 ) -> ProjectLocationQueueCreateCall<'a, C> {
1618 ProjectLocationQueueCreateCall {
1619 hub: self.hub,
1620 _request: request,
1621 _parent: parent.to_string(),
1622 _delegate: Default::default(),
1623 _additional_params: Default::default(),
1624 _scopes: Default::default(),
1625 }
1626 }
1627
1628 /// Create a builder to help you perform the following task:
1629 ///
1630 /// Deletes a queue. This command will delete the queue even if it has tasks in it. Note: If you delete a queue, you may be prevented from creating a new queue with the same name as the deleted queue for a tombstone window of up to 3 days. During this window, the CreateQueue operation may appear to recreate the queue, but this can be misleading. If you attempt to create a queue with the same name as one that is in the tombstone window, run GetQueue to confirm that the queue creation was successful. If GetQueue returns 200 response code, your queue was successfully created with the name of the previously deleted queue. Otherwise, your queue did not successfully recreate. WARNING: Using this method may have unintended side effects if you are using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
1631 ///
1632 /// # Arguments
1633 ///
1634 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1635 pub fn locations_queues_delete(&self, name: &str) -> ProjectLocationQueueDeleteCall<'a, C> {
1636 ProjectLocationQueueDeleteCall {
1637 hub: self.hub,
1638 _name: name.to_string(),
1639 _delegate: Default::default(),
1640 _additional_params: Default::default(),
1641 _scopes: Default::default(),
1642 }
1643 }
1644
1645 /// Create a builder to help you perform the following task:
1646 ///
1647 /// Gets a queue.
1648 ///
1649 /// # Arguments
1650 ///
1651 /// * `name` - Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1652 pub fn locations_queues_get(&self, name: &str) -> ProjectLocationQueueGetCall<'a, C> {
1653 ProjectLocationQueueGetCall {
1654 hub: self.hub,
1655 _name: name.to_string(),
1656 _read_mask: Default::default(),
1657 _delegate: Default::default(),
1658 _additional_params: Default::default(),
1659 _scopes: Default::default(),
1660 }
1661 }
1662
1663 /// Create a builder to help you perform the following task:
1664 ///
1665 /// Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set. Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the specified resource parent: * `cloudtasks.queues.getIamPolicy`
1666 ///
1667 /// # Arguments
1668 ///
1669 /// * `request` - No description provided.
1670 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1671 pub fn locations_queues_get_iam_policy(
1672 &self,
1673 request: GetIamPolicyRequest,
1674 resource: &str,
1675 ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
1676 ProjectLocationQueueGetIamPolicyCall {
1677 hub: self.hub,
1678 _request: request,
1679 _resource: resource.to_string(),
1680 _delegate: Default::default(),
1681 _additional_params: Default::default(),
1682 _scopes: Default::default(),
1683 }
1684 }
1685
1686 /// Create a builder to help you perform the following task:
1687 ///
1688 /// Lists queues. Queues are returned in lexicographical order.
1689 ///
1690 /// # Arguments
1691 ///
1692 /// * `parent` - Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`
1693 pub fn locations_queues_list(&self, parent: &str) -> ProjectLocationQueueListCall<'a, C> {
1694 ProjectLocationQueueListCall {
1695 hub: self.hub,
1696 _parent: parent.to_string(),
1697 _read_mask: Default::default(),
1698 _page_token: Default::default(),
1699 _page_size: Default::default(),
1700 _filter: Default::default(),
1701 _delegate: Default::default(),
1702 _additional_params: Default::default(),
1703 _scopes: Default::default(),
1704 }
1705 }
1706
1707 /// Create a builder to help you perform the following task:
1708 ///
1709 /// Updates a queue. This method creates the queue if it does not exist and updates the queue if it does exist. Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not. WARNING: Using this method may have unintended side effects if you are using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
1710 ///
1711 /// # Arguments
1712 ///
1713 /// * `request` - No description provided.
1714 /// * `name` - Caller-specified and required in CreateQueue, after which it becomes output only. The queue name. The queue name must have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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 queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters.
1715 pub fn locations_queues_patch(
1716 &self,
1717 request: Queue,
1718 name: &str,
1719 ) -> ProjectLocationQueuePatchCall<'a, C> {
1720 ProjectLocationQueuePatchCall {
1721 hub: self.hub,
1722 _request: request,
1723 _name: name.to_string(),
1724 _update_mask: Default::default(),
1725 _delegate: Default::default(),
1726 _additional_params: Default::default(),
1727 _scopes: Default::default(),
1728 }
1729 }
1730
1731 /// Create a builder to help you perform the following task:
1732 ///
1733 /// Pauses the queue. If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.
1734 ///
1735 /// # Arguments
1736 ///
1737 /// * `request` - No description provided.
1738 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1739 pub fn locations_queues_pause(
1740 &self,
1741 request: PauseQueueRequest,
1742 name: &str,
1743 ) -> ProjectLocationQueuePauseCall<'a, C> {
1744 ProjectLocationQueuePauseCall {
1745 hub: self.hub,
1746 _request: request,
1747 _name: name.to_string(),
1748 _delegate: Default::default(),
1749 _additional_params: Default::default(),
1750 _scopes: Default::default(),
1751 }
1752 }
1753
1754 /// Create a builder to help you perform the following task:
1755 ///
1756 /// Purges a queue by deleting all of its tasks. All tasks created before this method is called are permanently deleted. Purge operations can take up to one minute to take effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible.
1757 ///
1758 /// # Arguments
1759 ///
1760 /// * `request` - No description provided.
1761 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1762 pub fn locations_queues_purge(
1763 &self,
1764 request: PurgeQueueRequest,
1765 name: &str,
1766 ) -> ProjectLocationQueuePurgeCall<'a, C> {
1767 ProjectLocationQueuePurgeCall {
1768 hub: self.hub,
1769 _request: request,
1770 _name: name.to_string(),
1771 _delegate: Default::default(),
1772 _additional_params: Default::default(),
1773 _scopes: Default::default(),
1774 }
1775 }
1776
1777 /// Create a builder to help you perform the following task:
1778 ///
1779 /// Resume a queue. This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING. WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
1780 ///
1781 /// # Arguments
1782 ///
1783 /// * `request` - No description provided.
1784 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1785 pub fn locations_queues_resume(
1786 &self,
1787 request: ResumeQueueRequest,
1788 name: &str,
1789 ) -> ProjectLocationQueueResumeCall<'a, C> {
1790 ProjectLocationQueueResumeCall {
1791 hub: self.hub,
1792 _request: request,
1793 _name: name.to_string(),
1794 _delegate: Default::default(),
1795 _additional_params: Default::default(),
1796 _scopes: Default::default(),
1797 }
1798 }
1799
1800 /// Create a builder to help you perform the following task:
1801 ///
1802 /// Sets the access control policy for a Queue. Replaces any existing policy. Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console. Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the specified resource parent: * `cloudtasks.queues.setIamPolicy`
1803 ///
1804 /// # Arguments
1805 ///
1806 /// * `request` - No description provided.
1807 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1808 pub fn locations_queues_set_iam_policy(
1809 &self,
1810 request: SetIamPolicyRequest,
1811 resource: &str,
1812 ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
1813 ProjectLocationQueueSetIamPolicyCall {
1814 hub: self.hub,
1815 _request: request,
1816 _resource: resource.to_string(),
1817 _delegate: Default::default(),
1818 _additional_params: Default::default(),
1819 _scopes: Default::default(),
1820 }
1821 }
1822
1823 /// Create a builder to help you perform the following task:
1824 ///
1825 /// Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
1826 ///
1827 /// # Arguments
1828 ///
1829 /// * `request` - No description provided.
1830 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1831 pub fn locations_queues_test_iam_permissions(
1832 &self,
1833 request: TestIamPermissionsRequest,
1834 resource: &str,
1835 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
1836 ProjectLocationQueueTestIamPermissionCall {
1837 hub: self.hub,
1838 _request: request,
1839 _resource: resource.to_string(),
1840 _delegate: Default::default(),
1841 _additional_params: Default::default(),
1842 _scopes: Default::default(),
1843 }
1844 }
1845
1846 /// Create a builder to help you perform the following task:
1847 ///
1848 /// Gets information about a location.
1849 ///
1850 /// # Arguments
1851 ///
1852 /// * `name` - Resource name for the location.
1853 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1854 ProjectLocationGetCall {
1855 hub: self.hub,
1856 _name: name.to_string(),
1857 _delegate: Default::default(),
1858 _additional_params: Default::default(),
1859 _scopes: Default::default(),
1860 }
1861 }
1862
1863 /// Create a builder to help you perform the following task:
1864 ///
1865 /// Gets the CMEK config. Gets the Customer Managed Encryption Key configured with the Cloud Tasks lcoation. By default there is no kms_key configured.
1866 ///
1867 /// # Arguments
1868 ///
1869 /// * `name` - Required. The config. For example: projects/PROJECT_ID/locations/LOCATION_ID/CmekConfig`
1870 pub fn locations_get_cmek_config(&self, name: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
1871 ProjectLocationGetCmekConfigCall {
1872 hub: self.hub,
1873 _name: name.to_string(),
1874 _delegate: Default::default(),
1875 _additional_params: Default::default(),
1876 _scopes: Default::default(),
1877 }
1878 }
1879
1880 /// Create a builder to help you perform the following task:
1881 ///
1882 /// Lists information about the supported locations for this service.
1883 ///
1884 /// # Arguments
1885 ///
1886 /// * `name` - The resource that owns the locations collection, if applicable.
1887 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1888 ProjectLocationListCall {
1889 hub: self.hub,
1890 _name: name.to_string(),
1891 _page_token: Default::default(),
1892 _page_size: Default::default(),
1893 _filter: Default::default(),
1894 _extra_location_types: Default::default(),
1895 _delegate: Default::default(),
1896 _additional_params: Default::default(),
1897 _scopes: Default::default(),
1898 }
1899 }
1900
1901 /// Create a builder to help you perform the following task:
1902 ///
1903 /// Creates or Updates a CMEK config. Updates the Customer Managed Encryption Key assotiated with the Cloud Tasks location (Creates if the key does not already exist). All new tasks created in the location will be encrypted at-rest with the KMS-key provided in the config.
1904 ///
1905 /// # Arguments
1906 ///
1907 /// * `request` - No description provided.
1908 /// * `name` - Output only. The config resource name which includes the project and location and must end in 'cmekConfig', in the format projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig`
1909 pub fn locations_update_cmek_config(
1910 &self,
1911 request: CmekConfig,
1912 name: &str,
1913 ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
1914 ProjectLocationUpdateCmekConfigCall {
1915 hub: self.hub,
1916 _request: request,
1917 _name: name.to_string(),
1918 _update_mask: Default::default(),
1919 _delegate: Default::default(),
1920 _additional_params: Default::default(),
1921 _scopes: Default::default(),
1922 }
1923 }
1924}
1925
1926// ###################
1927// CallBuilders ###
1928// #################
1929
1930/// Update queue list by uploading a queue.yaml file. The queue.yaml file is supplied in the request body as a YAML encoded string. This method was added to support gcloud clients versions before 322.0.0. New clients should use CreateQueue instead of this method.
1931///
1932/// A builder for the *queue.update* method supported by a *api* resource.
1933/// It is not used directly, but through a [`ApiMethods`] 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_cloudtasks2_beta2 as cloudtasks2_beta2;
1943/// use cloudtasks2_beta2::api::HttpBody;
1944/// # async fn dox() {
1945/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1946///
1947/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1948/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1949/// # .with_native_roots()
1950/// # .unwrap()
1951/// # .https_only()
1952/// # .enable_http2()
1953/// # .build();
1954///
1955/// # let executor = hyper_util::rt::TokioExecutor::new();
1956/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1957/// # secret,
1958/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1959/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1960/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1961/// # ),
1962/// # ).build().await.unwrap();
1963///
1964/// # let client = hyper_util::client::legacy::Client::builder(
1965/// # hyper_util::rt::TokioExecutor::new()
1966/// # )
1967/// # .build(
1968/// # hyper_rustls::HttpsConnectorBuilder::new()
1969/// # .with_native_roots()
1970/// # .unwrap()
1971/// # .https_or_http()
1972/// # .enable_http2()
1973/// # .build()
1974/// # );
1975/// # let mut hub = CloudTasks::new(client, auth);
1976/// // As the method needs a request, you would usually fill it with the desired information
1977/// // into the respective structure. Some of the parts shown here might not be applicable !
1978/// // Values shown here are possibly random and not representative !
1979/// let mut req = HttpBody::default();
1980///
1981/// // You can configure optional parameters by calling the respective setters at will, and
1982/// // execute the final call using `doit()`.
1983/// // Values shown here are possibly random and not representative !
1984/// let result = hub.api().queue_update(req)
1985/// .app_id("ipsum")
1986/// .doit().await;
1987/// # }
1988/// ```
1989pub struct ApiQueueUpdateCall<'a, C>
1990where
1991 C: 'a,
1992{
1993 hub: &'a CloudTasks<C>,
1994 _request: HttpBody,
1995 _app_id: 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 ApiQueueUpdateCall<'a, C> {}
2002
2003impl<'a, C> ApiQueueUpdateCall<'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, Empty)> {
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: "cloudtasks.api.queue.update",
2019 http_method: hyper::Method::POST,
2020 });
2021
2022 for &field in ["alt", "appId"].iter() {
2023 if self._additional_params.contains_key(field) {
2024 dlg.finished(false);
2025 return Err(common::Error::FieldClash(field));
2026 }
2027 }
2028
2029 let mut params = Params::with_capacity(4 + self._additional_params.len());
2030 if let Some(value) = self._app_id.as_ref() {
2031 params.push("appId", value);
2032 }
2033
2034 params.extend(self._additional_params.iter());
2035
2036 params.push("alt", "json");
2037 let mut url = self.hub._base_url.clone() + "api/queue/update";
2038 if self._scopes.is_empty() {
2039 self._scopes
2040 .insert(Scope::CloudPlatform.as_ref().to_string());
2041 }
2042
2043 let url = params.parse_with_url(&url);
2044
2045 let mut json_mime_type = mime::APPLICATION_JSON;
2046 let mut request_value_reader = {
2047 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2048 common::remove_json_null_values(&mut value);
2049 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2050 serde_json::to_writer(&mut dst, &value).unwrap();
2051 dst
2052 };
2053 let request_size = request_value_reader
2054 .seek(std::io::SeekFrom::End(0))
2055 .unwrap();
2056 request_value_reader
2057 .seek(std::io::SeekFrom::Start(0))
2058 .unwrap();
2059
2060 loop {
2061 let token = match self
2062 .hub
2063 .auth
2064 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2065 .await
2066 {
2067 Ok(token) => token,
2068 Err(e) => match dlg.token(e) {
2069 Ok(token) => token,
2070 Err(e) => {
2071 dlg.finished(false);
2072 return Err(common::Error::MissingToken(e));
2073 }
2074 },
2075 };
2076 request_value_reader
2077 .seek(std::io::SeekFrom::Start(0))
2078 .unwrap();
2079 let mut req_result = {
2080 let client = &self.hub.client;
2081 dlg.pre_request();
2082 let mut req_builder = hyper::Request::builder()
2083 .method(hyper::Method::POST)
2084 .uri(url.as_str())
2085 .header(USER_AGENT, self.hub._user_agent.clone());
2086
2087 if let Some(token) = token.as_ref() {
2088 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2089 }
2090
2091 let request = req_builder
2092 .header(CONTENT_TYPE, json_mime_type.to_string())
2093 .header(CONTENT_LENGTH, request_size as u64)
2094 .body(common::to_body(
2095 request_value_reader.get_ref().clone().into(),
2096 ));
2097
2098 client.request(request.unwrap()).await
2099 };
2100
2101 match req_result {
2102 Err(err) => {
2103 if let common::Retry::After(d) = dlg.http_error(&err) {
2104 sleep(d).await;
2105 continue;
2106 }
2107 dlg.finished(false);
2108 return Err(common::Error::HttpError(err));
2109 }
2110 Ok(res) => {
2111 let (mut parts, body) = res.into_parts();
2112 let mut body = common::Body::new(body);
2113 if !parts.status.is_success() {
2114 let bytes = common::to_bytes(body).await.unwrap_or_default();
2115 let error = serde_json::from_str(&common::to_string(&bytes));
2116 let response = common::to_response(parts, bytes.into());
2117
2118 if let common::Retry::After(d) =
2119 dlg.http_failure(&response, error.as_ref().ok())
2120 {
2121 sleep(d).await;
2122 continue;
2123 }
2124
2125 dlg.finished(false);
2126
2127 return Err(match error {
2128 Ok(value) => common::Error::BadRequest(value),
2129 _ => common::Error::Failure(response),
2130 });
2131 }
2132 let response = {
2133 let bytes = common::to_bytes(body).await.unwrap_or_default();
2134 let encoded = common::to_string(&bytes);
2135 match serde_json::from_str(&encoded) {
2136 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2137 Err(error) => {
2138 dlg.response_json_decode_error(&encoded, &error);
2139 return Err(common::Error::JsonDecodeError(
2140 encoded.to_string(),
2141 error,
2142 ));
2143 }
2144 }
2145 };
2146
2147 dlg.finished(true);
2148 return Ok(response);
2149 }
2150 }
2151 }
2152 }
2153
2154 ///
2155 /// Sets the *request* property to the given value.
2156 ///
2157 /// Even though the property as already been set when instantiating this call,
2158 /// we provide this method for API completeness.
2159 pub fn request(mut self, new_value: HttpBody) -> ApiQueueUpdateCall<'a, C> {
2160 self._request = new_value;
2161 self
2162 }
2163 /// Required. The App ID is supplied as an HTTP parameter. Unlike internal usage of App ID, it does not include a region prefix. Rather, the App ID represents the Project ID against which to make the request.
2164 ///
2165 /// Sets the *app id* query property to the given value.
2166 pub fn app_id(mut self, new_value: &str) -> ApiQueueUpdateCall<'a, C> {
2167 self._app_id = Some(new_value.to_string());
2168 self
2169 }
2170 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2171 /// while executing the actual API request.
2172 ///
2173 /// ````text
2174 /// It should be used to handle progress information, and to implement a certain level of resilience.
2175 /// ````
2176 ///
2177 /// Sets the *delegate* property to the given value.
2178 pub fn delegate(
2179 mut self,
2180 new_value: &'a mut dyn common::Delegate,
2181 ) -> ApiQueueUpdateCall<'a, C> {
2182 self._delegate = Some(new_value);
2183 self
2184 }
2185
2186 /// Set any additional parameter of the query string used in the request.
2187 /// It should be used to set parameters which are not yet available through their own
2188 /// setters.
2189 ///
2190 /// Please note that this method must not be used to set any of the known parameters
2191 /// which have their own setter method. If done anyway, the request will fail.
2192 ///
2193 /// # Additional Parameters
2194 ///
2195 /// * *$.xgafv* (query-string) - V1 error format.
2196 /// * *access_token* (query-string) - OAuth access token.
2197 /// * *alt* (query-string) - Data format for response.
2198 /// * *callback* (query-string) - JSONP
2199 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2200 /// * *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.
2201 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2202 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2203 /// * *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.
2204 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2205 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2206 pub fn param<T>(mut self, name: T, value: T) -> ApiQueueUpdateCall<'a, C>
2207 where
2208 T: AsRef<str>,
2209 {
2210 self._additional_params
2211 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2212 self
2213 }
2214
2215 /// Identifies the authorization scope for the method you are building.
2216 ///
2217 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2218 /// [`Scope::CloudPlatform`].
2219 ///
2220 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2221 /// tokens for more than one scope.
2222 ///
2223 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2224 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2225 /// sufficient, a read-write scope will do as well.
2226 pub fn add_scope<St>(mut self, scope: St) -> ApiQueueUpdateCall<'a, C>
2227 where
2228 St: AsRef<str>,
2229 {
2230 self._scopes.insert(String::from(scope.as_ref()));
2231 self
2232 }
2233 /// Identifies the authorization scope(s) for the method you are building.
2234 ///
2235 /// See [`Self::add_scope()`] for details.
2236 pub fn add_scopes<I, St>(mut self, scopes: I) -> ApiQueueUpdateCall<'a, C>
2237 where
2238 I: IntoIterator<Item = St>,
2239 St: AsRef<str>,
2240 {
2241 self._scopes
2242 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2243 self
2244 }
2245
2246 /// Removes all scopes, and no default scope will be used either.
2247 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2248 /// for details).
2249 pub fn clear_scopes(mut self) -> ApiQueueUpdateCall<'a, C> {
2250 self._scopes.clear();
2251 self
2252 }
2253}
2254
2255/// Acknowledges a pull task. The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished. The worker must acknowledge a task within the lease_duration or the lease will expire and the task will become available to be leased again. After the task is acknowledged, it will not be returned by a later LeaseTasks, GetTask, or ListTasks.
2256///
2257/// A builder for the *locations.queues.tasks.acknowledge* method supported by a *project* resource.
2258/// It is not used directly, but through a [`ProjectMethods`] instance.
2259///
2260/// # Example
2261///
2262/// Instantiate a resource method builder
2263///
2264/// ```test_harness,no_run
2265/// # extern crate hyper;
2266/// # extern crate hyper_rustls;
2267/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
2268/// use cloudtasks2_beta2::api::AcknowledgeTaskRequest;
2269/// # async fn dox() {
2270/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2271///
2272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2273/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2274/// # .with_native_roots()
2275/// # .unwrap()
2276/// # .https_only()
2277/// # .enable_http2()
2278/// # .build();
2279///
2280/// # let executor = hyper_util::rt::TokioExecutor::new();
2281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2282/// # secret,
2283/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2284/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2285/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2286/// # ),
2287/// # ).build().await.unwrap();
2288///
2289/// # let client = hyper_util::client::legacy::Client::builder(
2290/// # hyper_util::rt::TokioExecutor::new()
2291/// # )
2292/// # .build(
2293/// # hyper_rustls::HttpsConnectorBuilder::new()
2294/// # .with_native_roots()
2295/// # .unwrap()
2296/// # .https_or_http()
2297/// # .enable_http2()
2298/// # .build()
2299/// # );
2300/// # let mut hub = CloudTasks::new(client, auth);
2301/// // As the method needs a request, you would usually fill it with the desired information
2302/// // into the respective structure. Some of the parts shown here might not be applicable !
2303/// // Values shown here are possibly random and not representative !
2304/// let mut req = AcknowledgeTaskRequest::default();
2305///
2306/// // You can configure optional parameters by calling the respective setters at will, and
2307/// // execute the final call using `doit()`.
2308/// // Values shown here are possibly random and not representative !
2309/// let result = hub.projects().locations_queues_tasks_acknowledge(req, "name")
2310/// .doit().await;
2311/// # }
2312/// ```
2313pub struct ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2314where
2315 C: 'a,
2316{
2317 hub: &'a CloudTasks<C>,
2318 _request: AcknowledgeTaskRequest,
2319 _name: String,
2320 _delegate: Option<&'a mut dyn common::Delegate>,
2321 _additional_params: HashMap<String, String>,
2322 _scopes: BTreeSet<String>,
2323}
2324
2325impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskAcknowledgeCall<'a, C> {}
2326
2327impl<'a, C> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2328where
2329 C: common::Connector,
2330{
2331 /// Perform the operation you have build so far.
2332 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2333 use std::borrow::Cow;
2334 use std::io::{Read, Seek};
2335
2336 use common::{url::Params, ToParts};
2337 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2338
2339 let mut dd = common::DefaultDelegate;
2340 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2341 dlg.begin(common::MethodInfo {
2342 id: "cloudtasks.projects.locations.queues.tasks.acknowledge",
2343 http_method: hyper::Method::POST,
2344 });
2345
2346 for &field in ["alt", "name"].iter() {
2347 if self._additional_params.contains_key(field) {
2348 dlg.finished(false);
2349 return Err(common::Error::FieldClash(field));
2350 }
2351 }
2352
2353 let mut params = Params::with_capacity(4 + self._additional_params.len());
2354 params.push("name", self._name);
2355
2356 params.extend(self._additional_params.iter());
2357
2358 params.push("alt", "json");
2359 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:acknowledge";
2360 if self._scopes.is_empty() {
2361 self._scopes
2362 .insert(Scope::CloudPlatform.as_ref().to_string());
2363 }
2364
2365 #[allow(clippy::single_element_loop)]
2366 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2367 url = params.uri_replacement(url, param_name, find_this, true);
2368 }
2369 {
2370 let to_remove = ["name"];
2371 params.remove_params(&to_remove);
2372 }
2373
2374 let url = params.parse_with_url(&url);
2375
2376 let mut json_mime_type = mime::APPLICATION_JSON;
2377 let mut request_value_reader = {
2378 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2379 common::remove_json_null_values(&mut value);
2380 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2381 serde_json::to_writer(&mut dst, &value).unwrap();
2382 dst
2383 };
2384 let request_size = request_value_reader
2385 .seek(std::io::SeekFrom::End(0))
2386 .unwrap();
2387 request_value_reader
2388 .seek(std::io::SeekFrom::Start(0))
2389 .unwrap();
2390
2391 loop {
2392 let token = match self
2393 .hub
2394 .auth
2395 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2396 .await
2397 {
2398 Ok(token) => token,
2399 Err(e) => match dlg.token(e) {
2400 Ok(token) => token,
2401 Err(e) => {
2402 dlg.finished(false);
2403 return Err(common::Error::MissingToken(e));
2404 }
2405 },
2406 };
2407 request_value_reader
2408 .seek(std::io::SeekFrom::Start(0))
2409 .unwrap();
2410 let mut req_result = {
2411 let client = &self.hub.client;
2412 dlg.pre_request();
2413 let mut req_builder = hyper::Request::builder()
2414 .method(hyper::Method::POST)
2415 .uri(url.as_str())
2416 .header(USER_AGENT, self.hub._user_agent.clone());
2417
2418 if let Some(token) = token.as_ref() {
2419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2420 }
2421
2422 let request = req_builder
2423 .header(CONTENT_TYPE, json_mime_type.to_string())
2424 .header(CONTENT_LENGTH, request_size as u64)
2425 .body(common::to_body(
2426 request_value_reader.get_ref().clone().into(),
2427 ));
2428
2429 client.request(request.unwrap()).await
2430 };
2431
2432 match req_result {
2433 Err(err) => {
2434 if let common::Retry::After(d) = dlg.http_error(&err) {
2435 sleep(d).await;
2436 continue;
2437 }
2438 dlg.finished(false);
2439 return Err(common::Error::HttpError(err));
2440 }
2441 Ok(res) => {
2442 let (mut parts, body) = res.into_parts();
2443 let mut body = common::Body::new(body);
2444 if !parts.status.is_success() {
2445 let bytes = common::to_bytes(body).await.unwrap_or_default();
2446 let error = serde_json::from_str(&common::to_string(&bytes));
2447 let response = common::to_response(parts, bytes.into());
2448
2449 if let common::Retry::After(d) =
2450 dlg.http_failure(&response, error.as_ref().ok())
2451 {
2452 sleep(d).await;
2453 continue;
2454 }
2455
2456 dlg.finished(false);
2457
2458 return Err(match error {
2459 Ok(value) => common::Error::BadRequest(value),
2460 _ => common::Error::Failure(response),
2461 });
2462 }
2463 let response = {
2464 let bytes = common::to_bytes(body).await.unwrap_or_default();
2465 let encoded = common::to_string(&bytes);
2466 match serde_json::from_str(&encoded) {
2467 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2468 Err(error) => {
2469 dlg.response_json_decode_error(&encoded, &error);
2470 return Err(common::Error::JsonDecodeError(
2471 encoded.to_string(),
2472 error,
2473 ));
2474 }
2475 }
2476 };
2477
2478 dlg.finished(true);
2479 return Ok(response);
2480 }
2481 }
2482 }
2483 }
2484
2485 ///
2486 /// Sets the *request* property to the given value.
2487 ///
2488 /// Even though the property as already been set when instantiating this call,
2489 /// we provide this method for API completeness.
2490 pub fn request(
2491 mut self,
2492 new_value: AcknowledgeTaskRequest,
2493 ) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2494 self._request = new_value;
2495 self
2496 }
2497 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2498 ///
2499 /// Sets the *name* path property to the given value.
2500 ///
2501 /// Even though the property as already been set when instantiating this call,
2502 /// we provide this method for API completeness.
2503 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2504 self._name = new_value.to_string();
2505 self
2506 }
2507 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2508 /// while executing the actual API request.
2509 ///
2510 /// ````text
2511 /// It should be used to handle progress information, and to implement a certain level of resilience.
2512 /// ````
2513 ///
2514 /// Sets the *delegate* property to the given value.
2515 pub fn delegate(
2516 mut self,
2517 new_value: &'a mut dyn common::Delegate,
2518 ) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2519 self._delegate = Some(new_value);
2520 self
2521 }
2522
2523 /// Set any additional parameter of the query string used in the request.
2524 /// It should be used to set parameters which are not yet available through their own
2525 /// setters.
2526 ///
2527 /// Please note that this method must not be used to set any of the known parameters
2528 /// which have their own setter method. If done anyway, the request will fail.
2529 ///
2530 /// # Additional Parameters
2531 ///
2532 /// * *$.xgafv* (query-string) - V1 error format.
2533 /// * *access_token* (query-string) - OAuth access token.
2534 /// * *alt* (query-string) - Data format for response.
2535 /// * *callback* (query-string) - JSONP
2536 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2537 /// * *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.
2538 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2539 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2540 /// * *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.
2541 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2542 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2543 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2544 where
2545 T: AsRef<str>,
2546 {
2547 self._additional_params
2548 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2549 self
2550 }
2551
2552 /// Identifies the authorization scope for the method you are building.
2553 ///
2554 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2555 /// [`Scope::CloudPlatform`].
2556 ///
2557 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2558 /// tokens for more than one scope.
2559 ///
2560 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2561 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2562 /// sufficient, a read-write scope will do as well.
2563 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2564 where
2565 St: AsRef<str>,
2566 {
2567 self._scopes.insert(String::from(scope.as_ref()));
2568 self
2569 }
2570 /// Identifies the authorization scope(s) for the method you are building.
2571 ///
2572 /// See [`Self::add_scope()`] for details.
2573 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2574 where
2575 I: IntoIterator<Item = St>,
2576 St: AsRef<str>,
2577 {
2578 self._scopes
2579 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2580 self
2581 }
2582
2583 /// Removes all scopes, and no default scope will be used either.
2584 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2585 /// for details).
2586 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2587 self._scopes.clear();
2588 self
2589 }
2590}
2591
2592/// Creates and buffers a new task without the need to explicitly define a Task message. The queue must have HTTP target. To create the task with a custom ID, use the following format and set TASK_ID to your desired ID: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer To create the task with an automatically generated ID, use the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer.
2593///
2594/// A builder for the *locations.queues.tasks.buffer* method supported by a *project* resource.
2595/// It is not used directly, but through a [`ProjectMethods`] instance.
2596///
2597/// # Example
2598///
2599/// Instantiate a resource method builder
2600///
2601/// ```test_harness,no_run
2602/// # extern crate hyper;
2603/// # extern crate hyper_rustls;
2604/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
2605/// use cloudtasks2_beta2::api::BufferTaskRequest;
2606/// # async fn dox() {
2607/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2608///
2609/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2610/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2611/// # .with_native_roots()
2612/// # .unwrap()
2613/// # .https_only()
2614/// # .enable_http2()
2615/// # .build();
2616///
2617/// # let executor = hyper_util::rt::TokioExecutor::new();
2618/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2619/// # secret,
2620/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2621/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2622/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2623/// # ),
2624/// # ).build().await.unwrap();
2625///
2626/// # let client = hyper_util::client::legacy::Client::builder(
2627/// # hyper_util::rt::TokioExecutor::new()
2628/// # )
2629/// # .build(
2630/// # hyper_rustls::HttpsConnectorBuilder::new()
2631/// # .with_native_roots()
2632/// # .unwrap()
2633/// # .https_or_http()
2634/// # .enable_http2()
2635/// # .build()
2636/// # );
2637/// # let mut hub = CloudTasks::new(client, auth);
2638/// // As the method needs a request, you would usually fill it with the desired information
2639/// // into the respective structure. Some of the parts shown here might not be applicable !
2640/// // Values shown here are possibly random and not representative !
2641/// let mut req = BufferTaskRequest::default();
2642///
2643/// // You can configure optional parameters by calling the respective setters at will, and
2644/// // execute the final call using `doit()`.
2645/// // Values shown here are possibly random and not representative !
2646/// let result = hub.projects().locations_queues_tasks_buffer(req, "queue", "taskId")
2647/// .doit().await;
2648/// # }
2649/// ```
2650pub struct ProjectLocationQueueTaskBufferCall<'a, C>
2651where
2652 C: 'a,
2653{
2654 hub: &'a CloudTasks<C>,
2655 _request: BufferTaskRequest,
2656 _queue: String,
2657 _task_id: String,
2658 _delegate: Option<&'a mut dyn common::Delegate>,
2659 _additional_params: HashMap<String, String>,
2660 _scopes: BTreeSet<String>,
2661}
2662
2663impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskBufferCall<'a, C> {}
2664
2665impl<'a, C> ProjectLocationQueueTaskBufferCall<'a, C>
2666where
2667 C: common::Connector,
2668{
2669 /// Perform the operation you have build so far.
2670 pub async fn doit(mut self) -> common::Result<(common::Response, BufferTaskResponse)> {
2671 use std::borrow::Cow;
2672 use std::io::{Read, Seek};
2673
2674 use common::{url::Params, ToParts};
2675 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2676
2677 let mut dd = common::DefaultDelegate;
2678 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2679 dlg.begin(common::MethodInfo {
2680 id: "cloudtasks.projects.locations.queues.tasks.buffer",
2681 http_method: hyper::Method::POST,
2682 });
2683
2684 for &field in ["alt", "queue", "taskId"].iter() {
2685 if self._additional_params.contains_key(field) {
2686 dlg.finished(false);
2687 return Err(common::Error::FieldClash(field));
2688 }
2689 }
2690
2691 let mut params = Params::with_capacity(5 + self._additional_params.len());
2692 params.push("queue", self._queue);
2693 params.push("taskId", self._task_id);
2694
2695 params.extend(self._additional_params.iter());
2696
2697 params.push("alt", "json");
2698 let mut url = self.hub._base_url.clone() + "v2beta2/{+queue}/tasks/{taskId}:buffer";
2699 if self._scopes.is_empty() {
2700 self._scopes
2701 .insert(Scope::CloudPlatform.as_ref().to_string());
2702 }
2703
2704 #[allow(clippy::single_element_loop)]
2705 for &(find_this, param_name) in [("{+queue}", "queue"), ("{taskId}", "taskId")].iter() {
2706 url = params.uri_replacement(url, param_name, find_this, true);
2707 }
2708 {
2709 let to_remove = ["taskId", "queue"];
2710 params.remove_params(&to_remove);
2711 }
2712
2713 let url = params.parse_with_url(&url);
2714
2715 let mut json_mime_type = mime::APPLICATION_JSON;
2716 let mut request_value_reader = {
2717 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2718 common::remove_json_null_values(&mut value);
2719 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2720 serde_json::to_writer(&mut dst, &value).unwrap();
2721 dst
2722 };
2723 let request_size = request_value_reader
2724 .seek(std::io::SeekFrom::End(0))
2725 .unwrap();
2726 request_value_reader
2727 .seek(std::io::SeekFrom::Start(0))
2728 .unwrap();
2729
2730 loop {
2731 let token = match self
2732 .hub
2733 .auth
2734 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2735 .await
2736 {
2737 Ok(token) => token,
2738 Err(e) => match dlg.token(e) {
2739 Ok(token) => token,
2740 Err(e) => {
2741 dlg.finished(false);
2742 return Err(common::Error::MissingToken(e));
2743 }
2744 },
2745 };
2746 request_value_reader
2747 .seek(std::io::SeekFrom::Start(0))
2748 .unwrap();
2749 let mut req_result = {
2750 let client = &self.hub.client;
2751 dlg.pre_request();
2752 let mut req_builder = hyper::Request::builder()
2753 .method(hyper::Method::POST)
2754 .uri(url.as_str())
2755 .header(USER_AGENT, self.hub._user_agent.clone());
2756
2757 if let Some(token) = token.as_ref() {
2758 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2759 }
2760
2761 let request = req_builder
2762 .header(CONTENT_TYPE, json_mime_type.to_string())
2763 .header(CONTENT_LENGTH, request_size as u64)
2764 .body(common::to_body(
2765 request_value_reader.get_ref().clone().into(),
2766 ));
2767
2768 client.request(request.unwrap()).await
2769 };
2770
2771 match req_result {
2772 Err(err) => {
2773 if let common::Retry::After(d) = dlg.http_error(&err) {
2774 sleep(d).await;
2775 continue;
2776 }
2777 dlg.finished(false);
2778 return Err(common::Error::HttpError(err));
2779 }
2780 Ok(res) => {
2781 let (mut parts, body) = res.into_parts();
2782 let mut body = common::Body::new(body);
2783 if !parts.status.is_success() {
2784 let bytes = common::to_bytes(body).await.unwrap_or_default();
2785 let error = serde_json::from_str(&common::to_string(&bytes));
2786 let response = common::to_response(parts, bytes.into());
2787
2788 if let common::Retry::After(d) =
2789 dlg.http_failure(&response, error.as_ref().ok())
2790 {
2791 sleep(d).await;
2792 continue;
2793 }
2794
2795 dlg.finished(false);
2796
2797 return Err(match error {
2798 Ok(value) => common::Error::BadRequest(value),
2799 _ => common::Error::Failure(response),
2800 });
2801 }
2802 let response = {
2803 let bytes = common::to_bytes(body).await.unwrap_or_default();
2804 let encoded = common::to_string(&bytes);
2805 match serde_json::from_str(&encoded) {
2806 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2807 Err(error) => {
2808 dlg.response_json_decode_error(&encoded, &error);
2809 return Err(common::Error::JsonDecodeError(
2810 encoded.to_string(),
2811 error,
2812 ));
2813 }
2814 }
2815 };
2816
2817 dlg.finished(true);
2818 return Ok(response);
2819 }
2820 }
2821 }
2822 }
2823
2824 ///
2825 /// Sets the *request* property to the given value.
2826 ///
2827 /// Even though the property as already been set when instantiating this call,
2828 /// we provide this method for API completeness.
2829 pub fn request(
2830 mut self,
2831 new_value: BufferTaskRequest,
2832 ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2833 self._request = new_value;
2834 self
2835 }
2836 /// Required. The parent queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
2837 ///
2838 /// Sets the *queue* path property to the given value.
2839 ///
2840 /// Even though the property as already been set when instantiating this call,
2841 /// we provide this method for API completeness.
2842 pub fn queue(mut self, new_value: &str) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2843 self._queue = new_value.to_string();
2844 self
2845 }
2846 /// Optional. Task ID for the task being created. If not provided, a random task ID is assigned to the task.
2847 ///
2848 /// Sets the *task id* path property to the given value.
2849 ///
2850 /// Even though the property as already been set when instantiating this call,
2851 /// we provide this method for API completeness.
2852 pub fn task_id(mut self, new_value: &str) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2853 self._task_id = new_value.to_string();
2854 self
2855 }
2856 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2857 /// while executing the actual API request.
2858 ///
2859 /// ````text
2860 /// It should be used to handle progress information, and to implement a certain level of resilience.
2861 /// ````
2862 ///
2863 /// Sets the *delegate* property to the given value.
2864 pub fn delegate(
2865 mut self,
2866 new_value: &'a mut dyn common::Delegate,
2867 ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2868 self._delegate = Some(new_value);
2869 self
2870 }
2871
2872 /// Set any additional parameter of the query string used in the request.
2873 /// It should be used to set parameters which are not yet available through their own
2874 /// setters.
2875 ///
2876 /// Please note that this method must not be used to set any of the known parameters
2877 /// which have their own setter method. If done anyway, the request will fail.
2878 ///
2879 /// # Additional Parameters
2880 ///
2881 /// * *$.xgafv* (query-string) - V1 error format.
2882 /// * *access_token* (query-string) - OAuth access token.
2883 /// * *alt* (query-string) - Data format for response.
2884 /// * *callback* (query-string) - JSONP
2885 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2886 /// * *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.
2887 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2888 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2889 /// * *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.
2890 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2891 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2892 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskBufferCall<'a, C>
2893 where
2894 T: AsRef<str>,
2895 {
2896 self._additional_params
2897 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2898 self
2899 }
2900
2901 /// Identifies the authorization scope for the method you are building.
2902 ///
2903 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2904 /// [`Scope::CloudPlatform`].
2905 ///
2906 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2907 /// tokens for more than one scope.
2908 ///
2909 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2910 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2911 /// sufficient, a read-write scope will do as well.
2912 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskBufferCall<'a, C>
2913 where
2914 St: AsRef<str>,
2915 {
2916 self._scopes.insert(String::from(scope.as_ref()));
2917 self
2918 }
2919 /// Identifies the authorization scope(s) for the method you are building.
2920 ///
2921 /// See [`Self::add_scope()`] for details.
2922 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskBufferCall<'a, C>
2923 where
2924 I: IntoIterator<Item = St>,
2925 St: AsRef<str>,
2926 {
2927 self._scopes
2928 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2929 self
2930 }
2931
2932 /// Removes all scopes, and no default scope will be used either.
2933 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2934 /// for details).
2935 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2936 self._scopes.clear();
2937 self
2938 }
2939}
2940
2941/// Cancel a pull task's lease. The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.
2942///
2943/// A builder for the *locations.queues.tasks.cancelLease* method supported by a *project* resource.
2944/// It is not used directly, but through a [`ProjectMethods`] instance.
2945///
2946/// # Example
2947///
2948/// Instantiate a resource method builder
2949///
2950/// ```test_harness,no_run
2951/// # extern crate hyper;
2952/// # extern crate hyper_rustls;
2953/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
2954/// use cloudtasks2_beta2::api::CancelLeaseRequest;
2955/// # async fn dox() {
2956/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2957///
2958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2959/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2960/// # .with_native_roots()
2961/// # .unwrap()
2962/// # .https_only()
2963/// # .enable_http2()
2964/// # .build();
2965///
2966/// # let executor = hyper_util::rt::TokioExecutor::new();
2967/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2968/// # secret,
2969/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2970/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2971/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2972/// # ),
2973/// # ).build().await.unwrap();
2974///
2975/// # let client = hyper_util::client::legacy::Client::builder(
2976/// # hyper_util::rt::TokioExecutor::new()
2977/// # )
2978/// # .build(
2979/// # hyper_rustls::HttpsConnectorBuilder::new()
2980/// # .with_native_roots()
2981/// # .unwrap()
2982/// # .https_or_http()
2983/// # .enable_http2()
2984/// # .build()
2985/// # );
2986/// # let mut hub = CloudTasks::new(client, auth);
2987/// // As the method needs a request, you would usually fill it with the desired information
2988/// // into the respective structure. Some of the parts shown here might not be applicable !
2989/// // Values shown here are possibly random and not representative !
2990/// let mut req = CancelLeaseRequest::default();
2991///
2992/// // You can configure optional parameters by calling the respective setters at will, and
2993/// // execute the final call using `doit()`.
2994/// // Values shown here are possibly random and not representative !
2995/// let result = hub.projects().locations_queues_tasks_cancel_lease(req, "name")
2996/// .doit().await;
2997/// # }
2998/// ```
2999pub struct ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3000where
3001 C: 'a,
3002{
3003 hub: &'a CloudTasks<C>,
3004 _request: CancelLeaseRequest,
3005 _name: String,
3006 _delegate: Option<&'a mut dyn common::Delegate>,
3007 _additional_params: HashMap<String, String>,
3008 _scopes: BTreeSet<String>,
3009}
3010
3011impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskCancelLeaseCall<'a, C> {}
3012
3013impl<'a, C> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3014where
3015 C: common::Connector,
3016{
3017 /// Perform the operation you have build so far.
3018 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3019 use std::borrow::Cow;
3020 use std::io::{Read, Seek};
3021
3022 use common::{url::Params, ToParts};
3023 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3024
3025 let mut dd = common::DefaultDelegate;
3026 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3027 dlg.begin(common::MethodInfo {
3028 id: "cloudtasks.projects.locations.queues.tasks.cancelLease",
3029 http_method: hyper::Method::POST,
3030 });
3031
3032 for &field in ["alt", "name"].iter() {
3033 if self._additional_params.contains_key(field) {
3034 dlg.finished(false);
3035 return Err(common::Error::FieldClash(field));
3036 }
3037 }
3038
3039 let mut params = Params::with_capacity(4 + self._additional_params.len());
3040 params.push("name", self._name);
3041
3042 params.extend(self._additional_params.iter());
3043
3044 params.push("alt", "json");
3045 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:cancelLease";
3046 if self._scopes.is_empty() {
3047 self._scopes
3048 .insert(Scope::CloudPlatform.as_ref().to_string());
3049 }
3050
3051 #[allow(clippy::single_element_loop)]
3052 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3053 url = params.uri_replacement(url, param_name, find_this, true);
3054 }
3055 {
3056 let to_remove = ["name"];
3057 params.remove_params(&to_remove);
3058 }
3059
3060 let url = params.parse_with_url(&url);
3061
3062 let mut json_mime_type = mime::APPLICATION_JSON;
3063 let mut request_value_reader = {
3064 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3065 common::remove_json_null_values(&mut value);
3066 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3067 serde_json::to_writer(&mut dst, &value).unwrap();
3068 dst
3069 };
3070 let request_size = request_value_reader
3071 .seek(std::io::SeekFrom::End(0))
3072 .unwrap();
3073 request_value_reader
3074 .seek(std::io::SeekFrom::Start(0))
3075 .unwrap();
3076
3077 loop {
3078 let token = match self
3079 .hub
3080 .auth
3081 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3082 .await
3083 {
3084 Ok(token) => token,
3085 Err(e) => match dlg.token(e) {
3086 Ok(token) => token,
3087 Err(e) => {
3088 dlg.finished(false);
3089 return Err(common::Error::MissingToken(e));
3090 }
3091 },
3092 };
3093 request_value_reader
3094 .seek(std::io::SeekFrom::Start(0))
3095 .unwrap();
3096 let mut req_result = {
3097 let client = &self.hub.client;
3098 dlg.pre_request();
3099 let mut req_builder = hyper::Request::builder()
3100 .method(hyper::Method::POST)
3101 .uri(url.as_str())
3102 .header(USER_AGENT, self.hub._user_agent.clone());
3103
3104 if let Some(token) = token.as_ref() {
3105 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3106 }
3107
3108 let request = req_builder
3109 .header(CONTENT_TYPE, json_mime_type.to_string())
3110 .header(CONTENT_LENGTH, request_size as u64)
3111 .body(common::to_body(
3112 request_value_reader.get_ref().clone().into(),
3113 ));
3114
3115 client.request(request.unwrap()).await
3116 };
3117
3118 match req_result {
3119 Err(err) => {
3120 if let common::Retry::After(d) = dlg.http_error(&err) {
3121 sleep(d).await;
3122 continue;
3123 }
3124 dlg.finished(false);
3125 return Err(common::Error::HttpError(err));
3126 }
3127 Ok(res) => {
3128 let (mut parts, body) = res.into_parts();
3129 let mut body = common::Body::new(body);
3130 if !parts.status.is_success() {
3131 let bytes = common::to_bytes(body).await.unwrap_or_default();
3132 let error = serde_json::from_str(&common::to_string(&bytes));
3133 let response = common::to_response(parts, bytes.into());
3134
3135 if let common::Retry::After(d) =
3136 dlg.http_failure(&response, error.as_ref().ok())
3137 {
3138 sleep(d).await;
3139 continue;
3140 }
3141
3142 dlg.finished(false);
3143
3144 return Err(match error {
3145 Ok(value) => common::Error::BadRequest(value),
3146 _ => common::Error::Failure(response),
3147 });
3148 }
3149 let response = {
3150 let bytes = common::to_bytes(body).await.unwrap_or_default();
3151 let encoded = common::to_string(&bytes);
3152 match serde_json::from_str(&encoded) {
3153 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3154 Err(error) => {
3155 dlg.response_json_decode_error(&encoded, &error);
3156 return Err(common::Error::JsonDecodeError(
3157 encoded.to_string(),
3158 error,
3159 ));
3160 }
3161 }
3162 };
3163
3164 dlg.finished(true);
3165 return Ok(response);
3166 }
3167 }
3168 }
3169 }
3170
3171 ///
3172 /// Sets the *request* property to the given value.
3173 ///
3174 /// Even though the property as already been set when instantiating this call,
3175 /// we provide this method for API completeness.
3176 pub fn request(
3177 mut self,
3178 new_value: CancelLeaseRequest,
3179 ) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3180 self._request = new_value;
3181 self
3182 }
3183 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
3184 ///
3185 /// Sets the *name* path property to the given value.
3186 ///
3187 /// Even though the property as already been set when instantiating this call,
3188 /// we provide this method for API completeness.
3189 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3190 self._name = new_value.to_string();
3191 self
3192 }
3193 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3194 /// while executing the actual API request.
3195 ///
3196 /// ````text
3197 /// It should be used to handle progress information, and to implement a certain level of resilience.
3198 /// ````
3199 ///
3200 /// Sets the *delegate* property to the given value.
3201 pub fn delegate(
3202 mut self,
3203 new_value: &'a mut dyn common::Delegate,
3204 ) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3205 self._delegate = Some(new_value);
3206 self
3207 }
3208
3209 /// Set any additional parameter of the query string used in the request.
3210 /// It should be used to set parameters which are not yet available through their own
3211 /// setters.
3212 ///
3213 /// Please note that this method must not be used to set any of the known parameters
3214 /// which have their own setter method. If done anyway, the request will fail.
3215 ///
3216 /// # Additional Parameters
3217 ///
3218 /// * *$.xgafv* (query-string) - V1 error format.
3219 /// * *access_token* (query-string) - OAuth access token.
3220 /// * *alt* (query-string) - Data format for response.
3221 /// * *callback* (query-string) - JSONP
3222 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3223 /// * *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.
3224 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3225 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3226 /// * *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.
3227 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3228 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3229 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3230 where
3231 T: AsRef<str>,
3232 {
3233 self._additional_params
3234 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3235 self
3236 }
3237
3238 /// Identifies the authorization scope for the method you are building.
3239 ///
3240 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3241 /// [`Scope::CloudPlatform`].
3242 ///
3243 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3244 /// tokens for more than one scope.
3245 ///
3246 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3247 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3248 /// sufficient, a read-write scope will do as well.
3249 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3250 where
3251 St: AsRef<str>,
3252 {
3253 self._scopes.insert(String::from(scope.as_ref()));
3254 self
3255 }
3256 /// Identifies the authorization scope(s) for the method you are building.
3257 ///
3258 /// See [`Self::add_scope()`] for details.
3259 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3260 where
3261 I: IntoIterator<Item = St>,
3262 St: AsRef<str>,
3263 {
3264 self._scopes
3265 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3266 self
3267 }
3268
3269 /// Removes all scopes, and no default scope will be used either.
3270 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3271 /// for details).
3272 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3273 self._scopes.clear();
3274 self
3275 }
3276}
3277
3278/// Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command. * For App Engine queues, the maximum task size is 100KB. * For pull queues, the maximum task size is 1MB.
3279///
3280/// A builder for the *locations.queues.tasks.create* method supported by a *project* resource.
3281/// It is not used directly, but through a [`ProjectMethods`] instance.
3282///
3283/// # Example
3284///
3285/// Instantiate a resource method builder
3286///
3287/// ```test_harness,no_run
3288/// # extern crate hyper;
3289/// # extern crate hyper_rustls;
3290/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
3291/// use cloudtasks2_beta2::api::CreateTaskRequest;
3292/// # async fn dox() {
3293/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3294///
3295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3297/// # .with_native_roots()
3298/// # .unwrap()
3299/// # .https_only()
3300/// # .enable_http2()
3301/// # .build();
3302///
3303/// # let executor = hyper_util::rt::TokioExecutor::new();
3304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3305/// # secret,
3306/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3307/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3308/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3309/// # ),
3310/// # ).build().await.unwrap();
3311///
3312/// # let client = hyper_util::client::legacy::Client::builder(
3313/// # hyper_util::rt::TokioExecutor::new()
3314/// # )
3315/// # .build(
3316/// # hyper_rustls::HttpsConnectorBuilder::new()
3317/// # .with_native_roots()
3318/// # .unwrap()
3319/// # .https_or_http()
3320/// # .enable_http2()
3321/// # .build()
3322/// # );
3323/// # let mut hub = CloudTasks::new(client, auth);
3324/// // As the method needs a request, you would usually fill it with the desired information
3325/// // into the respective structure. Some of the parts shown here might not be applicable !
3326/// // Values shown here are possibly random and not representative !
3327/// let mut req = CreateTaskRequest::default();
3328///
3329/// // You can configure optional parameters by calling the respective setters at will, and
3330/// // execute the final call using `doit()`.
3331/// // Values shown here are possibly random and not representative !
3332/// let result = hub.projects().locations_queues_tasks_create(req, "parent")
3333/// .doit().await;
3334/// # }
3335/// ```
3336pub struct ProjectLocationQueueTaskCreateCall<'a, C>
3337where
3338 C: 'a,
3339{
3340 hub: &'a CloudTasks<C>,
3341 _request: CreateTaskRequest,
3342 _parent: String,
3343 _delegate: Option<&'a mut dyn common::Delegate>,
3344 _additional_params: HashMap<String, String>,
3345 _scopes: BTreeSet<String>,
3346}
3347
3348impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskCreateCall<'a, C> {}
3349
3350impl<'a, C> ProjectLocationQueueTaskCreateCall<'a, C>
3351where
3352 C: common::Connector,
3353{
3354 /// Perform the operation you have build so far.
3355 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3356 use std::borrow::Cow;
3357 use std::io::{Read, Seek};
3358
3359 use common::{url::Params, ToParts};
3360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3361
3362 let mut dd = common::DefaultDelegate;
3363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3364 dlg.begin(common::MethodInfo {
3365 id: "cloudtasks.projects.locations.queues.tasks.create",
3366 http_method: hyper::Method::POST,
3367 });
3368
3369 for &field in ["alt", "parent"].iter() {
3370 if self._additional_params.contains_key(field) {
3371 dlg.finished(false);
3372 return Err(common::Error::FieldClash(field));
3373 }
3374 }
3375
3376 let mut params = Params::with_capacity(4 + self._additional_params.len());
3377 params.push("parent", self._parent);
3378
3379 params.extend(self._additional_params.iter());
3380
3381 params.push("alt", "json");
3382 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/tasks";
3383 if self._scopes.is_empty() {
3384 self._scopes
3385 .insert(Scope::CloudPlatform.as_ref().to_string());
3386 }
3387
3388 #[allow(clippy::single_element_loop)]
3389 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3390 url = params.uri_replacement(url, param_name, find_this, true);
3391 }
3392 {
3393 let to_remove = ["parent"];
3394 params.remove_params(&to_remove);
3395 }
3396
3397 let url = params.parse_with_url(&url);
3398
3399 let mut json_mime_type = mime::APPLICATION_JSON;
3400 let mut request_value_reader = {
3401 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3402 common::remove_json_null_values(&mut value);
3403 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3404 serde_json::to_writer(&mut dst, &value).unwrap();
3405 dst
3406 };
3407 let request_size = request_value_reader
3408 .seek(std::io::SeekFrom::End(0))
3409 .unwrap();
3410 request_value_reader
3411 .seek(std::io::SeekFrom::Start(0))
3412 .unwrap();
3413
3414 loop {
3415 let token = match self
3416 .hub
3417 .auth
3418 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3419 .await
3420 {
3421 Ok(token) => token,
3422 Err(e) => match dlg.token(e) {
3423 Ok(token) => token,
3424 Err(e) => {
3425 dlg.finished(false);
3426 return Err(common::Error::MissingToken(e));
3427 }
3428 },
3429 };
3430 request_value_reader
3431 .seek(std::io::SeekFrom::Start(0))
3432 .unwrap();
3433 let mut req_result = {
3434 let client = &self.hub.client;
3435 dlg.pre_request();
3436 let mut req_builder = hyper::Request::builder()
3437 .method(hyper::Method::POST)
3438 .uri(url.as_str())
3439 .header(USER_AGENT, self.hub._user_agent.clone());
3440
3441 if let Some(token) = token.as_ref() {
3442 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3443 }
3444
3445 let request = req_builder
3446 .header(CONTENT_TYPE, json_mime_type.to_string())
3447 .header(CONTENT_LENGTH, request_size as u64)
3448 .body(common::to_body(
3449 request_value_reader.get_ref().clone().into(),
3450 ));
3451
3452 client.request(request.unwrap()).await
3453 };
3454
3455 match req_result {
3456 Err(err) => {
3457 if let common::Retry::After(d) = dlg.http_error(&err) {
3458 sleep(d).await;
3459 continue;
3460 }
3461 dlg.finished(false);
3462 return Err(common::Error::HttpError(err));
3463 }
3464 Ok(res) => {
3465 let (mut parts, body) = res.into_parts();
3466 let mut body = common::Body::new(body);
3467 if !parts.status.is_success() {
3468 let bytes = common::to_bytes(body).await.unwrap_or_default();
3469 let error = serde_json::from_str(&common::to_string(&bytes));
3470 let response = common::to_response(parts, bytes.into());
3471
3472 if let common::Retry::After(d) =
3473 dlg.http_failure(&response, error.as_ref().ok())
3474 {
3475 sleep(d).await;
3476 continue;
3477 }
3478
3479 dlg.finished(false);
3480
3481 return Err(match error {
3482 Ok(value) => common::Error::BadRequest(value),
3483 _ => common::Error::Failure(response),
3484 });
3485 }
3486 let response = {
3487 let bytes = common::to_bytes(body).await.unwrap_or_default();
3488 let encoded = common::to_string(&bytes);
3489 match serde_json::from_str(&encoded) {
3490 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3491 Err(error) => {
3492 dlg.response_json_decode_error(&encoded, &error);
3493 return Err(common::Error::JsonDecodeError(
3494 encoded.to_string(),
3495 error,
3496 ));
3497 }
3498 }
3499 };
3500
3501 dlg.finished(true);
3502 return Ok(response);
3503 }
3504 }
3505 }
3506 }
3507
3508 ///
3509 /// Sets the *request* property to the given value.
3510 ///
3511 /// Even though the property as already been set when instantiating this call,
3512 /// we provide this method for API completeness.
3513 pub fn request(
3514 mut self,
3515 new_value: CreateTaskRequest,
3516 ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3517 self._request = new_value;
3518 self
3519 }
3520 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
3521 ///
3522 /// Sets the *parent* path property to the given value.
3523 ///
3524 /// Even though the property as already been set when instantiating this call,
3525 /// we provide this method for API completeness.
3526 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3527 self._parent = new_value.to_string();
3528 self
3529 }
3530 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3531 /// while executing the actual API request.
3532 ///
3533 /// ````text
3534 /// It should be used to handle progress information, and to implement a certain level of resilience.
3535 /// ````
3536 ///
3537 /// Sets the *delegate* property to the given value.
3538 pub fn delegate(
3539 mut self,
3540 new_value: &'a mut dyn common::Delegate,
3541 ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3542 self._delegate = Some(new_value);
3543 self
3544 }
3545
3546 /// Set any additional parameter of the query string used in the request.
3547 /// It should be used to set parameters which are not yet available through their own
3548 /// setters.
3549 ///
3550 /// Please note that this method must not be used to set any of the known parameters
3551 /// which have their own setter method. If done anyway, the request will fail.
3552 ///
3553 /// # Additional Parameters
3554 ///
3555 /// * *$.xgafv* (query-string) - V1 error format.
3556 /// * *access_token* (query-string) - OAuth access token.
3557 /// * *alt* (query-string) - Data format for response.
3558 /// * *callback* (query-string) - JSONP
3559 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3560 /// * *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.
3561 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3562 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3563 /// * *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.
3564 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3565 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3566 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskCreateCall<'a, C>
3567 where
3568 T: AsRef<str>,
3569 {
3570 self._additional_params
3571 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3572 self
3573 }
3574
3575 /// Identifies the authorization scope for the method you are building.
3576 ///
3577 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3578 /// [`Scope::CloudPlatform`].
3579 ///
3580 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3581 /// tokens for more than one scope.
3582 ///
3583 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3584 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3585 /// sufficient, a read-write scope will do as well.
3586 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskCreateCall<'a, C>
3587 where
3588 St: AsRef<str>,
3589 {
3590 self._scopes.insert(String::from(scope.as_ref()));
3591 self
3592 }
3593 /// Identifies the authorization scope(s) for the method you are building.
3594 ///
3595 /// See [`Self::add_scope()`] for details.
3596 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskCreateCall<'a, C>
3597 where
3598 I: IntoIterator<Item = St>,
3599 St: AsRef<str>,
3600 {
3601 self._scopes
3602 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3603 self
3604 }
3605
3606 /// Removes all scopes, and no default scope will be used either.
3607 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3608 /// for details).
3609 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3610 self._scopes.clear();
3611 self
3612 }
3613}
3614
3615/// Deletes a task. A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has completed successfully or permanently failed.
3616///
3617/// A builder for the *locations.queues.tasks.delete* method supported by a *project* resource.
3618/// It is not used directly, but through a [`ProjectMethods`] instance.
3619///
3620/// # Example
3621///
3622/// Instantiate a resource method builder
3623///
3624/// ```test_harness,no_run
3625/// # extern crate hyper;
3626/// # extern crate hyper_rustls;
3627/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
3628/// # async fn dox() {
3629/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3630///
3631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3632/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3633/// # .with_native_roots()
3634/// # .unwrap()
3635/// # .https_only()
3636/// # .enable_http2()
3637/// # .build();
3638///
3639/// # let executor = hyper_util::rt::TokioExecutor::new();
3640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3641/// # secret,
3642/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3643/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3644/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3645/// # ),
3646/// # ).build().await.unwrap();
3647///
3648/// # let client = hyper_util::client::legacy::Client::builder(
3649/// # hyper_util::rt::TokioExecutor::new()
3650/// # )
3651/// # .build(
3652/// # hyper_rustls::HttpsConnectorBuilder::new()
3653/// # .with_native_roots()
3654/// # .unwrap()
3655/// # .https_or_http()
3656/// # .enable_http2()
3657/// # .build()
3658/// # );
3659/// # let mut hub = CloudTasks::new(client, auth);
3660/// // You can configure optional parameters by calling the respective setters at will, and
3661/// // execute the final call using `doit()`.
3662/// // Values shown here are possibly random and not representative !
3663/// let result = hub.projects().locations_queues_tasks_delete("name")
3664/// .doit().await;
3665/// # }
3666/// ```
3667pub struct ProjectLocationQueueTaskDeleteCall<'a, C>
3668where
3669 C: 'a,
3670{
3671 hub: &'a CloudTasks<C>,
3672 _name: String,
3673 _delegate: Option<&'a mut dyn common::Delegate>,
3674 _additional_params: HashMap<String, String>,
3675 _scopes: BTreeSet<String>,
3676}
3677
3678impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskDeleteCall<'a, C> {}
3679
3680impl<'a, C> ProjectLocationQueueTaskDeleteCall<'a, C>
3681where
3682 C: common::Connector,
3683{
3684 /// Perform the operation you have build so far.
3685 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3686 use std::borrow::Cow;
3687 use std::io::{Read, Seek};
3688
3689 use common::{url::Params, ToParts};
3690 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3691
3692 let mut dd = common::DefaultDelegate;
3693 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3694 dlg.begin(common::MethodInfo {
3695 id: "cloudtasks.projects.locations.queues.tasks.delete",
3696 http_method: hyper::Method::DELETE,
3697 });
3698
3699 for &field in ["alt", "name"].iter() {
3700 if self._additional_params.contains_key(field) {
3701 dlg.finished(false);
3702 return Err(common::Error::FieldClash(field));
3703 }
3704 }
3705
3706 let mut params = Params::with_capacity(3 + self._additional_params.len());
3707 params.push("name", self._name);
3708
3709 params.extend(self._additional_params.iter());
3710
3711 params.push("alt", "json");
3712 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
3713 if self._scopes.is_empty() {
3714 self._scopes
3715 .insert(Scope::CloudPlatform.as_ref().to_string());
3716 }
3717
3718 #[allow(clippy::single_element_loop)]
3719 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3720 url = params.uri_replacement(url, param_name, find_this, true);
3721 }
3722 {
3723 let to_remove = ["name"];
3724 params.remove_params(&to_remove);
3725 }
3726
3727 let url = params.parse_with_url(&url);
3728
3729 loop {
3730 let token = match self
3731 .hub
3732 .auth
3733 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3734 .await
3735 {
3736 Ok(token) => token,
3737 Err(e) => match dlg.token(e) {
3738 Ok(token) => token,
3739 Err(e) => {
3740 dlg.finished(false);
3741 return Err(common::Error::MissingToken(e));
3742 }
3743 },
3744 };
3745 let mut req_result = {
3746 let client = &self.hub.client;
3747 dlg.pre_request();
3748 let mut req_builder = hyper::Request::builder()
3749 .method(hyper::Method::DELETE)
3750 .uri(url.as_str())
3751 .header(USER_AGENT, self.hub._user_agent.clone());
3752
3753 if let Some(token) = token.as_ref() {
3754 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3755 }
3756
3757 let request = req_builder
3758 .header(CONTENT_LENGTH, 0_u64)
3759 .body(common::to_body::<String>(None));
3760
3761 client.request(request.unwrap()).await
3762 };
3763
3764 match req_result {
3765 Err(err) => {
3766 if let common::Retry::After(d) = dlg.http_error(&err) {
3767 sleep(d).await;
3768 continue;
3769 }
3770 dlg.finished(false);
3771 return Err(common::Error::HttpError(err));
3772 }
3773 Ok(res) => {
3774 let (mut parts, body) = res.into_parts();
3775 let mut body = common::Body::new(body);
3776 if !parts.status.is_success() {
3777 let bytes = common::to_bytes(body).await.unwrap_or_default();
3778 let error = serde_json::from_str(&common::to_string(&bytes));
3779 let response = common::to_response(parts, bytes.into());
3780
3781 if let common::Retry::After(d) =
3782 dlg.http_failure(&response, error.as_ref().ok())
3783 {
3784 sleep(d).await;
3785 continue;
3786 }
3787
3788 dlg.finished(false);
3789
3790 return Err(match error {
3791 Ok(value) => common::Error::BadRequest(value),
3792 _ => common::Error::Failure(response),
3793 });
3794 }
3795 let response = {
3796 let bytes = common::to_bytes(body).await.unwrap_or_default();
3797 let encoded = common::to_string(&bytes);
3798 match serde_json::from_str(&encoded) {
3799 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3800 Err(error) => {
3801 dlg.response_json_decode_error(&encoded, &error);
3802 return Err(common::Error::JsonDecodeError(
3803 encoded.to_string(),
3804 error,
3805 ));
3806 }
3807 }
3808 };
3809
3810 dlg.finished(true);
3811 return Ok(response);
3812 }
3813 }
3814 }
3815 }
3816
3817 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
3818 ///
3819 /// Sets the *name* path property to the given value.
3820 ///
3821 /// Even though the property as already been set when instantiating this call,
3822 /// we provide this method for API completeness.
3823 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
3824 self._name = new_value.to_string();
3825 self
3826 }
3827 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3828 /// while executing the actual API request.
3829 ///
3830 /// ````text
3831 /// It should be used to handle progress information, and to implement a certain level of resilience.
3832 /// ````
3833 ///
3834 /// Sets the *delegate* property to the given value.
3835 pub fn delegate(
3836 mut self,
3837 new_value: &'a mut dyn common::Delegate,
3838 ) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
3839 self._delegate = Some(new_value);
3840 self
3841 }
3842
3843 /// Set any additional parameter of the query string used in the request.
3844 /// It should be used to set parameters which are not yet available through their own
3845 /// setters.
3846 ///
3847 /// Please note that this method must not be used to set any of the known parameters
3848 /// which have their own setter method. If done anyway, the request will fail.
3849 ///
3850 /// # Additional Parameters
3851 ///
3852 /// * *$.xgafv* (query-string) - V1 error format.
3853 /// * *access_token* (query-string) - OAuth access token.
3854 /// * *alt* (query-string) - Data format for response.
3855 /// * *callback* (query-string) - JSONP
3856 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3857 /// * *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.
3858 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3859 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3860 /// * *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.
3861 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3862 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3863 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskDeleteCall<'a, C>
3864 where
3865 T: AsRef<str>,
3866 {
3867 self._additional_params
3868 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3869 self
3870 }
3871
3872 /// Identifies the authorization scope for the method you are building.
3873 ///
3874 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3875 /// [`Scope::CloudPlatform`].
3876 ///
3877 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3878 /// tokens for more than one scope.
3879 ///
3880 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3881 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3882 /// sufficient, a read-write scope will do as well.
3883 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskDeleteCall<'a, C>
3884 where
3885 St: AsRef<str>,
3886 {
3887 self._scopes.insert(String::from(scope.as_ref()));
3888 self
3889 }
3890 /// Identifies the authorization scope(s) for the method you are building.
3891 ///
3892 /// See [`Self::add_scope()`] for details.
3893 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskDeleteCall<'a, C>
3894 where
3895 I: IntoIterator<Item = St>,
3896 St: AsRef<str>,
3897 {
3898 self._scopes
3899 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3900 self
3901 }
3902
3903 /// Removes all scopes, and no default scope will be used either.
3904 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3905 /// for details).
3906 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
3907 self._scopes.clear();
3908 self
3909 }
3910}
3911
3912/// Gets a task.
3913///
3914/// A builder for the *locations.queues.tasks.get* method supported by a *project* resource.
3915/// It is not used directly, but through a [`ProjectMethods`] instance.
3916///
3917/// # Example
3918///
3919/// Instantiate a resource method builder
3920///
3921/// ```test_harness,no_run
3922/// # extern crate hyper;
3923/// # extern crate hyper_rustls;
3924/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
3925/// # async fn dox() {
3926/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3927///
3928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3930/// # .with_native_roots()
3931/// # .unwrap()
3932/// # .https_only()
3933/// # .enable_http2()
3934/// # .build();
3935///
3936/// # let executor = hyper_util::rt::TokioExecutor::new();
3937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3938/// # secret,
3939/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3940/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3941/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3942/// # ),
3943/// # ).build().await.unwrap();
3944///
3945/// # let client = hyper_util::client::legacy::Client::builder(
3946/// # hyper_util::rt::TokioExecutor::new()
3947/// # )
3948/// # .build(
3949/// # hyper_rustls::HttpsConnectorBuilder::new()
3950/// # .with_native_roots()
3951/// # .unwrap()
3952/// # .https_or_http()
3953/// # .enable_http2()
3954/// # .build()
3955/// # );
3956/// # let mut hub = CloudTasks::new(client, auth);
3957/// // You can configure optional parameters by calling the respective setters at will, and
3958/// // execute the final call using `doit()`.
3959/// // Values shown here are possibly random and not representative !
3960/// let result = hub.projects().locations_queues_tasks_get("name")
3961/// .response_view("duo")
3962/// .doit().await;
3963/// # }
3964/// ```
3965pub struct ProjectLocationQueueTaskGetCall<'a, C>
3966where
3967 C: 'a,
3968{
3969 hub: &'a CloudTasks<C>,
3970 _name: String,
3971 _response_view: Option<String>,
3972 _delegate: Option<&'a mut dyn common::Delegate>,
3973 _additional_params: HashMap<String, String>,
3974 _scopes: BTreeSet<String>,
3975}
3976
3977impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskGetCall<'a, C> {}
3978
3979impl<'a, C> ProjectLocationQueueTaskGetCall<'a, C>
3980where
3981 C: common::Connector,
3982{
3983 /// Perform the operation you have build so far.
3984 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3985 use std::borrow::Cow;
3986 use std::io::{Read, Seek};
3987
3988 use common::{url::Params, ToParts};
3989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3990
3991 let mut dd = common::DefaultDelegate;
3992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3993 dlg.begin(common::MethodInfo {
3994 id: "cloudtasks.projects.locations.queues.tasks.get",
3995 http_method: hyper::Method::GET,
3996 });
3997
3998 for &field in ["alt", "name", "responseView"].iter() {
3999 if self._additional_params.contains_key(field) {
4000 dlg.finished(false);
4001 return Err(common::Error::FieldClash(field));
4002 }
4003 }
4004
4005 let mut params = Params::with_capacity(4 + self._additional_params.len());
4006 params.push("name", self._name);
4007 if let Some(value) = self._response_view.as_ref() {
4008 params.push("responseView", value);
4009 }
4010
4011 params.extend(self._additional_params.iter());
4012
4013 params.push("alt", "json");
4014 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
4015 if self._scopes.is_empty() {
4016 self._scopes
4017 .insert(Scope::CloudPlatform.as_ref().to_string());
4018 }
4019
4020 #[allow(clippy::single_element_loop)]
4021 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4022 url = params.uri_replacement(url, param_name, find_this, true);
4023 }
4024 {
4025 let to_remove = ["name"];
4026 params.remove_params(&to_remove);
4027 }
4028
4029 let url = params.parse_with_url(&url);
4030
4031 loop {
4032 let token = match self
4033 .hub
4034 .auth
4035 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4036 .await
4037 {
4038 Ok(token) => token,
4039 Err(e) => match dlg.token(e) {
4040 Ok(token) => token,
4041 Err(e) => {
4042 dlg.finished(false);
4043 return Err(common::Error::MissingToken(e));
4044 }
4045 },
4046 };
4047 let mut req_result = {
4048 let client = &self.hub.client;
4049 dlg.pre_request();
4050 let mut req_builder = hyper::Request::builder()
4051 .method(hyper::Method::GET)
4052 .uri(url.as_str())
4053 .header(USER_AGENT, self.hub._user_agent.clone());
4054
4055 if let Some(token) = token.as_ref() {
4056 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4057 }
4058
4059 let request = req_builder
4060 .header(CONTENT_LENGTH, 0_u64)
4061 .body(common::to_body::<String>(None));
4062
4063 client.request(request.unwrap()).await
4064 };
4065
4066 match req_result {
4067 Err(err) => {
4068 if let common::Retry::After(d) = dlg.http_error(&err) {
4069 sleep(d).await;
4070 continue;
4071 }
4072 dlg.finished(false);
4073 return Err(common::Error::HttpError(err));
4074 }
4075 Ok(res) => {
4076 let (mut parts, body) = res.into_parts();
4077 let mut body = common::Body::new(body);
4078 if !parts.status.is_success() {
4079 let bytes = common::to_bytes(body).await.unwrap_or_default();
4080 let error = serde_json::from_str(&common::to_string(&bytes));
4081 let response = common::to_response(parts, bytes.into());
4082
4083 if let common::Retry::After(d) =
4084 dlg.http_failure(&response, error.as_ref().ok())
4085 {
4086 sleep(d).await;
4087 continue;
4088 }
4089
4090 dlg.finished(false);
4091
4092 return Err(match error {
4093 Ok(value) => common::Error::BadRequest(value),
4094 _ => common::Error::Failure(response),
4095 });
4096 }
4097 let response = {
4098 let bytes = common::to_bytes(body).await.unwrap_or_default();
4099 let encoded = common::to_string(&bytes);
4100 match serde_json::from_str(&encoded) {
4101 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4102 Err(error) => {
4103 dlg.response_json_decode_error(&encoded, &error);
4104 return Err(common::Error::JsonDecodeError(
4105 encoded.to_string(),
4106 error,
4107 ));
4108 }
4109 }
4110 };
4111
4112 dlg.finished(true);
4113 return Ok(response);
4114 }
4115 }
4116 }
4117 }
4118
4119 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
4120 ///
4121 /// Sets the *name* path property to the given value.
4122 ///
4123 /// Even though the property as already been set when instantiating this call,
4124 /// we provide this method for API completeness.
4125 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
4126 self._name = new_value.to_string();
4127 self
4128 }
4129 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
4130 ///
4131 /// Sets the *response view* query property to the given value.
4132 pub fn response_view(mut self, new_value: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
4133 self._response_view = Some(new_value.to_string());
4134 self
4135 }
4136 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4137 /// while executing the actual API request.
4138 ///
4139 /// ````text
4140 /// It should be used to handle progress information, and to implement a certain level of resilience.
4141 /// ````
4142 ///
4143 /// Sets the *delegate* property to the given value.
4144 pub fn delegate(
4145 mut self,
4146 new_value: &'a mut dyn common::Delegate,
4147 ) -> ProjectLocationQueueTaskGetCall<'a, C> {
4148 self._delegate = Some(new_value);
4149 self
4150 }
4151
4152 /// Set any additional parameter of the query string used in the request.
4153 /// It should be used to set parameters which are not yet available through their own
4154 /// setters.
4155 ///
4156 /// Please note that this method must not be used to set any of the known parameters
4157 /// which have their own setter method. If done anyway, the request will fail.
4158 ///
4159 /// # Additional Parameters
4160 ///
4161 /// * *$.xgafv* (query-string) - V1 error format.
4162 /// * *access_token* (query-string) - OAuth access token.
4163 /// * *alt* (query-string) - Data format for response.
4164 /// * *callback* (query-string) - JSONP
4165 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4166 /// * *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.
4167 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4168 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4169 /// * *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.
4170 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4171 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4172 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskGetCall<'a, C>
4173 where
4174 T: AsRef<str>,
4175 {
4176 self._additional_params
4177 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4178 self
4179 }
4180
4181 /// Identifies the authorization scope for the method you are building.
4182 ///
4183 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4184 /// [`Scope::CloudPlatform`].
4185 ///
4186 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4187 /// tokens for more than one scope.
4188 ///
4189 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4190 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4191 /// sufficient, a read-write scope will do as well.
4192 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskGetCall<'a, C>
4193 where
4194 St: AsRef<str>,
4195 {
4196 self._scopes.insert(String::from(scope.as_ref()));
4197 self
4198 }
4199 /// Identifies the authorization scope(s) for the method you are building.
4200 ///
4201 /// See [`Self::add_scope()`] for details.
4202 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskGetCall<'a, C>
4203 where
4204 I: IntoIterator<Item = St>,
4205 St: AsRef<str>,
4206 {
4207 self._scopes
4208 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4209 self
4210 }
4211
4212 /// Removes all scopes, and no default scope will be used either.
4213 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4214 /// for details).
4215 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskGetCall<'a, C> {
4216 self._scopes.clear();
4217 self
4218 }
4219}
4220
4221/// Leases tasks from a pull queue for lease_duration. This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task. The payload is intended to store data that the worker needs to perform the work associated with the task. To return the payloads in the response, set response_view to FULL. A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.
4222///
4223/// A builder for the *locations.queues.tasks.lease* method supported by a *project* resource.
4224/// It is not used directly, but through a [`ProjectMethods`] instance.
4225///
4226/// # Example
4227///
4228/// Instantiate a resource method builder
4229///
4230/// ```test_harness,no_run
4231/// # extern crate hyper;
4232/// # extern crate hyper_rustls;
4233/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
4234/// use cloudtasks2_beta2::api::LeaseTasksRequest;
4235/// # async fn dox() {
4236/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4237///
4238/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4239/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4240/// # .with_native_roots()
4241/// # .unwrap()
4242/// # .https_only()
4243/// # .enable_http2()
4244/// # .build();
4245///
4246/// # let executor = hyper_util::rt::TokioExecutor::new();
4247/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4248/// # secret,
4249/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4250/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4251/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4252/// # ),
4253/// # ).build().await.unwrap();
4254///
4255/// # let client = hyper_util::client::legacy::Client::builder(
4256/// # hyper_util::rt::TokioExecutor::new()
4257/// # )
4258/// # .build(
4259/// # hyper_rustls::HttpsConnectorBuilder::new()
4260/// # .with_native_roots()
4261/// # .unwrap()
4262/// # .https_or_http()
4263/// # .enable_http2()
4264/// # .build()
4265/// # );
4266/// # let mut hub = CloudTasks::new(client, auth);
4267/// // As the method needs a request, you would usually fill it with the desired information
4268/// // into the respective structure. Some of the parts shown here might not be applicable !
4269/// // Values shown here are possibly random and not representative !
4270/// let mut req = LeaseTasksRequest::default();
4271///
4272/// // You can configure optional parameters by calling the respective setters at will, and
4273/// // execute the final call using `doit()`.
4274/// // Values shown here are possibly random and not representative !
4275/// let result = hub.projects().locations_queues_tasks_lease(req, "parent")
4276/// .doit().await;
4277/// # }
4278/// ```
4279pub struct ProjectLocationQueueTaskLeaseCall<'a, C>
4280where
4281 C: 'a,
4282{
4283 hub: &'a CloudTasks<C>,
4284 _request: LeaseTasksRequest,
4285 _parent: String,
4286 _delegate: Option<&'a mut dyn common::Delegate>,
4287 _additional_params: HashMap<String, String>,
4288 _scopes: BTreeSet<String>,
4289}
4290
4291impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskLeaseCall<'a, C> {}
4292
4293impl<'a, C> ProjectLocationQueueTaskLeaseCall<'a, C>
4294where
4295 C: common::Connector,
4296{
4297 /// Perform the operation you have build so far.
4298 pub async fn doit(mut self) -> common::Result<(common::Response, LeaseTasksResponse)> {
4299 use std::borrow::Cow;
4300 use std::io::{Read, Seek};
4301
4302 use common::{url::Params, ToParts};
4303 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4304
4305 let mut dd = common::DefaultDelegate;
4306 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4307 dlg.begin(common::MethodInfo {
4308 id: "cloudtasks.projects.locations.queues.tasks.lease",
4309 http_method: hyper::Method::POST,
4310 });
4311
4312 for &field in ["alt", "parent"].iter() {
4313 if self._additional_params.contains_key(field) {
4314 dlg.finished(false);
4315 return Err(common::Error::FieldClash(field));
4316 }
4317 }
4318
4319 let mut params = Params::with_capacity(4 + self._additional_params.len());
4320 params.push("parent", self._parent);
4321
4322 params.extend(self._additional_params.iter());
4323
4324 params.push("alt", "json");
4325 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/tasks:lease";
4326 if self._scopes.is_empty() {
4327 self._scopes
4328 .insert(Scope::CloudPlatform.as_ref().to_string());
4329 }
4330
4331 #[allow(clippy::single_element_loop)]
4332 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4333 url = params.uri_replacement(url, param_name, find_this, true);
4334 }
4335 {
4336 let to_remove = ["parent"];
4337 params.remove_params(&to_remove);
4338 }
4339
4340 let url = params.parse_with_url(&url);
4341
4342 let mut json_mime_type = mime::APPLICATION_JSON;
4343 let mut request_value_reader = {
4344 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4345 common::remove_json_null_values(&mut value);
4346 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4347 serde_json::to_writer(&mut dst, &value).unwrap();
4348 dst
4349 };
4350 let request_size = request_value_reader
4351 .seek(std::io::SeekFrom::End(0))
4352 .unwrap();
4353 request_value_reader
4354 .seek(std::io::SeekFrom::Start(0))
4355 .unwrap();
4356
4357 loop {
4358 let token = match self
4359 .hub
4360 .auth
4361 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4362 .await
4363 {
4364 Ok(token) => token,
4365 Err(e) => match dlg.token(e) {
4366 Ok(token) => token,
4367 Err(e) => {
4368 dlg.finished(false);
4369 return Err(common::Error::MissingToken(e));
4370 }
4371 },
4372 };
4373 request_value_reader
4374 .seek(std::io::SeekFrom::Start(0))
4375 .unwrap();
4376 let mut req_result = {
4377 let client = &self.hub.client;
4378 dlg.pre_request();
4379 let mut req_builder = hyper::Request::builder()
4380 .method(hyper::Method::POST)
4381 .uri(url.as_str())
4382 .header(USER_AGENT, self.hub._user_agent.clone());
4383
4384 if let Some(token) = token.as_ref() {
4385 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4386 }
4387
4388 let request = req_builder
4389 .header(CONTENT_TYPE, json_mime_type.to_string())
4390 .header(CONTENT_LENGTH, request_size as u64)
4391 .body(common::to_body(
4392 request_value_reader.get_ref().clone().into(),
4393 ));
4394
4395 client.request(request.unwrap()).await
4396 };
4397
4398 match req_result {
4399 Err(err) => {
4400 if let common::Retry::After(d) = dlg.http_error(&err) {
4401 sleep(d).await;
4402 continue;
4403 }
4404 dlg.finished(false);
4405 return Err(common::Error::HttpError(err));
4406 }
4407 Ok(res) => {
4408 let (mut parts, body) = res.into_parts();
4409 let mut body = common::Body::new(body);
4410 if !parts.status.is_success() {
4411 let bytes = common::to_bytes(body).await.unwrap_or_default();
4412 let error = serde_json::from_str(&common::to_string(&bytes));
4413 let response = common::to_response(parts, bytes.into());
4414
4415 if let common::Retry::After(d) =
4416 dlg.http_failure(&response, error.as_ref().ok())
4417 {
4418 sleep(d).await;
4419 continue;
4420 }
4421
4422 dlg.finished(false);
4423
4424 return Err(match error {
4425 Ok(value) => common::Error::BadRequest(value),
4426 _ => common::Error::Failure(response),
4427 });
4428 }
4429 let response = {
4430 let bytes = common::to_bytes(body).await.unwrap_or_default();
4431 let encoded = common::to_string(&bytes);
4432 match serde_json::from_str(&encoded) {
4433 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4434 Err(error) => {
4435 dlg.response_json_decode_error(&encoded, &error);
4436 return Err(common::Error::JsonDecodeError(
4437 encoded.to_string(),
4438 error,
4439 ));
4440 }
4441 }
4442 };
4443
4444 dlg.finished(true);
4445 return Ok(response);
4446 }
4447 }
4448 }
4449 }
4450
4451 ///
4452 /// Sets the *request* property to the given value.
4453 ///
4454 /// Even though the property as already been set when instantiating this call,
4455 /// we provide this method for API completeness.
4456 pub fn request(
4457 mut self,
4458 new_value: LeaseTasksRequest,
4459 ) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4460 self._request = new_value;
4461 self
4462 }
4463 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
4464 ///
4465 /// Sets the *parent* path property to the given value.
4466 ///
4467 /// Even though the property as already been set when instantiating this call,
4468 /// we provide this method for API completeness.
4469 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4470 self._parent = new_value.to_string();
4471 self
4472 }
4473 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4474 /// while executing the actual API request.
4475 ///
4476 /// ````text
4477 /// It should be used to handle progress information, and to implement a certain level of resilience.
4478 /// ````
4479 ///
4480 /// Sets the *delegate* property to the given value.
4481 pub fn delegate(
4482 mut self,
4483 new_value: &'a mut dyn common::Delegate,
4484 ) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4485 self._delegate = Some(new_value);
4486 self
4487 }
4488
4489 /// Set any additional parameter of the query string used in the request.
4490 /// It should be used to set parameters which are not yet available through their own
4491 /// setters.
4492 ///
4493 /// Please note that this method must not be used to set any of the known parameters
4494 /// which have their own setter method. If done anyway, the request will fail.
4495 ///
4496 /// # Additional Parameters
4497 ///
4498 /// * *$.xgafv* (query-string) - V1 error format.
4499 /// * *access_token* (query-string) - OAuth access token.
4500 /// * *alt* (query-string) - Data format for response.
4501 /// * *callback* (query-string) - JSONP
4502 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4503 /// * *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.
4504 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4505 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4506 /// * *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.
4507 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4508 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4509 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskLeaseCall<'a, C>
4510 where
4511 T: AsRef<str>,
4512 {
4513 self._additional_params
4514 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4515 self
4516 }
4517
4518 /// Identifies the authorization scope for the method you are building.
4519 ///
4520 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4521 /// [`Scope::CloudPlatform`].
4522 ///
4523 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4524 /// tokens for more than one scope.
4525 ///
4526 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4527 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4528 /// sufficient, a read-write scope will do as well.
4529 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskLeaseCall<'a, C>
4530 where
4531 St: AsRef<str>,
4532 {
4533 self._scopes.insert(String::from(scope.as_ref()));
4534 self
4535 }
4536 /// Identifies the authorization scope(s) for the method you are building.
4537 ///
4538 /// See [`Self::add_scope()`] for details.
4539 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskLeaseCall<'a, C>
4540 where
4541 I: IntoIterator<Item = St>,
4542 St: AsRef<str>,
4543 {
4544 self._scopes
4545 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4546 self
4547 }
4548
4549 /// Removes all scopes, and no default scope will be used either.
4550 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4551 /// for details).
4552 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4553 self._scopes.clear();
4554 self
4555 }
4556}
4557
4558/// Lists the tasks in a queue. By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned. The tasks may be returned in any order. The ordering may change at any time.
4559///
4560/// A builder for the *locations.queues.tasks.list* method supported by a *project* resource.
4561/// It is not used directly, but through a [`ProjectMethods`] instance.
4562///
4563/// # Example
4564///
4565/// Instantiate a resource method builder
4566///
4567/// ```test_harness,no_run
4568/// # extern crate hyper;
4569/// # extern crate hyper_rustls;
4570/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
4571/// # async fn dox() {
4572/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4573///
4574/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4575/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4576/// # .with_native_roots()
4577/// # .unwrap()
4578/// # .https_only()
4579/// # .enable_http2()
4580/// # .build();
4581///
4582/// # let executor = hyper_util::rt::TokioExecutor::new();
4583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4584/// # secret,
4585/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4586/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4587/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4588/// # ),
4589/// # ).build().await.unwrap();
4590///
4591/// # let client = hyper_util::client::legacy::Client::builder(
4592/// # hyper_util::rt::TokioExecutor::new()
4593/// # )
4594/// # .build(
4595/// # hyper_rustls::HttpsConnectorBuilder::new()
4596/// # .with_native_roots()
4597/// # .unwrap()
4598/// # .https_or_http()
4599/// # .enable_http2()
4600/// # .build()
4601/// # );
4602/// # let mut hub = CloudTasks::new(client, auth);
4603/// // You can configure optional parameters by calling the respective setters at will, and
4604/// // execute the final call using `doit()`.
4605/// // Values shown here are possibly random and not representative !
4606/// let result = hub.projects().locations_queues_tasks_list("parent")
4607/// .response_view("Lorem")
4608/// .page_token("gubergren")
4609/// .page_size(-75)
4610/// .doit().await;
4611/// # }
4612/// ```
4613pub struct ProjectLocationQueueTaskListCall<'a, C>
4614where
4615 C: 'a,
4616{
4617 hub: &'a CloudTasks<C>,
4618 _parent: String,
4619 _response_view: Option<String>,
4620 _page_token: Option<String>,
4621 _page_size: Option<i32>,
4622 _delegate: Option<&'a mut dyn common::Delegate>,
4623 _additional_params: HashMap<String, String>,
4624 _scopes: BTreeSet<String>,
4625}
4626
4627impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskListCall<'a, C> {}
4628
4629impl<'a, C> ProjectLocationQueueTaskListCall<'a, C>
4630where
4631 C: common::Connector,
4632{
4633 /// Perform the operation you have build so far.
4634 pub async fn doit(mut self) -> common::Result<(common::Response, ListTasksResponse)> {
4635 use std::borrow::Cow;
4636 use std::io::{Read, Seek};
4637
4638 use common::{url::Params, ToParts};
4639 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4640
4641 let mut dd = common::DefaultDelegate;
4642 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4643 dlg.begin(common::MethodInfo {
4644 id: "cloudtasks.projects.locations.queues.tasks.list",
4645 http_method: hyper::Method::GET,
4646 });
4647
4648 for &field in ["alt", "parent", "responseView", "pageToken", "pageSize"].iter() {
4649 if self._additional_params.contains_key(field) {
4650 dlg.finished(false);
4651 return Err(common::Error::FieldClash(field));
4652 }
4653 }
4654
4655 let mut params = Params::with_capacity(6 + self._additional_params.len());
4656 params.push("parent", self._parent);
4657 if let Some(value) = self._response_view.as_ref() {
4658 params.push("responseView", value);
4659 }
4660 if let Some(value) = self._page_token.as_ref() {
4661 params.push("pageToken", value);
4662 }
4663 if let Some(value) = self._page_size.as_ref() {
4664 params.push("pageSize", value.to_string());
4665 }
4666
4667 params.extend(self._additional_params.iter());
4668
4669 params.push("alt", "json");
4670 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/tasks";
4671 if self._scopes.is_empty() {
4672 self._scopes
4673 .insert(Scope::CloudPlatform.as_ref().to_string());
4674 }
4675
4676 #[allow(clippy::single_element_loop)]
4677 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4678 url = params.uri_replacement(url, param_name, find_this, true);
4679 }
4680 {
4681 let to_remove = ["parent"];
4682 params.remove_params(&to_remove);
4683 }
4684
4685 let url = params.parse_with_url(&url);
4686
4687 loop {
4688 let token = match self
4689 .hub
4690 .auth
4691 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4692 .await
4693 {
4694 Ok(token) => token,
4695 Err(e) => match dlg.token(e) {
4696 Ok(token) => token,
4697 Err(e) => {
4698 dlg.finished(false);
4699 return Err(common::Error::MissingToken(e));
4700 }
4701 },
4702 };
4703 let mut req_result = {
4704 let client = &self.hub.client;
4705 dlg.pre_request();
4706 let mut req_builder = hyper::Request::builder()
4707 .method(hyper::Method::GET)
4708 .uri(url.as_str())
4709 .header(USER_AGENT, self.hub._user_agent.clone());
4710
4711 if let Some(token) = token.as_ref() {
4712 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4713 }
4714
4715 let request = req_builder
4716 .header(CONTENT_LENGTH, 0_u64)
4717 .body(common::to_body::<String>(None));
4718
4719 client.request(request.unwrap()).await
4720 };
4721
4722 match req_result {
4723 Err(err) => {
4724 if let common::Retry::After(d) = dlg.http_error(&err) {
4725 sleep(d).await;
4726 continue;
4727 }
4728 dlg.finished(false);
4729 return Err(common::Error::HttpError(err));
4730 }
4731 Ok(res) => {
4732 let (mut parts, body) = res.into_parts();
4733 let mut body = common::Body::new(body);
4734 if !parts.status.is_success() {
4735 let bytes = common::to_bytes(body).await.unwrap_or_default();
4736 let error = serde_json::from_str(&common::to_string(&bytes));
4737 let response = common::to_response(parts, bytes.into());
4738
4739 if let common::Retry::After(d) =
4740 dlg.http_failure(&response, error.as_ref().ok())
4741 {
4742 sleep(d).await;
4743 continue;
4744 }
4745
4746 dlg.finished(false);
4747
4748 return Err(match error {
4749 Ok(value) => common::Error::BadRequest(value),
4750 _ => common::Error::Failure(response),
4751 });
4752 }
4753 let response = {
4754 let bytes = common::to_bytes(body).await.unwrap_or_default();
4755 let encoded = common::to_string(&bytes);
4756 match serde_json::from_str(&encoded) {
4757 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4758 Err(error) => {
4759 dlg.response_json_decode_error(&encoded, &error);
4760 return Err(common::Error::JsonDecodeError(
4761 encoded.to_string(),
4762 error,
4763 ));
4764 }
4765 }
4766 };
4767
4768 dlg.finished(true);
4769 return Ok(response);
4770 }
4771 }
4772 }
4773 }
4774
4775 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
4776 ///
4777 /// Sets the *parent* path property to the given value.
4778 ///
4779 /// Even though the property as already been set when instantiating this call,
4780 /// we provide this method for API completeness.
4781 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
4782 self._parent = new_value.to_string();
4783 self
4784 }
4785 /// The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
4786 ///
4787 /// Sets the *response view* query property to the given value.
4788 pub fn response_view(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
4789 self._response_view = Some(new_value.to_string());
4790 self
4791 }
4792 /// A token identifying the page of results to 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 ListTasks method. The page token is valid for only 2 hours.
4793 ///
4794 /// Sets the *page token* query property to the given value.
4795 pub fn page_token(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
4796 self._page_token = Some(new_value.to_string());
4797 self
4798 }
4799 /// Maximum page size. Fewer tasks than requested might be returned, even if more tasks exist; use next_page_token in the response to determine if more tasks exist. The maximum page size is 1000. If unspecified, the page size will be the maximum.
4800 ///
4801 /// Sets the *page size* query property to the given value.
4802 pub fn page_size(mut self, new_value: i32) -> ProjectLocationQueueTaskListCall<'a, C> {
4803 self._page_size = Some(new_value);
4804 self
4805 }
4806 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4807 /// while executing the actual API request.
4808 ///
4809 /// ````text
4810 /// It should be used to handle progress information, and to implement a certain level of resilience.
4811 /// ````
4812 ///
4813 /// Sets the *delegate* property to the given value.
4814 pub fn delegate(
4815 mut self,
4816 new_value: &'a mut dyn common::Delegate,
4817 ) -> ProjectLocationQueueTaskListCall<'a, C> {
4818 self._delegate = Some(new_value);
4819 self
4820 }
4821
4822 /// Set any additional parameter of the query string used in the request.
4823 /// It should be used to set parameters which are not yet available through their own
4824 /// setters.
4825 ///
4826 /// Please note that this method must not be used to set any of the known parameters
4827 /// which have their own setter method. If done anyway, the request will fail.
4828 ///
4829 /// # Additional Parameters
4830 ///
4831 /// * *$.xgafv* (query-string) - V1 error format.
4832 /// * *access_token* (query-string) - OAuth access token.
4833 /// * *alt* (query-string) - Data format for response.
4834 /// * *callback* (query-string) - JSONP
4835 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4836 /// * *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.
4837 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4838 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4839 /// * *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.
4840 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4841 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4842 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskListCall<'a, C>
4843 where
4844 T: AsRef<str>,
4845 {
4846 self._additional_params
4847 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4848 self
4849 }
4850
4851 /// Identifies the authorization scope for the method you are building.
4852 ///
4853 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4854 /// [`Scope::CloudPlatform`].
4855 ///
4856 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4857 /// tokens for more than one scope.
4858 ///
4859 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4860 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4861 /// sufficient, a read-write scope will do as well.
4862 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskListCall<'a, C>
4863 where
4864 St: AsRef<str>,
4865 {
4866 self._scopes.insert(String::from(scope.as_ref()));
4867 self
4868 }
4869 /// Identifies the authorization scope(s) for the method you are building.
4870 ///
4871 /// See [`Self::add_scope()`] for details.
4872 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskListCall<'a, C>
4873 where
4874 I: IntoIterator<Item = St>,
4875 St: AsRef<str>,
4876 {
4877 self._scopes
4878 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4879 self
4880 }
4881
4882 /// Removes all scopes, and no default scope will be used either.
4883 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4884 /// for details).
4885 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskListCall<'a, C> {
4886 self._scopes.clear();
4887 self
4888 }
4889}
4890
4891/// Renew the current lease of a pull task. The worker can use this method to extend the lease by a new duration, starting from now. The new task lease will be returned in the task's schedule_time.
4892///
4893/// A builder for the *locations.queues.tasks.renewLease* method supported by a *project* resource.
4894/// It is not used directly, but through a [`ProjectMethods`] instance.
4895///
4896/// # Example
4897///
4898/// Instantiate a resource method builder
4899///
4900/// ```test_harness,no_run
4901/// # extern crate hyper;
4902/// # extern crate hyper_rustls;
4903/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
4904/// use cloudtasks2_beta2::api::RenewLeaseRequest;
4905/// # async fn dox() {
4906/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4907///
4908/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4909/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4910/// # .with_native_roots()
4911/// # .unwrap()
4912/// # .https_only()
4913/// # .enable_http2()
4914/// # .build();
4915///
4916/// # let executor = hyper_util::rt::TokioExecutor::new();
4917/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4918/// # secret,
4919/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4920/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4921/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4922/// # ),
4923/// # ).build().await.unwrap();
4924///
4925/// # let client = hyper_util::client::legacy::Client::builder(
4926/// # hyper_util::rt::TokioExecutor::new()
4927/// # )
4928/// # .build(
4929/// # hyper_rustls::HttpsConnectorBuilder::new()
4930/// # .with_native_roots()
4931/// # .unwrap()
4932/// # .https_or_http()
4933/// # .enable_http2()
4934/// # .build()
4935/// # );
4936/// # let mut hub = CloudTasks::new(client, auth);
4937/// // As the method needs a request, you would usually fill it with the desired information
4938/// // into the respective structure. Some of the parts shown here might not be applicable !
4939/// // Values shown here are possibly random and not representative !
4940/// let mut req = RenewLeaseRequest::default();
4941///
4942/// // You can configure optional parameters by calling the respective setters at will, and
4943/// // execute the final call using `doit()`.
4944/// // Values shown here are possibly random and not representative !
4945/// let result = hub.projects().locations_queues_tasks_renew_lease(req, "name")
4946/// .doit().await;
4947/// # }
4948/// ```
4949pub struct ProjectLocationQueueTaskRenewLeaseCall<'a, C>
4950where
4951 C: 'a,
4952{
4953 hub: &'a CloudTasks<C>,
4954 _request: RenewLeaseRequest,
4955 _name: String,
4956 _delegate: Option<&'a mut dyn common::Delegate>,
4957 _additional_params: HashMap<String, String>,
4958 _scopes: BTreeSet<String>,
4959}
4960
4961impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskRenewLeaseCall<'a, C> {}
4962
4963impl<'a, C> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
4964where
4965 C: common::Connector,
4966{
4967 /// Perform the operation you have build so far.
4968 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
4969 use std::borrow::Cow;
4970 use std::io::{Read, Seek};
4971
4972 use common::{url::Params, ToParts};
4973 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4974
4975 let mut dd = common::DefaultDelegate;
4976 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4977 dlg.begin(common::MethodInfo {
4978 id: "cloudtasks.projects.locations.queues.tasks.renewLease",
4979 http_method: hyper::Method::POST,
4980 });
4981
4982 for &field in ["alt", "name"].iter() {
4983 if self._additional_params.contains_key(field) {
4984 dlg.finished(false);
4985 return Err(common::Error::FieldClash(field));
4986 }
4987 }
4988
4989 let mut params = Params::with_capacity(4 + self._additional_params.len());
4990 params.push("name", self._name);
4991
4992 params.extend(self._additional_params.iter());
4993
4994 params.push("alt", "json");
4995 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:renewLease";
4996 if self._scopes.is_empty() {
4997 self._scopes
4998 .insert(Scope::CloudPlatform.as_ref().to_string());
4999 }
5000
5001 #[allow(clippy::single_element_loop)]
5002 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5003 url = params.uri_replacement(url, param_name, find_this, true);
5004 }
5005 {
5006 let to_remove = ["name"];
5007 params.remove_params(&to_remove);
5008 }
5009
5010 let url = params.parse_with_url(&url);
5011
5012 let mut json_mime_type = mime::APPLICATION_JSON;
5013 let mut request_value_reader = {
5014 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5015 common::remove_json_null_values(&mut value);
5016 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5017 serde_json::to_writer(&mut dst, &value).unwrap();
5018 dst
5019 };
5020 let request_size = request_value_reader
5021 .seek(std::io::SeekFrom::End(0))
5022 .unwrap();
5023 request_value_reader
5024 .seek(std::io::SeekFrom::Start(0))
5025 .unwrap();
5026
5027 loop {
5028 let token = match self
5029 .hub
5030 .auth
5031 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5032 .await
5033 {
5034 Ok(token) => token,
5035 Err(e) => match dlg.token(e) {
5036 Ok(token) => token,
5037 Err(e) => {
5038 dlg.finished(false);
5039 return Err(common::Error::MissingToken(e));
5040 }
5041 },
5042 };
5043 request_value_reader
5044 .seek(std::io::SeekFrom::Start(0))
5045 .unwrap();
5046 let mut req_result = {
5047 let client = &self.hub.client;
5048 dlg.pre_request();
5049 let mut req_builder = hyper::Request::builder()
5050 .method(hyper::Method::POST)
5051 .uri(url.as_str())
5052 .header(USER_AGENT, self.hub._user_agent.clone());
5053
5054 if let Some(token) = token.as_ref() {
5055 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5056 }
5057
5058 let request = req_builder
5059 .header(CONTENT_TYPE, json_mime_type.to_string())
5060 .header(CONTENT_LENGTH, request_size as u64)
5061 .body(common::to_body(
5062 request_value_reader.get_ref().clone().into(),
5063 ));
5064
5065 client.request(request.unwrap()).await
5066 };
5067
5068 match req_result {
5069 Err(err) => {
5070 if let common::Retry::After(d) = dlg.http_error(&err) {
5071 sleep(d).await;
5072 continue;
5073 }
5074 dlg.finished(false);
5075 return Err(common::Error::HttpError(err));
5076 }
5077 Ok(res) => {
5078 let (mut parts, body) = res.into_parts();
5079 let mut body = common::Body::new(body);
5080 if !parts.status.is_success() {
5081 let bytes = common::to_bytes(body).await.unwrap_or_default();
5082 let error = serde_json::from_str(&common::to_string(&bytes));
5083 let response = common::to_response(parts, bytes.into());
5084
5085 if let common::Retry::After(d) =
5086 dlg.http_failure(&response, error.as_ref().ok())
5087 {
5088 sleep(d).await;
5089 continue;
5090 }
5091
5092 dlg.finished(false);
5093
5094 return Err(match error {
5095 Ok(value) => common::Error::BadRequest(value),
5096 _ => common::Error::Failure(response),
5097 });
5098 }
5099 let response = {
5100 let bytes = common::to_bytes(body).await.unwrap_or_default();
5101 let encoded = common::to_string(&bytes);
5102 match serde_json::from_str(&encoded) {
5103 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5104 Err(error) => {
5105 dlg.response_json_decode_error(&encoded, &error);
5106 return Err(common::Error::JsonDecodeError(
5107 encoded.to_string(),
5108 error,
5109 ));
5110 }
5111 }
5112 };
5113
5114 dlg.finished(true);
5115 return Ok(response);
5116 }
5117 }
5118 }
5119 }
5120
5121 ///
5122 /// Sets the *request* property to the given value.
5123 ///
5124 /// Even though the property as already been set when instantiating this call,
5125 /// we provide this method for API completeness.
5126 pub fn request(
5127 mut self,
5128 new_value: RenewLeaseRequest,
5129 ) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
5130 self._request = new_value;
5131 self
5132 }
5133 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
5134 ///
5135 /// Sets the *name* path property to the given value.
5136 ///
5137 /// Even though the property as already been set when instantiating this call,
5138 /// we provide this method for API completeness.
5139 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
5140 self._name = new_value.to_string();
5141 self
5142 }
5143 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5144 /// while executing the actual API request.
5145 ///
5146 /// ````text
5147 /// It should be used to handle progress information, and to implement a certain level of resilience.
5148 /// ````
5149 ///
5150 /// Sets the *delegate* property to the given value.
5151 pub fn delegate(
5152 mut self,
5153 new_value: &'a mut dyn common::Delegate,
5154 ) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
5155 self._delegate = Some(new_value);
5156 self
5157 }
5158
5159 /// Set any additional parameter of the query string used in the request.
5160 /// It should be used to set parameters which are not yet available through their own
5161 /// setters.
5162 ///
5163 /// Please note that this method must not be used to set any of the known parameters
5164 /// which have their own setter method. If done anyway, the request will fail.
5165 ///
5166 /// # Additional Parameters
5167 ///
5168 /// * *$.xgafv* (query-string) - V1 error format.
5169 /// * *access_token* (query-string) - OAuth access token.
5170 /// * *alt* (query-string) - Data format for response.
5171 /// * *callback* (query-string) - JSONP
5172 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5173 /// * *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.
5174 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5175 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5176 /// * *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.
5177 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5178 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5179 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
5180 where
5181 T: AsRef<str>,
5182 {
5183 self._additional_params
5184 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5185 self
5186 }
5187
5188 /// Identifies the authorization scope for the method you are building.
5189 ///
5190 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5191 /// [`Scope::CloudPlatform`].
5192 ///
5193 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5194 /// tokens for more than one scope.
5195 ///
5196 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5197 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5198 /// sufficient, a read-write scope will do as well.
5199 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
5200 where
5201 St: AsRef<str>,
5202 {
5203 self._scopes.insert(String::from(scope.as_ref()));
5204 self
5205 }
5206 /// Identifies the authorization scope(s) for the method you are building.
5207 ///
5208 /// See [`Self::add_scope()`] for details.
5209 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
5210 where
5211 I: IntoIterator<Item = St>,
5212 St: AsRef<str>,
5213 {
5214 self._scopes
5215 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5216 self
5217 }
5218
5219 /// Removes all scopes, and no default scope will be used either.
5220 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5221 /// for details).
5222 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
5223 self._scopes.clear();
5224 self
5225 }
5226}
5227
5228/// Forces a task to run now. When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED. This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now. The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target. If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig. RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed. RunTask cannot be called on a pull task.
5229///
5230/// A builder for the *locations.queues.tasks.run* method supported by a *project* resource.
5231/// It is not used directly, but through a [`ProjectMethods`] instance.
5232///
5233/// # Example
5234///
5235/// Instantiate a resource method builder
5236///
5237/// ```test_harness,no_run
5238/// # extern crate hyper;
5239/// # extern crate hyper_rustls;
5240/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
5241/// use cloudtasks2_beta2::api::RunTaskRequest;
5242/// # async fn dox() {
5243/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5244///
5245/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5246/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5247/// # .with_native_roots()
5248/// # .unwrap()
5249/// # .https_only()
5250/// # .enable_http2()
5251/// # .build();
5252///
5253/// # let executor = hyper_util::rt::TokioExecutor::new();
5254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5255/// # secret,
5256/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5257/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5258/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5259/// # ),
5260/// # ).build().await.unwrap();
5261///
5262/// # let client = hyper_util::client::legacy::Client::builder(
5263/// # hyper_util::rt::TokioExecutor::new()
5264/// # )
5265/// # .build(
5266/// # hyper_rustls::HttpsConnectorBuilder::new()
5267/// # .with_native_roots()
5268/// # .unwrap()
5269/// # .https_or_http()
5270/// # .enable_http2()
5271/// # .build()
5272/// # );
5273/// # let mut hub = CloudTasks::new(client, auth);
5274/// // As the method needs a request, you would usually fill it with the desired information
5275/// // into the respective structure. Some of the parts shown here might not be applicable !
5276/// // Values shown here are possibly random and not representative !
5277/// let mut req = RunTaskRequest::default();
5278///
5279/// // You can configure optional parameters by calling the respective setters at will, and
5280/// // execute the final call using `doit()`.
5281/// // Values shown here are possibly random and not representative !
5282/// let result = hub.projects().locations_queues_tasks_run(req, "name")
5283/// .doit().await;
5284/// # }
5285/// ```
5286pub struct ProjectLocationQueueTaskRunCall<'a, C>
5287where
5288 C: 'a,
5289{
5290 hub: &'a CloudTasks<C>,
5291 _request: RunTaskRequest,
5292 _name: String,
5293 _delegate: Option<&'a mut dyn common::Delegate>,
5294 _additional_params: HashMap<String, String>,
5295 _scopes: BTreeSet<String>,
5296}
5297
5298impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskRunCall<'a, C> {}
5299
5300impl<'a, C> ProjectLocationQueueTaskRunCall<'a, C>
5301where
5302 C: common::Connector,
5303{
5304 /// Perform the operation you have build so far.
5305 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
5306 use std::borrow::Cow;
5307 use std::io::{Read, Seek};
5308
5309 use common::{url::Params, ToParts};
5310 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5311
5312 let mut dd = common::DefaultDelegate;
5313 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5314 dlg.begin(common::MethodInfo {
5315 id: "cloudtasks.projects.locations.queues.tasks.run",
5316 http_method: hyper::Method::POST,
5317 });
5318
5319 for &field in ["alt", "name"].iter() {
5320 if self._additional_params.contains_key(field) {
5321 dlg.finished(false);
5322 return Err(common::Error::FieldClash(field));
5323 }
5324 }
5325
5326 let mut params = Params::with_capacity(4 + self._additional_params.len());
5327 params.push("name", self._name);
5328
5329 params.extend(self._additional_params.iter());
5330
5331 params.push("alt", "json");
5332 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:run";
5333 if self._scopes.is_empty() {
5334 self._scopes
5335 .insert(Scope::CloudPlatform.as_ref().to_string());
5336 }
5337
5338 #[allow(clippy::single_element_loop)]
5339 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5340 url = params.uri_replacement(url, param_name, find_this, true);
5341 }
5342 {
5343 let to_remove = ["name"];
5344 params.remove_params(&to_remove);
5345 }
5346
5347 let url = params.parse_with_url(&url);
5348
5349 let mut json_mime_type = mime::APPLICATION_JSON;
5350 let mut request_value_reader = {
5351 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5352 common::remove_json_null_values(&mut value);
5353 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5354 serde_json::to_writer(&mut dst, &value).unwrap();
5355 dst
5356 };
5357 let request_size = request_value_reader
5358 .seek(std::io::SeekFrom::End(0))
5359 .unwrap();
5360 request_value_reader
5361 .seek(std::io::SeekFrom::Start(0))
5362 .unwrap();
5363
5364 loop {
5365 let token = match self
5366 .hub
5367 .auth
5368 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5369 .await
5370 {
5371 Ok(token) => token,
5372 Err(e) => match dlg.token(e) {
5373 Ok(token) => token,
5374 Err(e) => {
5375 dlg.finished(false);
5376 return Err(common::Error::MissingToken(e));
5377 }
5378 },
5379 };
5380 request_value_reader
5381 .seek(std::io::SeekFrom::Start(0))
5382 .unwrap();
5383 let mut req_result = {
5384 let client = &self.hub.client;
5385 dlg.pre_request();
5386 let mut req_builder = hyper::Request::builder()
5387 .method(hyper::Method::POST)
5388 .uri(url.as_str())
5389 .header(USER_AGENT, self.hub._user_agent.clone());
5390
5391 if let Some(token) = token.as_ref() {
5392 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5393 }
5394
5395 let request = req_builder
5396 .header(CONTENT_TYPE, json_mime_type.to_string())
5397 .header(CONTENT_LENGTH, request_size as u64)
5398 .body(common::to_body(
5399 request_value_reader.get_ref().clone().into(),
5400 ));
5401
5402 client.request(request.unwrap()).await
5403 };
5404
5405 match req_result {
5406 Err(err) => {
5407 if let common::Retry::After(d) = dlg.http_error(&err) {
5408 sleep(d).await;
5409 continue;
5410 }
5411 dlg.finished(false);
5412 return Err(common::Error::HttpError(err));
5413 }
5414 Ok(res) => {
5415 let (mut parts, body) = res.into_parts();
5416 let mut body = common::Body::new(body);
5417 if !parts.status.is_success() {
5418 let bytes = common::to_bytes(body).await.unwrap_or_default();
5419 let error = serde_json::from_str(&common::to_string(&bytes));
5420 let response = common::to_response(parts, bytes.into());
5421
5422 if let common::Retry::After(d) =
5423 dlg.http_failure(&response, error.as_ref().ok())
5424 {
5425 sleep(d).await;
5426 continue;
5427 }
5428
5429 dlg.finished(false);
5430
5431 return Err(match error {
5432 Ok(value) => common::Error::BadRequest(value),
5433 _ => common::Error::Failure(response),
5434 });
5435 }
5436 let response = {
5437 let bytes = common::to_bytes(body).await.unwrap_or_default();
5438 let encoded = common::to_string(&bytes);
5439 match serde_json::from_str(&encoded) {
5440 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5441 Err(error) => {
5442 dlg.response_json_decode_error(&encoded, &error);
5443 return Err(common::Error::JsonDecodeError(
5444 encoded.to_string(),
5445 error,
5446 ));
5447 }
5448 }
5449 };
5450
5451 dlg.finished(true);
5452 return Ok(response);
5453 }
5454 }
5455 }
5456 }
5457
5458 ///
5459 /// Sets the *request* property to the given value.
5460 ///
5461 /// Even though the property as already been set when instantiating this call,
5462 /// we provide this method for API completeness.
5463 pub fn request(mut self, new_value: RunTaskRequest) -> ProjectLocationQueueTaskRunCall<'a, C> {
5464 self._request = new_value;
5465 self
5466 }
5467 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
5468 ///
5469 /// Sets the *name* path property to the given value.
5470 ///
5471 /// Even though the property as already been set when instantiating this call,
5472 /// we provide this method for API completeness.
5473 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskRunCall<'a, C> {
5474 self._name = new_value.to_string();
5475 self
5476 }
5477 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5478 /// while executing the actual API request.
5479 ///
5480 /// ````text
5481 /// It should be used to handle progress information, and to implement a certain level of resilience.
5482 /// ````
5483 ///
5484 /// Sets the *delegate* property to the given value.
5485 pub fn delegate(
5486 mut self,
5487 new_value: &'a mut dyn common::Delegate,
5488 ) -> ProjectLocationQueueTaskRunCall<'a, C> {
5489 self._delegate = Some(new_value);
5490 self
5491 }
5492
5493 /// Set any additional parameter of the query string used in the request.
5494 /// It should be used to set parameters which are not yet available through their own
5495 /// setters.
5496 ///
5497 /// Please note that this method must not be used to set any of the known parameters
5498 /// which have their own setter method. If done anyway, the request will fail.
5499 ///
5500 /// # Additional Parameters
5501 ///
5502 /// * *$.xgafv* (query-string) - V1 error format.
5503 /// * *access_token* (query-string) - OAuth access token.
5504 /// * *alt* (query-string) - Data format for response.
5505 /// * *callback* (query-string) - JSONP
5506 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5507 /// * *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.
5508 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5509 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5510 /// * *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.
5511 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5512 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5513 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskRunCall<'a, C>
5514 where
5515 T: AsRef<str>,
5516 {
5517 self._additional_params
5518 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5519 self
5520 }
5521
5522 /// Identifies the authorization scope for the method you are building.
5523 ///
5524 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5525 /// [`Scope::CloudPlatform`].
5526 ///
5527 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5528 /// tokens for more than one scope.
5529 ///
5530 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5531 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5532 /// sufficient, a read-write scope will do as well.
5533 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskRunCall<'a, C>
5534 where
5535 St: AsRef<str>,
5536 {
5537 self._scopes.insert(String::from(scope.as_ref()));
5538 self
5539 }
5540 /// Identifies the authorization scope(s) for the method you are building.
5541 ///
5542 /// See [`Self::add_scope()`] for details.
5543 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskRunCall<'a, C>
5544 where
5545 I: IntoIterator<Item = St>,
5546 St: AsRef<str>,
5547 {
5548 self._scopes
5549 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5550 self
5551 }
5552
5553 /// Removes all scopes, and no default scope will be used either.
5554 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5555 /// for details).
5556 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskRunCall<'a, C> {
5557 self._scopes.clear();
5558 self
5559 }
5560}
5561
5562/// Creates a queue. Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not. WARNING: Using this method may have unintended side effects if you are using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
5563///
5564/// A builder for the *locations.queues.create* method supported by a *project* resource.
5565/// It is not used directly, but through a [`ProjectMethods`] instance.
5566///
5567/// # Example
5568///
5569/// Instantiate a resource method builder
5570///
5571/// ```test_harness,no_run
5572/// # extern crate hyper;
5573/// # extern crate hyper_rustls;
5574/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
5575/// use cloudtasks2_beta2::api::Queue;
5576/// # async fn dox() {
5577/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5578///
5579/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5580/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5581/// # .with_native_roots()
5582/// # .unwrap()
5583/// # .https_only()
5584/// # .enable_http2()
5585/// # .build();
5586///
5587/// # let executor = hyper_util::rt::TokioExecutor::new();
5588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5589/// # secret,
5590/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5591/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5592/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5593/// # ),
5594/// # ).build().await.unwrap();
5595///
5596/// # let client = hyper_util::client::legacy::Client::builder(
5597/// # hyper_util::rt::TokioExecutor::new()
5598/// # )
5599/// # .build(
5600/// # hyper_rustls::HttpsConnectorBuilder::new()
5601/// # .with_native_roots()
5602/// # .unwrap()
5603/// # .https_or_http()
5604/// # .enable_http2()
5605/// # .build()
5606/// # );
5607/// # let mut hub = CloudTasks::new(client, auth);
5608/// // As the method needs a request, you would usually fill it with the desired information
5609/// // into the respective structure. Some of the parts shown here might not be applicable !
5610/// // Values shown here are possibly random and not representative !
5611/// let mut req = Queue::default();
5612///
5613/// // You can configure optional parameters by calling the respective setters at will, and
5614/// // execute the final call using `doit()`.
5615/// // Values shown here are possibly random and not representative !
5616/// let result = hub.projects().locations_queues_create(req, "parent")
5617/// .doit().await;
5618/// # }
5619/// ```
5620pub struct ProjectLocationQueueCreateCall<'a, C>
5621where
5622 C: 'a,
5623{
5624 hub: &'a CloudTasks<C>,
5625 _request: Queue,
5626 _parent: String,
5627 _delegate: Option<&'a mut dyn common::Delegate>,
5628 _additional_params: HashMap<String, String>,
5629 _scopes: BTreeSet<String>,
5630}
5631
5632impl<'a, C> common::CallBuilder for ProjectLocationQueueCreateCall<'a, C> {}
5633
5634impl<'a, C> ProjectLocationQueueCreateCall<'a, C>
5635where
5636 C: common::Connector,
5637{
5638 /// Perform the operation you have build so far.
5639 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
5640 use std::borrow::Cow;
5641 use std::io::{Read, Seek};
5642
5643 use common::{url::Params, ToParts};
5644 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5645
5646 let mut dd = common::DefaultDelegate;
5647 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5648 dlg.begin(common::MethodInfo {
5649 id: "cloudtasks.projects.locations.queues.create",
5650 http_method: hyper::Method::POST,
5651 });
5652
5653 for &field in ["alt", "parent"].iter() {
5654 if self._additional_params.contains_key(field) {
5655 dlg.finished(false);
5656 return Err(common::Error::FieldClash(field));
5657 }
5658 }
5659
5660 let mut params = Params::with_capacity(4 + self._additional_params.len());
5661 params.push("parent", self._parent);
5662
5663 params.extend(self._additional_params.iter());
5664
5665 params.push("alt", "json");
5666 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/queues";
5667 if self._scopes.is_empty() {
5668 self._scopes
5669 .insert(Scope::CloudPlatform.as_ref().to_string());
5670 }
5671
5672 #[allow(clippy::single_element_loop)]
5673 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5674 url = params.uri_replacement(url, param_name, find_this, true);
5675 }
5676 {
5677 let to_remove = ["parent"];
5678 params.remove_params(&to_remove);
5679 }
5680
5681 let url = params.parse_with_url(&url);
5682
5683 let mut json_mime_type = mime::APPLICATION_JSON;
5684 let mut request_value_reader = {
5685 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5686 common::remove_json_null_values(&mut value);
5687 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5688 serde_json::to_writer(&mut dst, &value).unwrap();
5689 dst
5690 };
5691 let request_size = request_value_reader
5692 .seek(std::io::SeekFrom::End(0))
5693 .unwrap();
5694 request_value_reader
5695 .seek(std::io::SeekFrom::Start(0))
5696 .unwrap();
5697
5698 loop {
5699 let token = match self
5700 .hub
5701 .auth
5702 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5703 .await
5704 {
5705 Ok(token) => token,
5706 Err(e) => match dlg.token(e) {
5707 Ok(token) => token,
5708 Err(e) => {
5709 dlg.finished(false);
5710 return Err(common::Error::MissingToken(e));
5711 }
5712 },
5713 };
5714 request_value_reader
5715 .seek(std::io::SeekFrom::Start(0))
5716 .unwrap();
5717 let mut req_result = {
5718 let client = &self.hub.client;
5719 dlg.pre_request();
5720 let mut req_builder = hyper::Request::builder()
5721 .method(hyper::Method::POST)
5722 .uri(url.as_str())
5723 .header(USER_AGENT, self.hub._user_agent.clone());
5724
5725 if let Some(token) = token.as_ref() {
5726 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5727 }
5728
5729 let request = req_builder
5730 .header(CONTENT_TYPE, json_mime_type.to_string())
5731 .header(CONTENT_LENGTH, request_size as u64)
5732 .body(common::to_body(
5733 request_value_reader.get_ref().clone().into(),
5734 ));
5735
5736 client.request(request.unwrap()).await
5737 };
5738
5739 match req_result {
5740 Err(err) => {
5741 if let common::Retry::After(d) = dlg.http_error(&err) {
5742 sleep(d).await;
5743 continue;
5744 }
5745 dlg.finished(false);
5746 return Err(common::Error::HttpError(err));
5747 }
5748 Ok(res) => {
5749 let (mut parts, body) = res.into_parts();
5750 let mut body = common::Body::new(body);
5751 if !parts.status.is_success() {
5752 let bytes = common::to_bytes(body).await.unwrap_or_default();
5753 let error = serde_json::from_str(&common::to_string(&bytes));
5754 let response = common::to_response(parts, bytes.into());
5755
5756 if let common::Retry::After(d) =
5757 dlg.http_failure(&response, error.as_ref().ok())
5758 {
5759 sleep(d).await;
5760 continue;
5761 }
5762
5763 dlg.finished(false);
5764
5765 return Err(match error {
5766 Ok(value) => common::Error::BadRequest(value),
5767 _ => common::Error::Failure(response),
5768 });
5769 }
5770 let response = {
5771 let bytes = common::to_bytes(body).await.unwrap_or_default();
5772 let encoded = common::to_string(&bytes);
5773 match serde_json::from_str(&encoded) {
5774 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5775 Err(error) => {
5776 dlg.response_json_decode_error(&encoded, &error);
5777 return Err(common::Error::JsonDecodeError(
5778 encoded.to_string(),
5779 error,
5780 ));
5781 }
5782 }
5783 };
5784
5785 dlg.finished(true);
5786 return Ok(response);
5787 }
5788 }
5789 }
5790 }
5791
5792 ///
5793 /// Sets the *request* property to the given value.
5794 ///
5795 /// Even though the property as already been set when instantiating this call,
5796 /// we provide this method for API completeness.
5797 pub fn request(mut self, new_value: Queue) -> ProjectLocationQueueCreateCall<'a, C> {
5798 self._request = new_value;
5799 self
5800 }
5801 /// Required. The location name in which the queue will be created. For example: `projects/PROJECT_ID/locations/LOCATION_ID` The list of allowed locations can be obtained by calling Cloud Tasks' implementation of ListLocations.
5802 ///
5803 /// Sets the *parent* path property to the given value.
5804 ///
5805 /// Even though the property as already been set when instantiating this call,
5806 /// we provide this method for API completeness.
5807 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueCreateCall<'a, C> {
5808 self._parent = new_value.to_string();
5809 self
5810 }
5811 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5812 /// while executing the actual API request.
5813 ///
5814 /// ````text
5815 /// It should be used to handle progress information, and to implement a certain level of resilience.
5816 /// ````
5817 ///
5818 /// Sets the *delegate* property to the given value.
5819 pub fn delegate(
5820 mut self,
5821 new_value: &'a mut dyn common::Delegate,
5822 ) -> ProjectLocationQueueCreateCall<'a, C> {
5823 self._delegate = Some(new_value);
5824 self
5825 }
5826
5827 /// Set any additional parameter of the query string used in the request.
5828 /// It should be used to set parameters which are not yet available through their own
5829 /// setters.
5830 ///
5831 /// Please note that this method must not be used to set any of the known parameters
5832 /// which have their own setter method. If done anyway, the request will fail.
5833 ///
5834 /// # Additional Parameters
5835 ///
5836 /// * *$.xgafv* (query-string) - V1 error format.
5837 /// * *access_token* (query-string) - OAuth access token.
5838 /// * *alt* (query-string) - Data format for response.
5839 /// * *callback* (query-string) - JSONP
5840 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5841 /// * *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.
5842 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5843 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5844 /// * *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.
5845 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5846 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5847 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueCreateCall<'a, C>
5848 where
5849 T: AsRef<str>,
5850 {
5851 self._additional_params
5852 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5853 self
5854 }
5855
5856 /// Identifies the authorization scope for the method you are building.
5857 ///
5858 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5859 /// [`Scope::CloudPlatform`].
5860 ///
5861 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5862 /// tokens for more than one scope.
5863 ///
5864 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5865 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5866 /// sufficient, a read-write scope will do as well.
5867 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueCreateCall<'a, C>
5868 where
5869 St: AsRef<str>,
5870 {
5871 self._scopes.insert(String::from(scope.as_ref()));
5872 self
5873 }
5874 /// Identifies the authorization scope(s) for the method you are building.
5875 ///
5876 /// See [`Self::add_scope()`] for details.
5877 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueCreateCall<'a, C>
5878 where
5879 I: IntoIterator<Item = St>,
5880 St: AsRef<str>,
5881 {
5882 self._scopes
5883 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5884 self
5885 }
5886
5887 /// Removes all scopes, and no default scope will be used either.
5888 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5889 /// for details).
5890 pub fn clear_scopes(mut self) -> ProjectLocationQueueCreateCall<'a, C> {
5891 self._scopes.clear();
5892 self
5893 }
5894}
5895
5896/// Deletes a queue. This command will delete the queue even if it has tasks in it. Note: If you delete a queue, you may be prevented from creating a new queue with the same name as the deleted queue for a tombstone window of up to 3 days. During this window, the CreateQueue operation may appear to recreate the queue, but this can be misleading. If you attempt to create a queue with the same name as one that is in the tombstone window, run GetQueue to confirm that the queue creation was successful. If GetQueue returns 200 response code, your queue was successfully created with the name of the previously deleted queue. Otherwise, your queue did not successfully recreate. WARNING: Using this method may have unintended side effects if you are using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
5897///
5898/// A builder for the *locations.queues.delete* method supported by a *project* resource.
5899/// It is not used directly, but through a [`ProjectMethods`] instance.
5900///
5901/// # Example
5902///
5903/// Instantiate a resource method builder
5904///
5905/// ```test_harness,no_run
5906/// # extern crate hyper;
5907/// # extern crate hyper_rustls;
5908/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
5909/// # async fn dox() {
5910/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5911///
5912/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5913/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5914/// # .with_native_roots()
5915/// # .unwrap()
5916/// # .https_only()
5917/// # .enable_http2()
5918/// # .build();
5919///
5920/// # let executor = hyper_util::rt::TokioExecutor::new();
5921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5922/// # secret,
5923/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5924/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5925/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5926/// # ),
5927/// # ).build().await.unwrap();
5928///
5929/// # let client = hyper_util::client::legacy::Client::builder(
5930/// # hyper_util::rt::TokioExecutor::new()
5931/// # )
5932/// # .build(
5933/// # hyper_rustls::HttpsConnectorBuilder::new()
5934/// # .with_native_roots()
5935/// # .unwrap()
5936/// # .https_or_http()
5937/// # .enable_http2()
5938/// # .build()
5939/// # );
5940/// # let mut hub = CloudTasks::new(client, auth);
5941/// // You can configure optional parameters by calling the respective setters at will, and
5942/// // execute the final call using `doit()`.
5943/// // Values shown here are possibly random and not representative !
5944/// let result = hub.projects().locations_queues_delete("name")
5945/// .doit().await;
5946/// # }
5947/// ```
5948pub struct ProjectLocationQueueDeleteCall<'a, C>
5949where
5950 C: 'a,
5951{
5952 hub: &'a CloudTasks<C>,
5953 _name: String,
5954 _delegate: Option<&'a mut dyn common::Delegate>,
5955 _additional_params: HashMap<String, String>,
5956 _scopes: BTreeSet<String>,
5957}
5958
5959impl<'a, C> common::CallBuilder for ProjectLocationQueueDeleteCall<'a, C> {}
5960
5961impl<'a, C> ProjectLocationQueueDeleteCall<'a, C>
5962where
5963 C: common::Connector,
5964{
5965 /// Perform the operation you have build so far.
5966 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5967 use std::borrow::Cow;
5968 use std::io::{Read, Seek};
5969
5970 use common::{url::Params, ToParts};
5971 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5972
5973 let mut dd = common::DefaultDelegate;
5974 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5975 dlg.begin(common::MethodInfo {
5976 id: "cloudtasks.projects.locations.queues.delete",
5977 http_method: hyper::Method::DELETE,
5978 });
5979
5980 for &field in ["alt", "name"].iter() {
5981 if self._additional_params.contains_key(field) {
5982 dlg.finished(false);
5983 return Err(common::Error::FieldClash(field));
5984 }
5985 }
5986
5987 let mut params = Params::with_capacity(3 + self._additional_params.len());
5988 params.push("name", self._name);
5989
5990 params.extend(self._additional_params.iter());
5991
5992 params.push("alt", "json");
5993 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
5994 if self._scopes.is_empty() {
5995 self._scopes
5996 .insert(Scope::CloudPlatform.as_ref().to_string());
5997 }
5998
5999 #[allow(clippy::single_element_loop)]
6000 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6001 url = params.uri_replacement(url, param_name, find_this, true);
6002 }
6003 {
6004 let to_remove = ["name"];
6005 params.remove_params(&to_remove);
6006 }
6007
6008 let url = params.parse_with_url(&url);
6009
6010 loop {
6011 let token = match self
6012 .hub
6013 .auth
6014 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6015 .await
6016 {
6017 Ok(token) => token,
6018 Err(e) => match dlg.token(e) {
6019 Ok(token) => token,
6020 Err(e) => {
6021 dlg.finished(false);
6022 return Err(common::Error::MissingToken(e));
6023 }
6024 },
6025 };
6026 let mut req_result = {
6027 let client = &self.hub.client;
6028 dlg.pre_request();
6029 let mut req_builder = hyper::Request::builder()
6030 .method(hyper::Method::DELETE)
6031 .uri(url.as_str())
6032 .header(USER_AGENT, self.hub._user_agent.clone());
6033
6034 if let Some(token) = token.as_ref() {
6035 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6036 }
6037
6038 let request = req_builder
6039 .header(CONTENT_LENGTH, 0_u64)
6040 .body(common::to_body::<String>(None));
6041
6042 client.request(request.unwrap()).await
6043 };
6044
6045 match req_result {
6046 Err(err) => {
6047 if let common::Retry::After(d) = dlg.http_error(&err) {
6048 sleep(d).await;
6049 continue;
6050 }
6051 dlg.finished(false);
6052 return Err(common::Error::HttpError(err));
6053 }
6054 Ok(res) => {
6055 let (mut parts, body) = res.into_parts();
6056 let mut body = common::Body::new(body);
6057 if !parts.status.is_success() {
6058 let bytes = common::to_bytes(body).await.unwrap_or_default();
6059 let error = serde_json::from_str(&common::to_string(&bytes));
6060 let response = common::to_response(parts, bytes.into());
6061
6062 if let common::Retry::After(d) =
6063 dlg.http_failure(&response, error.as_ref().ok())
6064 {
6065 sleep(d).await;
6066 continue;
6067 }
6068
6069 dlg.finished(false);
6070
6071 return Err(match error {
6072 Ok(value) => common::Error::BadRequest(value),
6073 _ => common::Error::Failure(response),
6074 });
6075 }
6076 let response = {
6077 let bytes = common::to_bytes(body).await.unwrap_or_default();
6078 let encoded = common::to_string(&bytes);
6079 match serde_json::from_str(&encoded) {
6080 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6081 Err(error) => {
6082 dlg.response_json_decode_error(&encoded, &error);
6083 return Err(common::Error::JsonDecodeError(
6084 encoded.to_string(),
6085 error,
6086 ));
6087 }
6088 }
6089 };
6090
6091 dlg.finished(true);
6092 return Ok(response);
6093 }
6094 }
6095 }
6096 }
6097
6098 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
6099 ///
6100 /// Sets the *name* path property to the given value.
6101 ///
6102 /// Even though the property as already been set when instantiating this call,
6103 /// we provide this method for API completeness.
6104 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueDeleteCall<'a, C> {
6105 self._name = new_value.to_string();
6106 self
6107 }
6108 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6109 /// while executing the actual API request.
6110 ///
6111 /// ````text
6112 /// It should be used to handle progress information, and to implement a certain level of resilience.
6113 /// ````
6114 ///
6115 /// Sets the *delegate* property to the given value.
6116 pub fn delegate(
6117 mut self,
6118 new_value: &'a mut dyn common::Delegate,
6119 ) -> ProjectLocationQueueDeleteCall<'a, C> {
6120 self._delegate = Some(new_value);
6121 self
6122 }
6123
6124 /// Set any additional parameter of the query string used in the request.
6125 /// It should be used to set parameters which are not yet available through their own
6126 /// setters.
6127 ///
6128 /// Please note that this method must not be used to set any of the known parameters
6129 /// which have their own setter method. If done anyway, the request will fail.
6130 ///
6131 /// # Additional Parameters
6132 ///
6133 /// * *$.xgafv* (query-string) - V1 error format.
6134 /// * *access_token* (query-string) - OAuth access token.
6135 /// * *alt* (query-string) - Data format for response.
6136 /// * *callback* (query-string) - JSONP
6137 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6138 /// * *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.
6139 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6140 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6141 /// * *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.
6142 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6143 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6144 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueDeleteCall<'a, C>
6145 where
6146 T: AsRef<str>,
6147 {
6148 self._additional_params
6149 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6150 self
6151 }
6152
6153 /// Identifies the authorization scope for the method you are building.
6154 ///
6155 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6156 /// [`Scope::CloudPlatform`].
6157 ///
6158 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6159 /// tokens for more than one scope.
6160 ///
6161 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6162 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6163 /// sufficient, a read-write scope will do as well.
6164 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueDeleteCall<'a, C>
6165 where
6166 St: AsRef<str>,
6167 {
6168 self._scopes.insert(String::from(scope.as_ref()));
6169 self
6170 }
6171 /// Identifies the authorization scope(s) for the method you are building.
6172 ///
6173 /// See [`Self::add_scope()`] for details.
6174 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueDeleteCall<'a, C>
6175 where
6176 I: IntoIterator<Item = St>,
6177 St: AsRef<str>,
6178 {
6179 self._scopes
6180 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6181 self
6182 }
6183
6184 /// Removes all scopes, and no default scope will be used either.
6185 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6186 /// for details).
6187 pub fn clear_scopes(mut self) -> ProjectLocationQueueDeleteCall<'a, C> {
6188 self._scopes.clear();
6189 self
6190 }
6191}
6192
6193/// Gets a queue.
6194///
6195/// A builder for the *locations.queues.get* method supported by a *project* resource.
6196/// It is not used directly, but through a [`ProjectMethods`] instance.
6197///
6198/// # Example
6199///
6200/// Instantiate a resource method builder
6201///
6202/// ```test_harness,no_run
6203/// # extern crate hyper;
6204/// # extern crate hyper_rustls;
6205/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6206/// # async fn dox() {
6207/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6208///
6209/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6210/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6211/// # .with_native_roots()
6212/// # .unwrap()
6213/// # .https_only()
6214/// # .enable_http2()
6215/// # .build();
6216///
6217/// # let executor = hyper_util::rt::TokioExecutor::new();
6218/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6219/// # secret,
6220/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6221/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6222/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6223/// # ),
6224/// # ).build().await.unwrap();
6225///
6226/// # let client = hyper_util::client::legacy::Client::builder(
6227/// # hyper_util::rt::TokioExecutor::new()
6228/// # )
6229/// # .build(
6230/// # hyper_rustls::HttpsConnectorBuilder::new()
6231/// # .with_native_roots()
6232/// # .unwrap()
6233/// # .https_or_http()
6234/// # .enable_http2()
6235/// # .build()
6236/// # );
6237/// # let mut hub = CloudTasks::new(client, auth);
6238/// // You can configure optional parameters by calling the respective setters at will, and
6239/// // execute the final call using `doit()`.
6240/// // Values shown here are possibly random and not representative !
6241/// let result = hub.projects().locations_queues_get("name")
6242/// .read_mask(FieldMask::new::<&str>(&[]))
6243/// .doit().await;
6244/// # }
6245/// ```
6246pub struct ProjectLocationQueueGetCall<'a, C>
6247where
6248 C: 'a,
6249{
6250 hub: &'a CloudTasks<C>,
6251 _name: String,
6252 _read_mask: Option<common::FieldMask>,
6253 _delegate: Option<&'a mut dyn common::Delegate>,
6254 _additional_params: HashMap<String, String>,
6255 _scopes: BTreeSet<String>,
6256}
6257
6258impl<'a, C> common::CallBuilder for ProjectLocationQueueGetCall<'a, C> {}
6259
6260impl<'a, C> ProjectLocationQueueGetCall<'a, C>
6261where
6262 C: common::Connector,
6263{
6264 /// Perform the operation you have build so far.
6265 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
6266 use std::borrow::Cow;
6267 use std::io::{Read, Seek};
6268
6269 use common::{url::Params, ToParts};
6270 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6271
6272 let mut dd = common::DefaultDelegate;
6273 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6274 dlg.begin(common::MethodInfo {
6275 id: "cloudtasks.projects.locations.queues.get",
6276 http_method: hyper::Method::GET,
6277 });
6278
6279 for &field in ["alt", "name", "readMask"].iter() {
6280 if self._additional_params.contains_key(field) {
6281 dlg.finished(false);
6282 return Err(common::Error::FieldClash(field));
6283 }
6284 }
6285
6286 let mut params = Params::with_capacity(4 + self._additional_params.len());
6287 params.push("name", self._name);
6288 if let Some(value) = self._read_mask.as_ref() {
6289 params.push("readMask", value.to_string());
6290 }
6291
6292 params.extend(self._additional_params.iter());
6293
6294 params.push("alt", "json");
6295 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
6296 if self._scopes.is_empty() {
6297 self._scopes
6298 .insert(Scope::CloudPlatform.as_ref().to_string());
6299 }
6300
6301 #[allow(clippy::single_element_loop)]
6302 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6303 url = params.uri_replacement(url, param_name, find_this, true);
6304 }
6305 {
6306 let to_remove = ["name"];
6307 params.remove_params(&to_remove);
6308 }
6309
6310 let url = params.parse_with_url(&url);
6311
6312 loop {
6313 let token = match self
6314 .hub
6315 .auth
6316 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6317 .await
6318 {
6319 Ok(token) => token,
6320 Err(e) => match dlg.token(e) {
6321 Ok(token) => token,
6322 Err(e) => {
6323 dlg.finished(false);
6324 return Err(common::Error::MissingToken(e));
6325 }
6326 },
6327 };
6328 let mut req_result = {
6329 let client = &self.hub.client;
6330 dlg.pre_request();
6331 let mut req_builder = hyper::Request::builder()
6332 .method(hyper::Method::GET)
6333 .uri(url.as_str())
6334 .header(USER_AGENT, self.hub._user_agent.clone());
6335
6336 if let Some(token) = token.as_ref() {
6337 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6338 }
6339
6340 let request = req_builder
6341 .header(CONTENT_LENGTH, 0_u64)
6342 .body(common::to_body::<String>(None));
6343
6344 client.request(request.unwrap()).await
6345 };
6346
6347 match req_result {
6348 Err(err) => {
6349 if let common::Retry::After(d) = dlg.http_error(&err) {
6350 sleep(d).await;
6351 continue;
6352 }
6353 dlg.finished(false);
6354 return Err(common::Error::HttpError(err));
6355 }
6356 Ok(res) => {
6357 let (mut parts, body) = res.into_parts();
6358 let mut body = common::Body::new(body);
6359 if !parts.status.is_success() {
6360 let bytes = common::to_bytes(body).await.unwrap_or_default();
6361 let error = serde_json::from_str(&common::to_string(&bytes));
6362 let response = common::to_response(parts, bytes.into());
6363
6364 if let common::Retry::After(d) =
6365 dlg.http_failure(&response, error.as_ref().ok())
6366 {
6367 sleep(d).await;
6368 continue;
6369 }
6370
6371 dlg.finished(false);
6372
6373 return Err(match error {
6374 Ok(value) => common::Error::BadRequest(value),
6375 _ => common::Error::Failure(response),
6376 });
6377 }
6378 let response = {
6379 let bytes = common::to_bytes(body).await.unwrap_or_default();
6380 let encoded = common::to_string(&bytes);
6381 match serde_json::from_str(&encoded) {
6382 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6383 Err(error) => {
6384 dlg.response_json_decode_error(&encoded, &error);
6385 return Err(common::Error::JsonDecodeError(
6386 encoded.to_string(),
6387 error,
6388 ));
6389 }
6390 }
6391 };
6392
6393 dlg.finished(true);
6394 return Ok(response);
6395 }
6396 }
6397 }
6398 }
6399
6400 /// Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
6401 ///
6402 /// Sets the *name* path property to the given value.
6403 ///
6404 /// Even though the property as already been set when instantiating this call,
6405 /// we provide this method for API completeness.
6406 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueGetCall<'a, C> {
6407 self._name = new_value.to_string();
6408 self
6409 }
6410 /// Optional. Read mask is used for a more granular control over what the API returns. If the mask is not present all fields will be returned except [Queue.stats]. [Queue.stats] will be returned only if it was explicitly specified in the mask.
6411 ///
6412 /// Sets the *read mask* query property to the given value.
6413 pub fn read_mask(mut self, new_value: common::FieldMask) -> ProjectLocationQueueGetCall<'a, C> {
6414 self._read_mask = Some(new_value);
6415 self
6416 }
6417 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6418 /// while executing the actual API request.
6419 ///
6420 /// ````text
6421 /// It should be used to handle progress information, and to implement a certain level of resilience.
6422 /// ````
6423 ///
6424 /// Sets the *delegate* property to the given value.
6425 pub fn delegate(
6426 mut self,
6427 new_value: &'a mut dyn common::Delegate,
6428 ) -> ProjectLocationQueueGetCall<'a, C> {
6429 self._delegate = Some(new_value);
6430 self
6431 }
6432
6433 /// Set any additional parameter of the query string used in the request.
6434 /// It should be used to set parameters which are not yet available through their own
6435 /// setters.
6436 ///
6437 /// Please note that this method must not be used to set any of the known parameters
6438 /// which have their own setter method. If done anyway, the request will fail.
6439 ///
6440 /// # Additional Parameters
6441 ///
6442 /// * *$.xgafv* (query-string) - V1 error format.
6443 /// * *access_token* (query-string) - OAuth access token.
6444 /// * *alt* (query-string) - Data format for response.
6445 /// * *callback* (query-string) - JSONP
6446 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6447 /// * *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.
6448 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6449 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6450 /// * *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.
6451 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6452 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6453 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueGetCall<'a, C>
6454 where
6455 T: AsRef<str>,
6456 {
6457 self._additional_params
6458 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6459 self
6460 }
6461
6462 /// Identifies the authorization scope for the method you are building.
6463 ///
6464 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6465 /// [`Scope::CloudPlatform`].
6466 ///
6467 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6468 /// tokens for more than one scope.
6469 ///
6470 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6471 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6472 /// sufficient, a read-write scope will do as well.
6473 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueGetCall<'a, C>
6474 where
6475 St: AsRef<str>,
6476 {
6477 self._scopes.insert(String::from(scope.as_ref()));
6478 self
6479 }
6480 /// Identifies the authorization scope(s) for the method you are building.
6481 ///
6482 /// See [`Self::add_scope()`] for details.
6483 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueGetCall<'a, C>
6484 where
6485 I: IntoIterator<Item = St>,
6486 St: AsRef<str>,
6487 {
6488 self._scopes
6489 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6490 self
6491 }
6492
6493 /// Removes all scopes, and no default scope will be used either.
6494 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6495 /// for details).
6496 pub fn clear_scopes(mut self) -> ProjectLocationQueueGetCall<'a, C> {
6497 self._scopes.clear();
6498 self
6499 }
6500}
6501
6502/// Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set. Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the specified resource parent: * `cloudtasks.queues.getIamPolicy`
6503///
6504/// A builder for the *locations.queues.getIamPolicy* method supported by a *project* resource.
6505/// It is not used directly, but through a [`ProjectMethods`] instance.
6506///
6507/// # Example
6508///
6509/// Instantiate a resource method builder
6510///
6511/// ```test_harness,no_run
6512/// # extern crate hyper;
6513/// # extern crate hyper_rustls;
6514/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6515/// use cloudtasks2_beta2::api::GetIamPolicyRequest;
6516/// # async fn dox() {
6517/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6518///
6519/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6520/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6521/// # .with_native_roots()
6522/// # .unwrap()
6523/// # .https_only()
6524/// # .enable_http2()
6525/// # .build();
6526///
6527/// # let executor = hyper_util::rt::TokioExecutor::new();
6528/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6529/// # secret,
6530/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6531/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6532/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6533/// # ),
6534/// # ).build().await.unwrap();
6535///
6536/// # let client = hyper_util::client::legacy::Client::builder(
6537/// # hyper_util::rt::TokioExecutor::new()
6538/// # )
6539/// # .build(
6540/// # hyper_rustls::HttpsConnectorBuilder::new()
6541/// # .with_native_roots()
6542/// # .unwrap()
6543/// # .https_or_http()
6544/// # .enable_http2()
6545/// # .build()
6546/// # );
6547/// # let mut hub = CloudTasks::new(client, auth);
6548/// // As the method needs a request, you would usually fill it with the desired information
6549/// // into the respective structure. Some of the parts shown here might not be applicable !
6550/// // Values shown here are possibly random and not representative !
6551/// let mut req = GetIamPolicyRequest::default();
6552///
6553/// // You can configure optional parameters by calling the respective setters at will, and
6554/// // execute the final call using `doit()`.
6555/// // Values shown here are possibly random and not representative !
6556/// let result = hub.projects().locations_queues_get_iam_policy(req, "resource")
6557/// .doit().await;
6558/// # }
6559/// ```
6560pub struct ProjectLocationQueueGetIamPolicyCall<'a, C>
6561where
6562 C: 'a,
6563{
6564 hub: &'a CloudTasks<C>,
6565 _request: GetIamPolicyRequest,
6566 _resource: String,
6567 _delegate: Option<&'a mut dyn common::Delegate>,
6568 _additional_params: HashMap<String, String>,
6569 _scopes: BTreeSet<String>,
6570}
6571
6572impl<'a, C> common::CallBuilder for ProjectLocationQueueGetIamPolicyCall<'a, C> {}
6573
6574impl<'a, C> ProjectLocationQueueGetIamPolicyCall<'a, C>
6575where
6576 C: common::Connector,
6577{
6578 /// Perform the operation you have build so far.
6579 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6580 use std::borrow::Cow;
6581 use std::io::{Read, Seek};
6582
6583 use common::{url::Params, ToParts};
6584 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6585
6586 let mut dd = common::DefaultDelegate;
6587 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6588 dlg.begin(common::MethodInfo {
6589 id: "cloudtasks.projects.locations.queues.getIamPolicy",
6590 http_method: hyper::Method::POST,
6591 });
6592
6593 for &field in ["alt", "resource"].iter() {
6594 if self._additional_params.contains_key(field) {
6595 dlg.finished(false);
6596 return Err(common::Error::FieldClash(field));
6597 }
6598 }
6599
6600 let mut params = Params::with_capacity(4 + self._additional_params.len());
6601 params.push("resource", self._resource);
6602
6603 params.extend(self._additional_params.iter());
6604
6605 params.push("alt", "json");
6606 let mut url = self.hub._base_url.clone() + "v2beta2/{+resource}:getIamPolicy";
6607 if self._scopes.is_empty() {
6608 self._scopes
6609 .insert(Scope::CloudPlatform.as_ref().to_string());
6610 }
6611
6612 #[allow(clippy::single_element_loop)]
6613 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6614 url = params.uri_replacement(url, param_name, find_this, true);
6615 }
6616 {
6617 let to_remove = ["resource"];
6618 params.remove_params(&to_remove);
6619 }
6620
6621 let url = params.parse_with_url(&url);
6622
6623 let mut json_mime_type = mime::APPLICATION_JSON;
6624 let mut request_value_reader = {
6625 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6626 common::remove_json_null_values(&mut value);
6627 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6628 serde_json::to_writer(&mut dst, &value).unwrap();
6629 dst
6630 };
6631 let request_size = request_value_reader
6632 .seek(std::io::SeekFrom::End(0))
6633 .unwrap();
6634 request_value_reader
6635 .seek(std::io::SeekFrom::Start(0))
6636 .unwrap();
6637
6638 loop {
6639 let token = match self
6640 .hub
6641 .auth
6642 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6643 .await
6644 {
6645 Ok(token) => token,
6646 Err(e) => match dlg.token(e) {
6647 Ok(token) => token,
6648 Err(e) => {
6649 dlg.finished(false);
6650 return Err(common::Error::MissingToken(e));
6651 }
6652 },
6653 };
6654 request_value_reader
6655 .seek(std::io::SeekFrom::Start(0))
6656 .unwrap();
6657 let mut req_result = {
6658 let client = &self.hub.client;
6659 dlg.pre_request();
6660 let mut req_builder = hyper::Request::builder()
6661 .method(hyper::Method::POST)
6662 .uri(url.as_str())
6663 .header(USER_AGENT, self.hub._user_agent.clone());
6664
6665 if let Some(token) = token.as_ref() {
6666 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6667 }
6668
6669 let request = req_builder
6670 .header(CONTENT_TYPE, json_mime_type.to_string())
6671 .header(CONTENT_LENGTH, request_size as u64)
6672 .body(common::to_body(
6673 request_value_reader.get_ref().clone().into(),
6674 ));
6675
6676 client.request(request.unwrap()).await
6677 };
6678
6679 match req_result {
6680 Err(err) => {
6681 if let common::Retry::After(d) = dlg.http_error(&err) {
6682 sleep(d).await;
6683 continue;
6684 }
6685 dlg.finished(false);
6686 return Err(common::Error::HttpError(err));
6687 }
6688 Ok(res) => {
6689 let (mut parts, body) = res.into_parts();
6690 let mut body = common::Body::new(body);
6691 if !parts.status.is_success() {
6692 let bytes = common::to_bytes(body).await.unwrap_or_default();
6693 let error = serde_json::from_str(&common::to_string(&bytes));
6694 let response = common::to_response(parts, bytes.into());
6695
6696 if let common::Retry::After(d) =
6697 dlg.http_failure(&response, error.as_ref().ok())
6698 {
6699 sleep(d).await;
6700 continue;
6701 }
6702
6703 dlg.finished(false);
6704
6705 return Err(match error {
6706 Ok(value) => common::Error::BadRequest(value),
6707 _ => common::Error::Failure(response),
6708 });
6709 }
6710 let response = {
6711 let bytes = common::to_bytes(body).await.unwrap_or_default();
6712 let encoded = common::to_string(&bytes);
6713 match serde_json::from_str(&encoded) {
6714 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6715 Err(error) => {
6716 dlg.response_json_decode_error(&encoded, &error);
6717 return Err(common::Error::JsonDecodeError(
6718 encoded.to_string(),
6719 error,
6720 ));
6721 }
6722 }
6723 };
6724
6725 dlg.finished(true);
6726 return Ok(response);
6727 }
6728 }
6729 }
6730 }
6731
6732 ///
6733 /// Sets the *request* property to the given value.
6734 ///
6735 /// Even though the property as already been set when instantiating this call,
6736 /// we provide this method for API completeness.
6737 pub fn request(
6738 mut self,
6739 new_value: GetIamPolicyRequest,
6740 ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6741 self._request = new_value;
6742 self
6743 }
6744 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6745 ///
6746 /// Sets the *resource* path property to the given value.
6747 ///
6748 /// Even though the property as already been set when instantiating this call,
6749 /// we provide this method for API completeness.
6750 pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6751 self._resource = new_value.to_string();
6752 self
6753 }
6754 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6755 /// while executing the actual API request.
6756 ///
6757 /// ````text
6758 /// It should be used to handle progress information, and to implement a certain level of resilience.
6759 /// ````
6760 ///
6761 /// Sets the *delegate* property to the given value.
6762 pub fn delegate(
6763 mut self,
6764 new_value: &'a mut dyn common::Delegate,
6765 ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6766 self._delegate = Some(new_value);
6767 self
6768 }
6769
6770 /// Set any additional parameter of the query string used in the request.
6771 /// It should be used to set parameters which are not yet available through their own
6772 /// setters.
6773 ///
6774 /// Please note that this method must not be used to set any of the known parameters
6775 /// which have their own setter method. If done anyway, the request will fail.
6776 ///
6777 /// # Additional Parameters
6778 ///
6779 /// * *$.xgafv* (query-string) - V1 error format.
6780 /// * *access_token* (query-string) - OAuth access token.
6781 /// * *alt* (query-string) - Data format for response.
6782 /// * *callback* (query-string) - JSONP
6783 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6784 /// * *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.
6785 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6786 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6787 /// * *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.
6788 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6789 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6790 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
6791 where
6792 T: AsRef<str>,
6793 {
6794 self._additional_params
6795 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6796 self
6797 }
6798
6799 /// Identifies the authorization scope for the method you are building.
6800 ///
6801 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6802 /// [`Scope::CloudPlatform`].
6803 ///
6804 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6805 /// tokens for more than one scope.
6806 ///
6807 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6808 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6809 /// sufficient, a read-write scope will do as well.
6810 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
6811 where
6812 St: AsRef<str>,
6813 {
6814 self._scopes.insert(String::from(scope.as_ref()));
6815 self
6816 }
6817 /// Identifies the authorization scope(s) for the method you are building.
6818 ///
6819 /// See [`Self::add_scope()`] for details.
6820 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
6821 where
6822 I: IntoIterator<Item = St>,
6823 St: AsRef<str>,
6824 {
6825 self._scopes
6826 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6827 self
6828 }
6829
6830 /// Removes all scopes, and no default scope will be used either.
6831 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6832 /// for details).
6833 pub fn clear_scopes(mut self) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6834 self._scopes.clear();
6835 self
6836 }
6837}
6838
6839/// Lists queues. Queues are returned in lexicographical order.
6840///
6841/// A builder for the *locations.queues.list* method supported by a *project* resource.
6842/// It is not used directly, but through a [`ProjectMethods`] instance.
6843///
6844/// # Example
6845///
6846/// Instantiate a resource method builder
6847///
6848/// ```test_harness,no_run
6849/// # extern crate hyper;
6850/// # extern crate hyper_rustls;
6851/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6852/// # async fn dox() {
6853/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6854///
6855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6856/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6857/// # .with_native_roots()
6858/// # .unwrap()
6859/// # .https_only()
6860/// # .enable_http2()
6861/// # .build();
6862///
6863/// # let executor = hyper_util::rt::TokioExecutor::new();
6864/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6865/// # secret,
6866/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6867/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6868/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6869/// # ),
6870/// # ).build().await.unwrap();
6871///
6872/// # let client = hyper_util::client::legacy::Client::builder(
6873/// # hyper_util::rt::TokioExecutor::new()
6874/// # )
6875/// # .build(
6876/// # hyper_rustls::HttpsConnectorBuilder::new()
6877/// # .with_native_roots()
6878/// # .unwrap()
6879/// # .https_or_http()
6880/// # .enable_http2()
6881/// # .build()
6882/// # );
6883/// # let mut hub = CloudTasks::new(client, auth);
6884/// // You can configure optional parameters by calling the respective setters at will, and
6885/// // execute the final call using `doit()`.
6886/// // Values shown here are possibly random and not representative !
6887/// let result = hub.projects().locations_queues_list("parent")
6888/// .read_mask(FieldMask::new::<&str>(&[]))
6889/// .page_token("sed")
6890/// .page_size(-37)
6891/// .filter("gubergren")
6892/// .doit().await;
6893/// # }
6894/// ```
6895pub struct ProjectLocationQueueListCall<'a, C>
6896where
6897 C: 'a,
6898{
6899 hub: &'a CloudTasks<C>,
6900 _parent: String,
6901 _read_mask: Option<common::FieldMask>,
6902 _page_token: Option<String>,
6903 _page_size: Option<i32>,
6904 _filter: Option<String>,
6905 _delegate: Option<&'a mut dyn common::Delegate>,
6906 _additional_params: HashMap<String, String>,
6907 _scopes: BTreeSet<String>,
6908}
6909
6910impl<'a, C> common::CallBuilder for ProjectLocationQueueListCall<'a, C> {}
6911
6912impl<'a, C> ProjectLocationQueueListCall<'a, C>
6913where
6914 C: common::Connector,
6915{
6916 /// Perform the operation you have build so far.
6917 pub async fn doit(mut self) -> common::Result<(common::Response, ListQueuesResponse)> {
6918 use std::borrow::Cow;
6919 use std::io::{Read, Seek};
6920
6921 use common::{url::Params, ToParts};
6922 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6923
6924 let mut dd = common::DefaultDelegate;
6925 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6926 dlg.begin(common::MethodInfo {
6927 id: "cloudtasks.projects.locations.queues.list",
6928 http_method: hyper::Method::GET,
6929 });
6930
6931 for &field in [
6932 "alt",
6933 "parent",
6934 "readMask",
6935 "pageToken",
6936 "pageSize",
6937 "filter",
6938 ]
6939 .iter()
6940 {
6941 if self._additional_params.contains_key(field) {
6942 dlg.finished(false);
6943 return Err(common::Error::FieldClash(field));
6944 }
6945 }
6946
6947 let mut params = Params::with_capacity(7 + self._additional_params.len());
6948 params.push("parent", self._parent);
6949 if let Some(value) = self._read_mask.as_ref() {
6950 params.push("readMask", value.to_string());
6951 }
6952 if let Some(value) = self._page_token.as_ref() {
6953 params.push("pageToken", value);
6954 }
6955 if let Some(value) = self._page_size.as_ref() {
6956 params.push("pageSize", value.to_string());
6957 }
6958 if let Some(value) = self._filter.as_ref() {
6959 params.push("filter", value);
6960 }
6961
6962 params.extend(self._additional_params.iter());
6963
6964 params.push("alt", "json");
6965 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/queues";
6966 if self._scopes.is_empty() {
6967 self._scopes
6968 .insert(Scope::CloudPlatform.as_ref().to_string());
6969 }
6970
6971 #[allow(clippy::single_element_loop)]
6972 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6973 url = params.uri_replacement(url, param_name, find_this, true);
6974 }
6975 {
6976 let to_remove = ["parent"];
6977 params.remove_params(&to_remove);
6978 }
6979
6980 let url = params.parse_with_url(&url);
6981
6982 loop {
6983 let token = match self
6984 .hub
6985 .auth
6986 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6987 .await
6988 {
6989 Ok(token) => token,
6990 Err(e) => match dlg.token(e) {
6991 Ok(token) => token,
6992 Err(e) => {
6993 dlg.finished(false);
6994 return Err(common::Error::MissingToken(e));
6995 }
6996 },
6997 };
6998 let mut req_result = {
6999 let client = &self.hub.client;
7000 dlg.pre_request();
7001 let mut req_builder = hyper::Request::builder()
7002 .method(hyper::Method::GET)
7003 .uri(url.as_str())
7004 .header(USER_AGENT, self.hub._user_agent.clone());
7005
7006 if let Some(token) = token.as_ref() {
7007 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7008 }
7009
7010 let request = req_builder
7011 .header(CONTENT_LENGTH, 0_u64)
7012 .body(common::to_body::<String>(None));
7013
7014 client.request(request.unwrap()).await
7015 };
7016
7017 match req_result {
7018 Err(err) => {
7019 if let common::Retry::After(d) = dlg.http_error(&err) {
7020 sleep(d).await;
7021 continue;
7022 }
7023 dlg.finished(false);
7024 return Err(common::Error::HttpError(err));
7025 }
7026 Ok(res) => {
7027 let (mut parts, body) = res.into_parts();
7028 let mut body = common::Body::new(body);
7029 if !parts.status.is_success() {
7030 let bytes = common::to_bytes(body).await.unwrap_or_default();
7031 let error = serde_json::from_str(&common::to_string(&bytes));
7032 let response = common::to_response(parts, bytes.into());
7033
7034 if let common::Retry::After(d) =
7035 dlg.http_failure(&response, error.as_ref().ok())
7036 {
7037 sleep(d).await;
7038 continue;
7039 }
7040
7041 dlg.finished(false);
7042
7043 return Err(match error {
7044 Ok(value) => common::Error::BadRequest(value),
7045 _ => common::Error::Failure(response),
7046 });
7047 }
7048 let response = {
7049 let bytes = common::to_bytes(body).await.unwrap_or_default();
7050 let encoded = common::to_string(&bytes);
7051 match serde_json::from_str(&encoded) {
7052 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7053 Err(error) => {
7054 dlg.response_json_decode_error(&encoded, &error);
7055 return Err(common::Error::JsonDecodeError(
7056 encoded.to_string(),
7057 error,
7058 ));
7059 }
7060 }
7061 };
7062
7063 dlg.finished(true);
7064 return Ok(response);
7065 }
7066 }
7067 }
7068 }
7069
7070 /// Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`
7071 ///
7072 /// Sets the *parent* path property to the given value.
7073 ///
7074 /// Even though the property as already been set when instantiating this call,
7075 /// we provide this method for API completeness.
7076 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
7077 self._parent = new_value.to_string();
7078 self
7079 }
7080 /// Optional. Read mask is used for a more granular control over what the API returns. If the mask is not present all fields will be returned except [Queue.stats]. [Queue.stats] will be returned only if it was explicitly specified in the mask.
7081 ///
7082 /// Sets the *read mask* query property to the given value.
7083 pub fn read_mask(
7084 mut self,
7085 new_value: common::FieldMask,
7086 ) -> ProjectLocationQueueListCall<'a, C> {
7087 self._read_mask = Some(new_value);
7088 self
7089 }
7090 /// A token identifying the page of results to 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 ListQueues method. It is an error to switch the value of the filter while iterating through pages.
7091 ///
7092 /// Sets the *page token* query property to the given value.
7093 pub fn page_token(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
7094 self._page_token = Some(new_value.to_string());
7095 self
7096 }
7097 /// Requested page size. The maximum page size is 9800. If unspecified, the page size will be the maximum. Fewer queues than requested might be returned, even if more queues exist; use the next_page_token in the response to determine if more queues exist.
7098 ///
7099 /// Sets the *page size* query property to the given value.
7100 pub fn page_size(mut self, new_value: i32) -> ProjectLocationQueueListCall<'a, C> {
7101 self._page_size = Some(new_value);
7102 self
7103 }
7104 /// `filter` can be used to specify a subset of queues. Any Queue field can be used as a filter and several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as described in [Stackdriver's Advanced Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). Sample filter "app_engine_http_target: *". Note that using filters might cause fewer queues than the requested_page size to be returned.
7105 ///
7106 /// Sets the *filter* query property to the given value.
7107 pub fn filter(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
7108 self._filter = Some(new_value.to_string());
7109 self
7110 }
7111 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7112 /// while executing the actual API request.
7113 ///
7114 /// ````text
7115 /// It should be used to handle progress information, and to implement a certain level of resilience.
7116 /// ````
7117 ///
7118 /// Sets the *delegate* property to the given value.
7119 pub fn delegate(
7120 mut self,
7121 new_value: &'a mut dyn common::Delegate,
7122 ) -> ProjectLocationQueueListCall<'a, C> {
7123 self._delegate = Some(new_value);
7124 self
7125 }
7126
7127 /// Set any additional parameter of the query string used in the request.
7128 /// It should be used to set parameters which are not yet available through their own
7129 /// setters.
7130 ///
7131 /// Please note that this method must not be used to set any of the known parameters
7132 /// which have their own setter method. If done anyway, the request will fail.
7133 ///
7134 /// # Additional Parameters
7135 ///
7136 /// * *$.xgafv* (query-string) - V1 error format.
7137 /// * *access_token* (query-string) - OAuth access token.
7138 /// * *alt* (query-string) - Data format for response.
7139 /// * *callback* (query-string) - JSONP
7140 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7141 /// * *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.
7142 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7143 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7144 /// * *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.
7145 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7146 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7147 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueListCall<'a, C>
7148 where
7149 T: AsRef<str>,
7150 {
7151 self._additional_params
7152 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7153 self
7154 }
7155
7156 /// Identifies the authorization scope for the method you are building.
7157 ///
7158 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7159 /// [`Scope::CloudPlatform`].
7160 ///
7161 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7162 /// tokens for more than one scope.
7163 ///
7164 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7165 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7166 /// sufficient, a read-write scope will do as well.
7167 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueListCall<'a, C>
7168 where
7169 St: AsRef<str>,
7170 {
7171 self._scopes.insert(String::from(scope.as_ref()));
7172 self
7173 }
7174 /// Identifies the authorization scope(s) for the method you are building.
7175 ///
7176 /// See [`Self::add_scope()`] for details.
7177 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueListCall<'a, C>
7178 where
7179 I: IntoIterator<Item = St>,
7180 St: AsRef<str>,
7181 {
7182 self._scopes
7183 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7184 self
7185 }
7186
7187 /// Removes all scopes, and no default scope will be used either.
7188 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7189 /// for details).
7190 pub fn clear_scopes(mut self) -> ProjectLocationQueueListCall<'a, C> {
7191 self._scopes.clear();
7192 self
7193 }
7194}
7195
7196/// Updates a queue. This method creates the queue if it does not exist and updates the queue if it does exist. Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not. WARNING: Using this method may have unintended side effects if you are using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. Read [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using this method.
7197///
7198/// A builder for the *locations.queues.patch* method supported by a *project* resource.
7199/// It is not used directly, but through a [`ProjectMethods`] instance.
7200///
7201/// # Example
7202///
7203/// Instantiate a resource method builder
7204///
7205/// ```test_harness,no_run
7206/// # extern crate hyper;
7207/// # extern crate hyper_rustls;
7208/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
7209/// use cloudtasks2_beta2::api::Queue;
7210/// # async fn dox() {
7211/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7212///
7213/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7214/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7215/// # .with_native_roots()
7216/// # .unwrap()
7217/// # .https_only()
7218/// # .enable_http2()
7219/// # .build();
7220///
7221/// # let executor = hyper_util::rt::TokioExecutor::new();
7222/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7223/// # secret,
7224/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7225/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7226/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7227/// # ),
7228/// # ).build().await.unwrap();
7229///
7230/// # let client = hyper_util::client::legacy::Client::builder(
7231/// # hyper_util::rt::TokioExecutor::new()
7232/// # )
7233/// # .build(
7234/// # hyper_rustls::HttpsConnectorBuilder::new()
7235/// # .with_native_roots()
7236/// # .unwrap()
7237/// # .https_or_http()
7238/// # .enable_http2()
7239/// # .build()
7240/// # );
7241/// # let mut hub = CloudTasks::new(client, auth);
7242/// // As the method needs a request, you would usually fill it with the desired information
7243/// // into the respective structure. Some of the parts shown here might not be applicable !
7244/// // Values shown here are possibly random and not representative !
7245/// let mut req = Queue::default();
7246///
7247/// // You can configure optional parameters by calling the respective setters at will, and
7248/// // execute the final call using `doit()`.
7249/// // Values shown here are possibly random and not representative !
7250/// let result = hub.projects().locations_queues_patch(req, "name")
7251/// .update_mask(FieldMask::new::<&str>(&[]))
7252/// .doit().await;
7253/// # }
7254/// ```
7255pub struct ProjectLocationQueuePatchCall<'a, C>
7256where
7257 C: 'a,
7258{
7259 hub: &'a CloudTasks<C>,
7260 _request: Queue,
7261 _name: String,
7262 _update_mask: Option<common::FieldMask>,
7263 _delegate: Option<&'a mut dyn common::Delegate>,
7264 _additional_params: HashMap<String, String>,
7265 _scopes: BTreeSet<String>,
7266}
7267
7268impl<'a, C> common::CallBuilder for ProjectLocationQueuePatchCall<'a, C> {}
7269
7270impl<'a, C> ProjectLocationQueuePatchCall<'a, C>
7271where
7272 C: common::Connector,
7273{
7274 /// Perform the operation you have build so far.
7275 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
7276 use std::borrow::Cow;
7277 use std::io::{Read, Seek};
7278
7279 use common::{url::Params, ToParts};
7280 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7281
7282 let mut dd = common::DefaultDelegate;
7283 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7284 dlg.begin(common::MethodInfo {
7285 id: "cloudtasks.projects.locations.queues.patch",
7286 http_method: hyper::Method::PATCH,
7287 });
7288
7289 for &field in ["alt", "name", "updateMask"].iter() {
7290 if self._additional_params.contains_key(field) {
7291 dlg.finished(false);
7292 return Err(common::Error::FieldClash(field));
7293 }
7294 }
7295
7296 let mut params = Params::with_capacity(5 + self._additional_params.len());
7297 params.push("name", self._name);
7298 if let Some(value) = self._update_mask.as_ref() {
7299 params.push("updateMask", value.to_string());
7300 }
7301
7302 params.extend(self._additional_params.iter());
7303
7304 params.push("alt", "json");
7305 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
7306 if self._scopes.is_empty() {
7307 self._scopes
7308 .insert(Scope::CloudPlatform.as_ref().to_string());
7309 }
7310
7311 #[allow(clippy::single_element_loop)]
7312 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7313 url = params.uri_replacement(url, param_name, find_this, true);
7314 }
7315 {
7316 let to_remove = ["name"];
7317 params.remove_params(&to_remove);
7318 }
7319
7320 let url = params.parse_with_url(&url);
7321
7322 let mut json_mime_type = mime::APPLICATION_JSON;
7323 let mut request_value_reader = {
7324 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7325 common::remove_json_null_values(&mut value);
7326 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7327 serde_json::to_writer(&mut dst, &value).unwrap();
7328 dst
7329 };
7330 let request_size = request_value_reader
7331 .seek(std::io::SeekFrom::End(0))
7332 .unwrap();
7333 request_value_reader
7334 .seek(std::io::SeekFrom::Start(0))
7335 .unwrap();
7336
7337 loop {
7338 let token = match self
7339 .hub
7340 .auth
7341 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7342 .await
7343 {
7344 Ok(token) => token,
7345 Err(e) => match dlg.token(e) {
7346 Ok(token) => token,
7347 Err(e) => {
7348 dlg.finished(false);
7349 return Err(common::Error::MissingToken(e));
7350 }
7351 },
7352 };
7353 request_value_reader
7354 .seek(std::io::SeekFrom::Start(0))
7355 .unwrap();
7356 let mut req_result = {
7357 let client = &self.hub.client;
7358 dlg.pre_request();
7359 let mut req_builder = hyper::Request::builder()
7360 .method(hyper::Method::PATCH)
7361 .uri(url.as_str())
7362 .header(USER_AGENT, self.hub._user_agent.clone());
7363
7364 if let Some(token) = token.as_ref() {
7365 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7366 }
7367
7368 let request = req_builder
7369 .header(CONTENT_TYPE, json_mime_type.to_string())
7370 .header(CONTENT_LENGTH, request_size as u64)
7371 .body(common::to_body(
7372 request_value_reader.get_ref().clone().into(),
7373 ));
7374
7375 client.request(request.unwrap()).await
7376 };
7377
7378 match req_result {
7379 Err(err) => {
7380 if let common::Retry::After(d) = dlg.http_error(&err) {
7381 sleep(d).await;
7382 continue;
7383 }
7384 dlg.finished(false);
7385 return Err(common::Error::HttpError(err));
7386 }
7387 Ok(res) => {
7388 let (mut parts, body) = res.into_parts();
7389 let mut body = common::Body::new(body);
7390 if !parts.status.is_success() {
7391 let bytes = common::to_bytes(body).await.unwrap_or_default();
7392 let error = serde_json::from_str(&common::to_string(&bytes));
7393 let response = common::to_response(parts, bytes.into());
7394
7395 if let common::Retry::After(d) =
7396 dlg.http_failure(&response, error.as_ref().ok())
7397 {
7398 sleep(d).await;
7399 continue;
7400 }
7401
7402 dlg.finished(false);
7403
7404 return Err(match error {
7405 Ok(value) => common::Error::BadRequest(value),
7406 _ => common::Error::Failure(response),
7407 });
7408 }
7409 let response = {
7410 let bytes = common::to_bytes(body).await.unwrap_or_default();
7411 let encoded = common::to_string(&bytes);
7412 match serde_json::from_str(&encoded) {
7413 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7414 Err(error) => {
7415 dlg.response_json_decode_error(&encoded, &error);
7416 return Err(common::Error::JsonDecodeError(
7417 encoded.to_string(),
7418 error,
7419 ));
7420 }
7421 }
7422 };
7423
7424 dlg.finished(true);
7425 return Ok(response);
7426 }
7427 }
7428 }
7429 }
7430
7431 ///
7432 /// Sets the *request* property to the given value.
7433 ///
7434 /// Even though the property as already been set when instantiating this call,
7435 /// we provide this method for API completeness.
7436 pub fn request(mut self, new_value: Queue) -> ProjectLocationQueuePatchCall<'a, C> {
7437 self._request = new_value;
7438 self
7439 }
7440 /// Caller-specified and required in CreateQueue, after which it becomes output only. The queue name. The queue name must have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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 queue's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters.
7441 ///
7442 /// Sets the *name* path property to the given value.
7443 ///
7444 /// Even though the property as already been set when instantiating this call,
7445 /// we provide this method for API completeness.
7446 pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePatchCall<'a, C> {
7447 self._name = new_value.to_string();
7448 self
7449 }
7450 /// A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated.
7451 ///
7452 /// Sets the *update mask* query property to the given value.
7453 pub fn update_mask(
7454 mut self,
7455 new_value: common::FieldMask,
7456 ) -> ProjectLocationQueuePatchCall<'a, C> {
7457 self._update_mask = Some(new_value);
7458 self
7459 }
7460 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7461 /// while executing the actual API request.
7462 ///
7463 /// ````text
7464 /// It should be used to handle progress information, and to implement a certain level of resilience.
7465 /// ````
7466 ///
7467 /// Sets the *delegate* property to the given value.
7468 pub fn delegate(
7469 mut self,
7470 new_value: &'a mut dyn common::Delegate,
7471 ) -> ProjectLocationQueuePatchCall<'a, C> {
7472 self._delegate = Some(new_value);
7473 self
7474 }
7475
7476 /// Set any additional parameter of the query string used in the request.
7477 /// It should be used to set parameters which are not yet available through their own
7478 /// setters.
7479 ///
7480 /// Please note that this method must not be used to set any of the known parameters
7481 /// which have their own setter method. If done anyway, the request will fail.
7482 ///
7483 /// # Additional Parameters
7484 ///
7485 /// * *$.xgafv* (query-string) - V1 error format.
7486 /// * *access_token* (query-string) - OAuth access token.
7487 /// * *alt* (query-string) - Data format for response.
7488 /// * *callback* (query-string) - JSONP
7489 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7490 /// * *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.
7491 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7492 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7493 /// * *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.
7494 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7495 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7496 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePatchCall<'a, C>
7497 where
7498 T: AsRef<str>,
7499 {
7500 self._additional_params
7501 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7502 self
7503 }
7504
7505 /// Identifies the authorization scope for the method you are building.
7506 ///
7507 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7508 /// [`Scope::CloudPlatform`].
7509 ///
7510 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7511 /// tokens for more than one scope.
7512 ///
7513 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7514 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7515 /// sufficient, a read-write scope will do as well.
7516 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePatchCall<'a, C>
7517 where
7518 St: AsRef<str>,
7519 {
7520 self._scopes.insert(String::from(scope.as_ref()));
7521 self
7522 }
7523 /// Identifies the authorization scope(s) for the method you are building.
7524 ///
7525 /// See [`Self::add_scope()`] for details.
7526 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePatchCall<'a, C>
7527 where
7528 I: IntoIterator<Item = St>,
7529 St: AsRef<str>,
7530 {
7531 self._scopes
7532 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7533 self
7534 }
7535
7536 /// Removes all scopes, and no default scope will be used either.
7537 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7538 /// for details).
7539 pub fn clear_scopes(mut self) -> ProjectLocationQueuePatchCall<'a, C> {
7540 self._scopes.clear();
7541 self
7542 }
7543}
7544
7545/// Pauses the queue. If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.
7546///
7547/// A builder for the *locations.queues.pause* method supported by a *project* resource.
7548/// It is not used directly, but through a [`ProjectMethods`] instance.
7549///
7550/// # Example
7551///
7552/// Instantiate a resource method builder
7553///
7554/// ```test_harness,no_run
7555/// # extern crate hyper;
7556/// # extern crate hyper_rustls;
7557/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
7558/// use cloudtasks2_beta2::api::PauseQueueRequest;
7559/// # async fn dox() {
7560/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7561///
7562/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7563/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7564/// # .with_native_roots()
7565/// # .unwrap()
7566/// # .https_only()
7567/// # .enable_http2()
7568/// # .build();
7569///
7570/// # let executor = hyper_util::rt::TokioExecutor::new();
7571/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7572/// # secret,
7573/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7574/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7575/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7576/// # ),
7577/// # ).build().await.unwrap();
7578///
7579/// # let client = hyper_util::client::legacy::Client::builder(
7580/// # hyper_util::rt::TokioExecutor::new()
7581/// # )
7582/// # .build(
7583/// # hyper_rustls::HttpsConnectorBuilder::new()
7584/// # .with_native_roots()
7585/// # .unwrap()
7586/// # .https_or_http()
7587/// # .enable_http2()
7588/// # .build()
7589/// # );
7590/// # let mut hub = CloudTasks::new(client, auth);
7591/// // As the method needs a request, you would usually fill it with the desired information
7592/// // into the respective structure. Some of the parts shown here might not be applicable !
7593/// // Values shown here are possibly random and not representative !
7594/// let mut req = PauseQueueRequest::default();
7595///
7596/// // You can configure optional parameters by calling the respective setters at will, and
7597/// // execute the final call using `doit()`.
7598/// // Values shown here are possibly random and not representative !
7599/// let result = hub.projects().locations_queues_pause(req, "name")
7600/// .doit().await;
7601/// # }
7602/// ```
7603pub struct ProjectLocationQueuePauseCall<'a, C>
7604where
7605 C: 'a,
7606{
7607 hub: &'a CloudTasks<C>,
7608 _request: PauseQueueRequest,
7609 _name: String,
7610 _delegate: Option<&'a mut dyn common::Delegate>,
7611 _additional_params: HashMap<String, String>,
7612 _scopes: BTreeSet<String>,
7613}
7614
7615impl<'a, C> common::CallBuilder for ProjectLocationQueuePauseCall<'a, C> {}
7616
7617impl<'a, C> ProjectLocationQueuePauseCall<'a, C>
7618where
7619 C: common::Connector,
7620{
7621 /// Perform the operation you have build so far.
7622 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
7623 use std::borrow::Cow;
7624 use std::io::{Read, Seek};
7625
7626 use common::{url::Params, ToParts};
7627 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7628
7629 let mut dd = common::DefaultDelegate;
7630 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7631 dlg.begin(common::MethodInfo {
7632 id: "cloudtasks.projects.locations.queues.pause",
7633 http_method: hyper::Method::POST,
7634 });
7635
7636 for &field in ["alt", "name"].iter() {
7637 if self._additional_params.contains_key(field) {
7638 dlg.finished(false);
7639 return Err(common::Error::FieldClash(field));
7640 }
7641 }
7642
7643 let mut params = Params::with_capacity(4 + self._additional_params.len());
7644 params.push("name", self._name);
7645
7646 params.extend(self._additional_params.iter());
7647
7648 params.push("alt", "json");
7649 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:pause";
7650 if self._scopes.is_empty() {
7651 self._scopes
7652 .insert(Scope::CloudPlatform.as_ref().to_string());
7653 }
7654
7655 #[allow(clippy::single_element_loop)]
7656 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7657 url = params.uri_replacement(url, param_name, find_this, true);
7658 }
7659 {
7660 let to_remove = ["name"];
7661 params.remove_params(&to_remove);
7662 }
7663
7664 let url = params.parse_with_url(&url);
7665
7666 let mut json_mime_type = mime::APPLICATION_JSON;
7667 let mut request_value_reader = {
7668 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7669 common::remove_json_null_values(&mut value);
7670 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7671 serde_json::to_writer(&mut dst, &value).unwrap();
7672 dst
7673 };
7674 let request_size = request_value_reader
7675 .seek(std::io::SeekFrom::End(0))
7676 .unwrap();
7677 request_value_reader
7678 .seek(std::io::SeekFrom::Start(0))
7679 .unwrap();
7680
7681 loop {
7682 let token = match self
7683 .hub
7684 .auth
7685 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7686 .await
7687 {
7688 Ok(token) => token,
7689 Err(e) => match dlg.token(e) {
7690 Ok(token) => token,
7691 Err(e) => {
7692 dlg.finished(false);
7693 return Err(common::Error::MissingToken(e));
7694 }
7695 },
7696 };
7697 request_value_reader
7698 .seek(std::io::SeekFrom::Start(0))
7699 .unwrap();
7700 let mut req_result = {
7701 let client = &self.hub.client;
7702 dlg.pre_request();
7703 let mut req_builder = hyper::Request::builder()
7704 .method(hyper::Method::POST)
7705 .uri(url.as_str())
7706 .header(USER_AGENT, self.hub._user_agent.clone());
7707
7708 if let Some(token) = token.as_ref() {
7709 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7710 }
7711
7712 let request = req_builder
7713 .header(CONTENT_TYPE, json_mime_type.to_string())
7714 .header(CONTENT_LENGTH, request_size as u64)
7715 .body(common::to_body(
7716 request_value_reader.get_ref().clone().into(),
7717 ));
7718
7719 client.request(request.unwrap()).await
7720 };
7721
7722 match req_result {
7723 Err(err) => {
7724 if let common::Retry::After(d) = dlg.http_error(&err) {
7725 sleep(d).await;
7726 continue;
7727 }
7728 dlg.finished(false);
7729 return Err(common::Error::HttpError(err));
7730 }
7731 Ok(res) => {
7732 let (mut parts, body) = res.into_parts();
7733 let mut body = common::Body::new(body);
7734 if !parts.status.is_success() {
7735 let bytes = common::to_bytes(body).await.unwrap_or_default();
7736 let error = serde_json::from_str(&common::to_string(&bytes));
7737 let response = common::to_response(parts, bytes.into());
7738
7739 if let common::Retry::After(d) =
7740 dlg.http_failure(&response, error.as_ref().ok())
7741 {
7742 sleep(d).await;
7743 continue;
7744 }
7745
7746 dlg.finished(false);
7747
7748 return Err(match error {
7749 Ok(value) => common::Error::BadRequest(value),
7750 _ => common::Error::Failure(response),
7751 });
7752 }
7753 let response = {
7754 let bytes = common::to_bytes(body).await.unwrap_or_default();
7755 let encoded = common::to_string(&bytes);
7756 match serde_json::from_str(&encoded) {
7757 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7758 Err(error) => {
7759 dlg.response_json_decode_error(&encoded, &error);
7760 return Err(common::Error::JsonDecodeError(
7761 encoded.to_string(),
7762 error,
7763 ));
7764 }
7765 }
7766 };
7767
7768 dlg.finished(true);
7769 return Ok(response);
7770 }
7771 }
7772 }
7773 }
7774
7775 ///
7776 /// Sets the *request* property to the given value.
7777 ///
7778 /// Even though the property as already been set when instantiating this call,
7779 /// we provide this method for API completeness.
7780 pub fn request(mut self, new_value: PauseQueueRequest) -> ProjectLocationQueuePauseCall<'a, C> {
7781 self._request = new_value;
7782 self
7783 }
7784 /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
7785 ///
7786 /// Sets the *name* path property to the given value.
7787 ///
7788 /// Even though the property as already been set when instantiating this call,
7789 /// we provide this method for API completeness.
7790 pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePauseCall<'a, C> {
7791 self._name = new_value.to_string();
7792 self
7793 }
7794 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7795 /// while executing the actual API request.
7796 ///
7797 /// ````text
7798 /// It should be used to handle progress information, and to implement a certain level of resilience.
7799 /// ````
7800 ///
7801 /// Sets the *delegate* property to the given value.
7802 pub fn delegate(
7803 mut self,
7804 new_value: &'a mut dyn common::Delegate,
7805 ) -> ProjectLocationQueuePauseCall<'a, C> {
7806 self._delegate = Some(new_value);
7807 self
7808 }
7809
7810 /// Set any additional parameter of the query string used in the request.
7811 /// It should be used to set parameters which are not yet available through their own
7812 /// setters.
7813 ///
7814 /// Please note that this method must not be used to set any of the known parameters
7815 /// which have their own setter method. If done anyway, the request will fail.
7816 ///
7817 /// # Additional Parameters
7818 ///
7819 /// * *$.xgafv* (query-string) - V1 error format.
7820 /// * *access_token* (query-string) - OAuth access token.
7821 /// * *alt* (query-string) - Data format for response.
7822 /// * *callback* (query-string) - JSONP
7823 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7824 /// * *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.
7825 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7826 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7827 /// * *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.
7828 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7829 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7830 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePauseCall<'a, C>
7831 where
7832 T: AsRef<str>,
7833 {
7834 self._additional_params
7835 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7836 self
7837 }
7838
7839 /// Identifies the authorization scope for the method you are building.
7840 ///
7841 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7842 /// [`Scope::CloudPlatform`].
7843 ///
7844 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7845 /// tokens for more than one scope.
7846 ///
7847 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7848 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7849 /// sufficient, a read-write scope will do as well.
7850 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePauseCall<'a, C>
7851 where
7852 St: AsRef<str>,
7853 {
7854 self._scopes.insert(String::from(scope.as_ref()));
7855 self
7856 }
7857 /// Identifies the authorization scope(s) for the method you are building.
7858 ///
7859 /// See [`Self::add_scope()`] for details.
7860 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePauseCall<'a, C>
7861 where
7862 I: IntoIterator<Item = St>,
7863 St: AsRef<str>,
7864 {
7865 self._scopes
7866 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7867 self
7868 }
7869
7870 /// Removes all scopes, and no default scope will be used either.
7871 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7872 /// for details).
7873 pub fn clear_scopes(mut self) -> ProjectLocationQueuePauseCall<'a, C> {
7874 self._scopes.clear();
7875 self
7876 }
7877}
7878
7879/// Purges a queue by deleting all of its tasks. All tasks created before this method is called are permanently deleted. Purge operations can take up to one minute to take effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible.
7880///
7881/// A builder for the *locations.queues.purge* method supported by a *project* resource.
7882/// It is not used directly, but through a [`ProjectMethods`] instance.
7883///
7884/// # Example
7885///
7886/// Instantiate a resource method builder
7887///
7888/// ```test_harness,no_run
7889/// # extern crate hyper;
7890/// # extern crate hyper_rustls;
7891/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
7892/// use cloudtasks2_beta2::api::PurgeQueueRequest;
7893/// # async fn dox() {
7894/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7895///
7896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7897/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7898/// # .with_native_roots()
7899/// # .unwrap()
7900/// # .https_only()
7901/// # .enable_http2()
7902/// # .build();
7903///
7904/// # let executor = hyper_util::rt::TokioExecutor::new();
7905/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7906/// # secret,
7907/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7908/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7909/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7910/// # ),
7911/// # ).build().await.unwrap();
7912///
7913/// # let client = hyper_util::client::legacy::Client::builder(
7914/// # hyper_util::rt::TokioExecutor::new()
7915/// # )
7916/// # .build(
7917/// # hyper_rustls::HttpsConnectorBuilder::new()
7918/// # .with_native_roots()
7919/// # .unwrap()
7920/// # .https_or_http()
7921/// # .enable_http2()
7922/// # .build()
7923/// # );
7924/// # let mut hub = CloudTasks::new(client, auth);
7925/// // As the method needs a request, you would usually fill it with the desired information
7926/// // into the respective structure. Some of the parts shown here might not be applicable !
7927/// // Values shown here are possibly random and not representative !
7928/// let mut req = PurgeQueueRequest::default();
7929///
7930/// // You can configure optional parameters by calling the respective setters at will, and
7931/// // execute the final call using `doit()`.
7932/// // Values shown here are possibly random and not representative !
7933/// let result = hub.projects().locations_queues_purge(req, "name")
7934/// .doit().await;
7935/// # }
7936/// ```
7937pub struct ProjectLocationQueuePurgeCall<'a, C>
7938where
7939 C: 'a,
7940{
7941 hub: &'a CloudTasks<C>,
7942 _request: PurgeQueueRequest,
7943 _name: String,
7944 _delegate: Option<&'a mut dyn common::Delegate>,
7945 _additional_params: HashMap<String, String>,
7946 _scopes: BTreeSet<String>,
7947}
7948
7949impl<'a, C> common::CallBuilder for ProjectLocationQueuePurgeCall<'a, C> {}
7950
7951impl<'a, C> ProjectLocationQueuePurgeCall<'a, C>
7952where
7953 C: common::Connector,
7954{
7955 /// Perform the operation you have build so far.
7956 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
7957 use std::borrow::Cow;
7958 use std::io::{Read, Seek};
7959
7960 use common::{url::Params, ToParts};
7961 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7962
7963 let mut dd = common::DefaultDelegate;
7964 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7965 dlg.begin(common::MethodInfo {
7966 id: "cloudtasks.projects.locations.queues.purge",
7967 http_method: hyper::Method::POST,
7968 });
7969
7970 for &field in ["alt", "name"].iter() {
7971 if self._additional_params.contains_key(field) {
7972 dlg.finished(false);
7973 return Err(common::Error::FieldClash(field));
7974 }
7975 }
7976
7977 let mut params = Params::with_capacity(4 + self._additional_params.len());
7978 params.push("name", self._name);
7979
7980 params.extend(self._additional_params.iter());
7981
7982 params.push("alt", "json");
7983 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:purge";
7984 if self._scopes.is_empty() {
7985 self._scopes
7986 .insert(Scope::CloudPlatform.as_ref().to_string());
7987 }
7988
7989 #[allow(clippy::single_element_loop)]
7990 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7991 url = params.uri_replacement(url, param_name, find_this, true);
7992 }
7993 {
7994 let to_remove = ["name"];
7995 params.remove_params(&to_remove);
7996 }
7997
7998 let url = params.parse_with_url(&url);
7999
8000 let mut json_mime_type = mime::APPLICATION_JSON;
8001 let mut request_value_reader = {
8002 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8003 common::remove_json_null_values(&mut value);
8004 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8005 serde_json::to_writer(&mut dst, &value).unwrap();
8006 dst
8007 };
8008 let request_size = request_value_reader
8009 .seek(std::io::SeekFrom::End(0))
8010 .unwrap();
8011 request_value_reader
8012 .seek(std::io::SeekFrom::Start(0))
8013 .unwrap();
8014
8015 loop {
8016 let token = match self
8017 .hub
8018 .auth
8019 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8020 .await
8021 {
8022 Ok(token) => token,
8023 Err(e) => match dlg.token(e) {
8024 Ok(token) => token,
8025 Err(e) => {
8026 dlg.finished(false);
8027 return Err(common::Error::MissingToken(e));
8028 }
8029 },
8030 };
8031 request_value_reader
8032 .seek(std::io::SeekFrom::Start(0))
8033 .unwrap();
8034 let mut req_result = {
8035 let client = &self.hub.client;
8036 dlg.pre_request();
8037 let mut req_builder = hyper::Request::builder()
8038 .method(hyper::Method::POST)
8039 .uri(url.as_str())
8040 .header(USER_AGENT, self.hub._user_agent.clone());
8041
8042 if let Some(token) = token.as_ref() {
8043 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8044 }
8045
8046 let request = req_builder
8047 .header(CONTENT_TYPE, json_mime_type.to_string())
8048 .header(CONTENT_LENGTH, request_size as u64)
8049 .body(common::to_body(
8050 request_value_reader.get_ref().clone().into(),
8051 ));
8052
8053 client.request(request.unwrap()).await
8054 };
8055
8056 match req_result {
8057 Err(err) => {
8058 if let common::Retry::After(d) = dlg.http_error(&err) {
8059 sleep(d).await;
8060 continue;
8061 }
8062 dlg.finished(false);
8063 return Err(common::Error::HttpError(err));
8064 }
8065 Ok(res) => {
8066 let (mut parts, body) = res.into_parts();
8067 let mut body = common::Body::new(body);
8068 if !parts.status.is_success() {
8069 let bytes = common::to_bytes(body).await.unwrap_or_default();
8070 let error = serde_json::from_str(&common::to_string(&bytes));
8071 let response = common::to_response(parts, bytes.into());
8072
8073 if let common::Retry::After(d) =
8074 dlg.http_failure(&response, error.as_ref().ok())
8075 {
8076 sleep(d).await;
8077 continue;
8078 }
8079
8080 dlg.finished(false);
8081
8082 return Err(match error {
8083 Ok(value) => common::Error::BadRequest(value),
8084 _ => common::Error::Failure(response),
8085 });
8086 }
8087 let response = {
8088 let bytes = common::to_bytes(body).await.unwrap_or_default();
8089 let encoded = common::to_string(&bytes);
8090 match serde_json::from_str(&encoded) {
8091 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8092 Err(error) => {
8093 dlg.response_json_decode_error(&encoded, &error);
8094 return Err(common::Error::JsonDecodeError(
8095 encoded.to_string(),
8096 error,
8097 ));
8098 }
8099 }
8100 };
8101
8102 dlg.finished(true);
8103 return Ok(response);
8104 }
8105 }
8106 }
8107 }
8108
8109 ///
8110 /// Sets the *request* property to the given value.
8111 ///
8112 /// Even though the property as already been set when instantiating this call,
8113 /// we provide this method for API completeness.
8114 pub fn request(mut self, new_value: PurgeQueueRequest) -> ProjectLocationQueuePurgeCall<'a, C> {
8115 self._request = new_value;
8116 self
8117 }
8118 /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
8119 ///
8120 /// Sets the *name* path property to the given value.
8121 ///
8122 /// Even though the property as already been set when instantiating this call,
8123 /// we provide this method for API completeness.
8124 pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePurgeCall<'a, C> {
8125 self._name = new_value.to_string();
8126 self
8127 }
8128 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8129 /// while executing the actual API request.
8130 ///
8131 /// ````text
8132 /// It should be used to handle progress information, and to implement a certain level of resilience.
8133 /// ````
8134 ///
8135 /// Sets the *delegate* property to the given value.
8136 pub fn delegate(
8137 mut self,
8138 new_value: &'a mut dyn common::Delegate,
8139 ) -> ProjectLocationQueuePurgeCall<'a, C> {
8140 self._delegate = Some(new_value);
8141 self
8142 }
8143
8144 /// Set any additional parameter of the query string used in the request.
8145 /// It should be used to set parameters which are not yet available through their own
8146 /// setters.
8147 ///
8148 /// Please note that this method must not be used to set any of the known parameters
8149 /// which have their own setter method. If done anyway, the request will fail.
8150 ///
8151 /// # Additional Parameters
8152 ///
8153 /// * *$.xgafv* (query-string) - V1 error format.
8154 /// * *access_token* (query-string) - OAuth access token.
8155 /// * *alt* (query-string) - Data format for response.
8156 /// * *callback* (query-string) - JSONP
8157 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8158 /// * *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.
8159 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8160 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8161 /// * *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.
8162 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8163 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8164 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePurgeCall<'a, C>
8165 where
8166 T: AsRef<str>,
8167 {
8168 self._additional_params
8169 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8170 self
8171 }
8172
8173 /// Identifies the authorization scope for the method you are building.
8174 ///
8175 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8176 /// [`Scope::CloudPlatform`].
8177 ///
8178 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8179 /// tokens for more than one scope.
8180 ///
8181 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8182 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8183 /// sufficient, a read-write scope will do as well.
8184 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePurgeCall<'a, C>
8185 where
8186 St: AsRef<str>,
8187 {
8188 self._scopes.insert(String::from(scope.as_ref()));
8189 self
8190 }
8191 /// Identifies the authorization scope(s) for the method you are building.
8192 ///
8193 /// See [`Self::add_scope()`] for details.
8194 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePurgeCall<'a, C>
8195 where
8196 I: IntoIterator<Item = St>,
8197 St: AsRef<str>,
8198 {
8199 self._scopes
8200 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8201 self
8202 }
8203
8204 /// Removes all scopes, and no default scope will be used either.
8205 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8206 /// for details).
8207 pub fn clear_scopes(mut self) -> ProjectLocationQueuePurgeCall<'a, C> {
8208 self._scopes.clear();
8209 self
8210 }
8211}
8212
8213/// Resume a queue. This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING. WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
8214///
8215/// A builder for the *locations.queues.resume* method supported by a *project* resource.
8216/// It is not used directly, but through a [`ProjectMethods`] instance.
8217///
8218/// # Example
8219///
8220/// Instantiate a resource method builder
8221///
8222/// ```test_harness,no_run
8223/// # extern crate hyper;
8224/// # extern crate hyper_rustls;
8225/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
8226/// use cloudtasks2_beta2::api::ResumeQueueRequest;
8227/// # async fn dox() {
8228/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8229///
8230/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8231/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8232/// # .with_native_roots()
8233/// # .unwrap()
8234/// # .https_only()
8235/// # .enable_http2()
8236/// # .build();
8237///
8238/// # let executor = hyper_util::rt::TokioExecutor::new();
8239/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8240/// # secret,
8241/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8242/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8243/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8244/// # ),
8245/// # ).build().await.unwrap();
8246///
8247/// # let client = hyper_util::client::legacy::Client::builder(
8248/// # hyper_util::rt::TokioExecutor::new()
8249/// # )
8250/// # .build(
8251/// # hyper_rustls::HttpsConnectorBuilder::new()
8252/// # .with_native_roots()
8253/// # .unwrap()
8254/// # .https_or_http()
8255/// # .enable_http2()
8256/// # .build()
8257/// # );
8258/// # let mut hub = CloudTasks::new(client, auth);
8259/// // As the method needs a request, you would usually fill it with the desired information
8260/// // into the respective structure. Some of the parts shown here might not be applicable !
8261/// // Values shown here are possibly random and not representative !
8262/// let mut req = ResumeQueueRequest::default();
8263///
8264/// // You can configure optional parameters by calling the respective setters at will, and
8265/// // execute the final call using `doit()`.
8266/// // Values shown here are possibly random and not representative !
8267/// let result = hub.projects().locations_queues_resume(req, "name")
8268/// .doit().await;
8269/// # }
8270/// ```
8271pub struct ProjectLocationQueueResumeCall<'a, C>
8272where
8273 C: 'a,
8274{
8275 hub: &'a CloudTasks<C>,
8276 _request: ResumeQueueRequest,
8277 _name: String,
8278 _delegate: Option<&'a mut dyn common::Delegate>,
8279 _additional_params: HashMap<String, String>,
8280 _scopes: BTreeSet<String>,
8281}
8282
8283impl<'a, C> common::CallBuilder for ProjectLocationQueueResumeCall<'a, C> {}
8284
8285impl<'a, C> ProjectLocationQueueResumeCall<'a, C>
8286where
8287 C: common::Connector,
8288{
8289 /// Perform the operation you have build so far.
8290 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
8291 use std::borrow::Cow;
8292 use std::io::{Read, Seek};
8293
8294 use common::{url::Params, ToParts};
8295 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8296
8297 let mut dd = common::DefaultDelegate;
8298 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8299 dlg.begin(common::MethodInfo {
8300 id: "cloudtasks.projects.locations.queues.resume",
8301 http_method: hyper::Method::POST,
8302 });
8303
8304 for &field in ["alt", "name"].iter() {
8305 if self._additional_params.contains_key(field) {
8306 dlg.finished(false);
8307 return Err(common::Error::FieldClash(field));
8308 }
8309 }
8310
8311 let mut params = Params::with_capacity(4 + self._additional_params.len());
8312 params.push("name", self._name);
8313
8314 params.extend(self._additional_params.iter());
8315
8316 params.push("alt", "json");
8317 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:resume";
8318 if self._scopes.is_empty() {
8319 self._scopes
8320 .insert(Scope::CloudPlatform.as_ref().to_string());
8321 }
8322
8323 #[allow(clippy::single_element_loop)]
8324 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8325 url = params.uri_replacement(url, param_name, find_this, true);
8326 }
8327 {
8328 let to_remove = ["name"];
8329 params.remove_params(&to_remove);
8330 }
8331
8332 let url = params.parse_with_url(&url);
8333
8334 let mut json_mime_type = mime::APPLICATION_JSON;
8335 let mut request_value_reader = {
8336 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8337 common::remove_json_null_values(&mut value);
8338 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8339 serde_json::to_writer(&mut dst, &value).unwrap();
8340 dst
8341 };
8342 let request_size = request_value_reader
8343 .seek(std::io::SeekFrom::End(0))
8344 .unwrap();
8345 request_value_reader
8346 .seek(std::io::SeekFrom::Start(0))
8347 .unwrap();
8348
8349 loop {
8350 let token = match self
8351 .hub
8352 .auth
8353 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8354 .await
8355 {
8356 Ok(token) => token,
8357 Err(e) => match dlg.token(e) {
8358 Ok(token) => token,
8359 Err(e) => {
8360 dlg.finished(false);
8361 return Err(common::Error::MissingToken(e));
8362 }
8363 },
8364 };
8365 request_value_reader
8366 .seek(std::io::SeekFrom::Start(0))
8367 .unwrap();
8368 let mut req_result = {
8369 let client = &self.hub.client;
8370 dlg.pre_request();
8371 let mut req_builder = hyper::Request::builder()
8372 .method(hyper::Method::POST)
8373 .uri(url.as_str())
8374 .header(USER_AGENT, self.hub._user_agent.clone());
8375
8376 if let Some(token) = token.as_ref() {
8377 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8378 }
8379
8380 let request = req_builder
8381 .header(CONTENT_TYPE, json_mime_type.to_string())
8382 .header(CONTENT_LENGTH, request_size as u64)
8383 .body(common::to_body(
8384 request_value_reader.get_ref().clone().into(),
8385 ));
8386
8387 client.request(request.unwrap()).await
8388 };
8389
8390 match req_result {
8391 Err(err) => {
8392 if let common::Retry::After(d) = dlg.http_error(&err) {
8393 sleep(d).await;
8394 continue;
8395 }
8396 dlg.finished(false);
8397 return Err(common::Error::HttpError(err));
8398 }
8399 Ok(res) => {
8400 let (mut parts, body) = res.into_parts();
8401 let mut body = common::Body::new(body);
8402 if !parts.status.is_success() {
8403 let bytes = common::to_bytes(body).await.unwrap_or_default();
8404 let error = serde_json::from_str(&common::to_string(&bytes));
8405 let response = common::to_response(parts, bytes.into());
8406
8407 if let common::Retry::After(d) =
8408 dlg.http_failure(&response, error.as_ref().ok())
8409 {
8410 sleep(d).await;
8411 continue;
8412 }
8413
8414 dlg.finished(false);
8415
8416 return Err(match error {
8417 Ok(value) => common::Error::BadRequest(value),
8418 _ => common::Error::Failure(response),
8419 });
8420 }
8421 let response = {
8422 let bytes = common::to_bytes(body).await.unwrap_or_default();
8423 let encoded = common::to_string(&bytes);
8424 match serde_json::from_str(&encoded) {
8425 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8426 Err(error) => {
8427 dlg.response_json_decode_error(&encoded, &error);
8428 return Err(common::Error::JsonDecodeError(
8429 encoded.to_string(),
8430 error,
8431 ));
8432 }
8433 }
8434 };
8435
8436 dlg.finished(true);
8437 return Ok(response);
8438 }
8439 }
8440 }
8441 }
8442
8443 ///
8444 /// Sets the *request* property to the given value.
8445 ///
8446 /// Even though the property as already been set when instantiating this call,
8447 /// we provide this method for API completeness.
8448 pub fn request(
8449 mut self,
8450 new_value: ResumeQueueRequest,
8451 ) -> ProjectLocationQueueResumeCall<'a, C> {
8452 self._request = new_value;
8453 self
8454 }
8455 /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
8456 ///
8457 /// Sets the *name* path property to the given value.
8458 ///
8459 /// Even though the property as already been set when instantiating this call,
8460 /// we provide this method for API completeness.
8461 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueResumeCall<'a, C> {
8462 self._name = new_value.to_string();
8463 self
8464 }
8465 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8466 /// while executing the actual API request.
8467 ///
8468 /// ````text
8469 /// It should be used to handle progress information, and to implement a certain level of resilience.
8470 /// ````
8471 ///
8472 /// Sets the *delegate* property to the given value.
8473 pub fn delegate(
8474 mut self,
8475 new_value: &'a mut dyn common::Delegate,
8476 ) -> ProjectLocationQueueResumeCall<'a, C> {
8477 self._delegate = Some(new_value);
8478 self
8479 }
8480
8481 /// Set any additional parameter of the query string used in the request.
8482 /// It should be used to set parameters which are not yet available through their own
8483 /// setters.
8484 ///
8485 /// Please note that this method must not be used to set any of the known parameters
8486 /// which have their own setter method. If done anyway, the request will fail.
8487 ///
8488 /// # Additional Parameters
8489 ///
8490 /// * *$.xgafv* (query-string) - V1 error format.
8491 /// * *access_token* (query-string) - OAuth access token.
8492 /// * *alt* (query-string) - Data format for response.
8493 /// * *callback* (query-string) - JSONP
8494 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8495 /// * *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.
8496 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8497 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8498 /// * *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.
8499 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8500 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8501 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueResumeCall<'a, C>
8502 where
8503 T: AsRef<str>,
8504 {
8505 self._additional_params
8506 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8507 self
8508 }
8509
8510 /// Identifies the authorization scope for the method you are building.
8511 ///
8512 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8513 /// [`Scope::CloudPlatform`].
8514 ///
8515 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8516 /// tokens for more than one scope.
8517 ///
8518 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8519 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8520 /// sufficient, a read-write scope will do as well.
8521 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueResumeCall<'a, C>
8522 where
8523 St: AsRef<str>,
8524 {
8525 self._scopes.insert(String::from(scope.as_ref()));
8526 self
8527 }
8528 /// Identifies the authorization scope(s) for the method you are building.
8529 ///
8530 /// See [`Self::add_scope()`] for details.
8531 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueResumeCall<'a, C>
8532 where
8533 I: IntoIterator<Item = St>,
8534 St: AsRef<str>,
8535 {
8536 self._scopes
8537 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8538 self
8539 }
8540
8541 /// Removes all scopes, and no default scope will be used either.
8542 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8543 /// for details).
8544 pub fn clear_scopes(mut self) -> ProjectLocationQueueResumeCall<'a, C> {
8545 self._scopes.clear();
8546 self
8547 }
8548}
8549
8550/// Sets the access control policy for a Queue. Replaces any existing policy. Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console. Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the specified resource parent: * `cloudtasks.queues.setIamPolicy`
8551///
8552/// A builder for the *locations.queues.setIamPolicy* method supported by a *project* resource.
8553/// It is not used directly, but through a [`ProjectMethods`] instance.
8554///
8555/// # Example
8556///
8557/// Instantiate a resource method builder
8558///
8559/// ```test_harness,no_run
8560/// # extern crate hyper;
8561/// # extern crate hyper_rustls;
8562/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
8563/// use cloudtasks2_beta2::api::SetIamPolicyRequest;
8564/// # async fn dox() {
8565/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8566///
8567/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8568/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8569/// # .with_native_roots()
8570/// # .unwrap()
8571/// # .https_only()
8572/// # .enable_http2()
8573/// # .build();
8574///
8575/// # let executor = hyper_util::rt::TokioExecutor::new();
8576/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8577/// # secret,
8578/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8579/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8580/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8581/// # ),
8582/// # ).build().await.unwrap();
8583///
8584/// # let client = hyper_util::client::legacy::Client::builder(
8585/// # hyper_util::rt::TokioExecutor::new()
8586/// # )
8587/// # .build(
8588/// # hyper_rustls::HttpsConnectorBuilder::new()
8589/// # .with_native_roots()
8590/// # .unwrap()
8591/// # .https_or_http()
8592/// # .enable_http2()
8593/// # .build()
8594/// # );
8595/// # let mut hub = CloudTasks::new(client, auth);
8596/// // As the method needs a request, you would usually fill it with the desired information
8597/// // into the respective structure. Some of the parts shown here might not be applicable !
8598/// // Values shown here are possibly random and not representative !
8599/// let mut req = SetIamPolicyRequest::default();
8600///
8601/// // You can configure optional parameters by calling the respective setters at will, and
8602/// // execute the final call using `doit()`.
8603/// // Values shown here are possibly random and not representative !
8604/// let result = hub.projects().locations_queues_set_iam_policy(req, "resource")
8605/// .doit().await;
8606/// # }
8607/// ```
8608pub struct ProjectLocationQueueSetIamPolicyCall<'a, C>
8609where
8610 C: 'a,
8611{
8612 hub: &'a CloudTasks<C>,
8613 _request: SetIamPolicyRequest,
8614 _resource: String,
8615 _delegate: Option<&'a mut dyn common::Delegate>,
8616 _additional_params: HashMap<String, String>,
8617 _scopes: BTreeSet<String>,
8618}
8619
8620impl<'a, C> common::CallBuilder for ProjectLocationQueueSetIamPolicyCall<'a, C> {}
8621
8622impl<'a, C> ProjectLocationQueueSetIamPolicyCall<'a, C>
8623where
8624 C: common::Connector,
8625{
8626 /// Perform the operation you have build so far.
8627 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8628 use std::borrow::Cow;
8629 use std::io::{Read, Seek};
8630
8631 use common::{url::Params, ToParts};
8632 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8633
8634 let mut dd = common::DefaultDelegate;
8635 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8636 dlg.begin(common::MethodInfo {
8637 id: "cloudtasks.projects.locations.queues.setIamPolicy",
8638 http_method: hyper::Method::POST,
8639 });
8640
8641 for &field in ["alt", "resource"].iter() {
8642 if self._additional_params.contains_key(field) {
8643 dlg.finished(false);
8644 return Err(common::Error::FieldClash(field));
8645 }
8646 }
8647
8648 let mut params = Params::with_capacity(4 + self._additional_params.len());
8649 params.push("resource", self._resource);
8650
8651 params.extend(self._additional_params.iter());
8652
8653 params.push("alt", "json");
8654 let mut url = self.hub._base_url.clone() + "v2beta2/{+resource}:setIamPolicy";
8655 if self._scopes.is_empty() {
8656 self._scopes
8657 .insert(Scope::CloudPlatform.as_ref().to_string());
8658 }
8659
8660 #[allow(clippy::single_element_loop)]
8661 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8662 url = params.uri_replacement(url, param_name, find_this, true);
8663 }
8664 {
8665 let to_remove = ["resource"];
8666 params.remove_params(&to_remove);
8667 }
8668
8669 let url = params.parse_with_url(&url);
8670
8671 let mut json_mime_type = mime::APPLICATION_JSON;
8672 let mut request_value_reader = {
8673 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8674 common::remove_json_null_values(&mut value);
8675 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8676 serde_json::to_writer(&mut dst, &value).unwrap();
8677 dst
8678 };
8679 let request_size = request_value_reader
8680 .seek(std::io::SeekFrom::End(0))
8681 .unwrap();
8682 request_value_reader
8683 .seek(std::io::SeekFrom::Start(0))
8684 .unwrap();
8685
8686 loop {
8687 let token = match self
8688 .hub
8689 .auth
8690 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8691 .await
8692 {
8693 Ok(token) => token,
8694 Err(e) => match dlg.token(e) {
8695 Ok(token) => token,
8696 Err(e) => {
8697 dlg.finished(false);
8698 return Err(common::Error::MissingToken(e));
8699 }
8700 },
8701 };
8702 request_value_reader
8703 .seek(std::io::SeekFrom::Start(0))
8704 .unwrap();
8705 let mut req_result = {
8706 let client = &self.hub.client;
8707 dlg.pre_request();
8708 let mut req_builder = hyper::Request::builder()
8709 .method(hyper::Method::POST)
8710 .uri(url.as_str())
8711 .header(USER_AGENT, self.hub._user_agent.clone());
8712
8713 if let Some(token) = token.as_ref() {
8714 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8715 }
8716
8717 let request = req_builder
8718 .header(CONTENT_TYPE, json_mime_type.to_string())
8719 .header(CONTENT_LENGTH, request_size as u64)
8720 .body(common::to_body(
8721 request_value_reader.get_ref().clone().into(),
8722 ));
8723
8724 client.request(request.unwrap()).await
8725 };
8726
8727 match req_result {
8728 Err(err) => {
8729 if let common::Retry::After(d) = dlg.http_error(&err) {
8730 sleep(d).await;
8731 continue;
8732 }
8733 dlg.finished(false);
8734 return Err(common::Error::HttpError(err));
8735 }
8736 Ok(res) => {
8737 let (mut parts, body) = res.into_parts();
8738 let mut body = common::Body::new(body);
8739 if !parts.status.is_success() {
8740 let bytes = common::to_bytes(body).await.unwrap_or_default();
8741 let error = serde_json::from_str(&common::to_string(&bytes));
8742 let response = common::to_response(parts, bytes.into());
8743
8744 if let common::Retry::After(d) =
8745 dlg.http_failure(&response, error.as_ref().ok())
8746 {
8747 sleep(d).await;
8748 continue;
8749 }
8750
8751 dlg.finished(false);
8752
8753 return Err(match error {
8754 Ok(value) => common::Error::BadRequest(value),
8755 _ => common::Error::Failure(response),
8756 });
8757 }
8758 let response = {
8759 let bytes = common::to_bytes(body).await.unwrap_or_default();
8760 let encoded = common::to_string(&bytes);
8761 match serde_json::from_str(&encoded) {
8762 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8763 Err(error) => {
8764 dlg.response_json_decode_error(&encoded, &error);
8765 return Err(common::Error::JsonDecodeError(
8766 encoded.to_string(),
8767 error,
8768 ));
8769 }
8770 }
8771 };
8772
8773 dlg.finished(true);
8774 return Ok(response);
8775 }
8776 }
8777 }
8778 }
8779
8780 ///
8781 /// Sets the *request* property to the given value.
8782 ///
8783 /// Even though the property as already been set when instantiating this call,
8784 /// we provide this method for API completeness.
8785 pub fn request(
8786 mut self,
8787 new_value: SetIamPolicyRequest,
8788 ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8789 self._request = new_value;
8790 self
8791 }
8792 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8793 ///
8794 /// Sets the *resource* path property to the given value.
8795 ///
8796 /// Even though the property as already been set when instantiating this call,
8797 /// we provide this method for API completeness.
8798 pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8799 self._resource = new_value.to_string();
8800 self
8801 }
8802 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8803 /// while executing the actual API request.
8804 ///
8805 /// ````text
8806 /// It should be used to handle progress information, and to implement a certain level of resilience.
8807 /// ````
8808 ///
8809 /// Sets the *delegate* property to the given value.
8810 pub fn delegate(
8811 mut self,
8812 new_value: &'a mut dyn common::Delegate,
8813 ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8814 self._delegate = Some(new_value);
8815 self
8816 }
8817
8818 /// Set any additional parameter of the query string used in the request.
8819 /// It should be used to set parameters which are not yet available through their own
8820 /// setters.
8821 ///
8822 /// Please note that this method must not be used to set any of the known parameters
8823 /// which have their own setter method. If done anyway, the request will fail.
8824 ///
8825 /// # Additional Parameters
8826 ///
8827 /// * *$.xgafv* (query-string) - V1 error format.
8828 /// * *access_token* (query-string) - OAuth access token.
8829 /// * *alt* (query-string) - Data format for response.
8830 /// * *callback* (query-string) - JSONP
8831 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8832 /// * *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.
8833 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8834 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8835 /// * *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.
8836 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8837 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8838 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
8839 where
8840 T: AsRef<str>,
8841 {
8842 self._additional_params
8843 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8844 self
8845 }
8846
8847 /// Identifies the authorization scope for the method you are building.
8848 ///
8849 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8850 /// [`Scope::CloudPlatform`].
8851 ///
8852 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8853 /// tokens for more than one scope.
8854 ///
8855 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8856 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8857 /// sufficient, a read-write scope will do as well.
8858 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
8859 where
8860 St: AsRef<str>,
8861 {
8862 self._scopes.insert(String::from(scope.as_ref()));
8863 self
8864 }
8865 /// Identifies the authorization scope(s) for the method you are building.
8866 ///
8867 /// See [`Self::add_scope()`] for details.
8868 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
8869 where
8870 I: IntoIterator<Item = St>,
8871 St: AsRef<str>,
8872 {
8873 self._scopes
8874 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8875 self
8876 }
8877
8878 /// Removes all scopes, and no default scope will be used either.
8879 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8880 /// for details).
8881 pub fn clear_scopes(mut self) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8882 self._scopes.clear();
8883 self
8884 }
8885}
8886
8887/// Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
8888///
8889/// A builder for the *locations.queues.testIamPermissions* method supported by a *project* resource.
8890/// It is not used directly, but through a [`ProjectMethods`] instance.
8891///
8892/// # Example
8893///
8894/// Instantiate a resource method builder
8895///
8896/// ```test_harness,no_run
8897/// # extern crate hyper;
8898/// # extern crate hyper_rustls;
8899/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
8900/// use cloudtasks2_beta2::api::TestIamPermissionsRequest;
8901/// # async fn dox() {
8902/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8903///
8904/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8905/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8906/// # .with_native_roots()
8907/// # .unwrap()
8908/// # .https_only()
8909/// # .enable_http2()
8910/// # .build();
8911///
8912/// # let executor = hyper_util::rt::TokioExecutor::new();
8913/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8914/// # secret,
8915/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8916/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8917/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8918/// # ),
8919/// # ).build().await.unwrap();
8920///
8921/// # let client = hyper_util::client::legacy::Client::builder(
8922/// # hyper_util::rt::TokioExecutor::new()
8923/// # )
8924/// # .build(
8925/// # hyper_rustls::HttpsConnectorBuilder::new()
8926/// # .with_native_roots()
8927/// # .unwrap()
8928/// # .https_or_http()
8929/// # .enable_http2()
8930/// # .build()
8931/// # );
8932/// # let mut hub = CloudTasks::new(client, auth);
8933/// // As the method needs a request, you would usually fill it with the desired information
8934/// // into the respective structure. Some of the parts shown here might not be applicable !
8935/// // Values shown here are possibly random and not representative !
8936/// let mut req = TestIamPermissionsRequest::default();
8937///
8938/// // You can configure optional parameters by calling the respective setters at will, and
8939/// // execute the final call using `doit()`.
8940/// // Values shown here are possibly random and not representative !
8941/// let result = hub.projects().locations_queues_test_iam_permissions(req, "resource")
8942/// .doit().await;
8943/// # }
8944/// ```
8945pub struct ProjectLocationQueueTestIamPermissionCall<'a, C>
8946where
8947 C: 'a,
8948{
8949 hub: &'a CloudTasks<C>,
8950 _request: TestIamPermissionsRequest,
8951 _resource: String,
8952 _delegate: Option<&'a mut dyn common::Delegate>,
8953 _additional_params: HashMap<String, String>,
8954 _scopes: BTreeSet<String>,
8955}
8956
8957impl<'a, C> common::CallBuilder for ProjectLocationQueueTestIamPermissionCall<'a, C> {}
8958
8959impl<'a, C> ProjectLocationQueueTestIamPermissionCall<'a, C>
8960where
8961 C: common::Connector,
8962{
8963 /// Perform the operation you have build so far.
8964 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8965 use std::borrow::Cow;
8966 use std::io::{Read, Seek};
8967
8968 use common::{url::Params, ToParts};
8969 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8970
8971 let mut dd = common::DefaultDelegate;
8972 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8973 dlg.begin(common::MethodInfo {
8974 id: "cloudtasks.projects.locations.queues.testIamPermissions",
8975 http_method: hyper::Method::POST,
8976 });
8977
8978 for &field in ["alt", "resource"].iter() {
8979 if self._additional_params.contains_key(field) {
8980 dlg.finished(false);
8981 return Err(common::Error::FieldClash(field));
8982 }
8983 }
8984
8985 let mut params = Params::with_capacity(4 + self._additional_params.len());
8986 params.push("resource", self._resource);
8987
8988 params.extend(self._additional_params.iter());
8989
8990 params.push("alt", "json");
8991 let mut url = self.hub._base_url.clone() + "v2beta2/{+resource}:testIamPermissions";
8992 if self._scopes.is_empty() {
8993 self._scopes
8994 .insert(Scope::CloudPlatform.as_ref().to_string());
8995 }
8996
8997 #[allow(clippy::single_element_loop)]
8998 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8999 url = params.uri_replacement(url, param_name, find_this, true);
9000 }
9001 {
9002 let to_remove = ["resource"];
9003 params.remove_params(&to_remove);
9004 }
9005
9006 let url = params.parse_with_url(&url);
9007
9008 let mut json_mime_type = mime::APPLICATION_JSON;
9009 let mut request_value_reader = {
9010 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9011 common::remove_json_null_values(&mut value);
9012 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9013 serde_json::to_writer(&mut dst, &value).unwrap();
9014 dst
9015 };
9016 let request_size = request_value_reader
9017 .seek(std::io::SeekFrom::End(0))
9018 .unwrap();
9019 request_value_reader
9020 .seek(std::io::SeekFrom::Start(0))
9021 .unwrap();
9022
9023 loop {
9024 let token = match self
9025 .hub
9026 .auth
9027 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9028 .await
9029 {
9030 Ok(token) => token,
9031 Err(e) => match dlg.token(e) {
9032 Ok(token) => token,
9033 Err(e) => {
9034 dlg.finished(false);
9035 return Err(common::Error::MissingToken(e));
9036 }
9037 },
9038 };
9039 request_value_reader
9040 .seek(std::io::SeekFrom::Start(0))
9041 .unwrap();
9042 let mut req_result = {
9043 let client = &self.hub.client;
9044 dlg.pre_request();
9045 let mut req_builder = hyper::Request::builder()
9046 .method(hyper::Method::POST)
9047 .uri(url.as_str())
9048 .header(USER_AGENT, self.hub._user_agent.clone());
9049
9050 if let Some(token) = token.as_ref() {
9051 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9052 }
9053
9054 let request = req_builder
9055 .header(CONTENT_TYPE, json_mime_type.to_string())
9056 .header(CONTENT_LENGTH, request_size as u64)
9057 .body(common::to_body(
9058 request_value_reader.get_ref().clone().into(),
9059 ));
9060
9061 client.request(request.unwrap()).await
9062 };
9063
9064 match req_result {
9065 Err(err) => {
9066 if let common::Retry::After(d) = dlg.http_error(&err) {
9067 sleep(d).await;
9068 continue;
9069 }
9070 dlg.finished(false);
9071 return Err(common::Error::HttpError(err));
9072 }
9073 Ok(res) => {
9074 let (mut parts, body) = res.into_parts();
9075 let mut body = common::Body::new(body);
9076 if !parts.status.is_success() {
9077 let bytes = common::to_bytes(body).await.unwrap_or_default();
9078 let error = serde_json::from_str(&common::to_string(&bytes));
9079 let response = common::to_response(parts, bytes.into());
9080
9081 if let common::Retry::After(d) =
9082 dlg.http_failure(&response, error.as_ref().ok())
9083 {
9084 sleep(d).await;
9085 continue;
9086 }
9087
9088 dlg.finished(false);
9089
9090 return Err(match error {
9091 Ok(value) => common::Error::BadRequest(value),
9092 _ => common::Error::Failure(response),
9093 });
9094 }
9095 let response = {
9096 let bytes = common::to_bytes(body).await.unwrap_or_default();
9097 let encoded = common::to_string(&bytes);
9098 match serde_json::from_str(&encoded) {
9099 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9100 Err(error) => {
9101 dlg.response_json_decode_error(&encoded, &error);
9102 return Err(common::Error::JsonDecodeError(
9103 encoded.to_string(),
9104 error,
9105 ));
9106 }
9107 }
9108 };
9109
9110 dlg.finished(true);
9111 return Ok(response);
9112 }
9113 }
9114 }
9115 }
9116
9117 ///
9118 /// Sets the *request* property to the given value.
9119 ///
9120 /// Even though the property as already been set when instantiating this call,
9121 /// we provide this method for API completeness.
9122 pub fn request(
9123 mut self,
9124 new_value: TestIamPermissionsRequest,
9125 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
9126 self._request = new_value;
9127 self
9128 }
9129 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
9130 ///
9131 /// Sets the *resource* path property to the given value.
9132 ///
9133 /// Even though the property as already been set when instantiating this call,
9134 /// we provide this method for API completeness.
9135 pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
9136 self._resource = new_value.to_string();
9137 self
9138 }
9139 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9140 /// while executing the actual API request.
9141 ///
9142 /// ````text
9143 /// It should be used to handle progress information, and to implement a certain level of resilience.
9144 /// ````
9145 ///
9146 /// Sets the *delegate* property to the given value.
9147 pub fn delegate(
9148 mut self,
9149 new_value: &'a mut dyn common::Delegate,
9150 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
9151 self._delegate = Some(new_value);
9152 self
9153 }
9154
9155 /// Set any additional parameter of the query string used in the request.
9156 /// It should be used to set parameters which are not yet available through their own
9157 /// setters.
9158 ///
9159 /// Please note that this method must not be used to set any of the known parameters
9160 /// which have their own setter method. If done anyway, the request will fail.
9161 ///
9162 /// # Additional Parameters
9163 ///
9164 /// * *$.xgafv* (query-string) - V1 error format.
9165 /// * *access_token* (query-string) - OAuth access token.
9166 /// * *alt* (query-string) - Data format for response.
9167 /// * *callback* (query-string) - JSONP
9168 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9169 /// * *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.
9170 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9171 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9172 /// * *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.
9173 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9174 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9175 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
9176 where
9177 T: AsRef<str>,
9178 {
9179 self._additional_params
9180 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9181 self
9182 }
9183
9184 /// Identifies the authorization scope for the method you are building.
9185 ///
9186 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9187 /// [`Scope::CloudPlatform`].
9188 ///
9189 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9190 /// tokens for more than one scope.
9191 ///
9192 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9193 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9194 /// sufficient, a read-write scope will do as well.
9195 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
9196 where
9197 St: AsRef<str>,
9198 {
9199 self._scopes.insert(String::from(scope.as_ref()));
9200 self
9201 }
9202 /// Identifies the authorization scope(s) for the method you are building.
9203 ///
9204 /// See [`Self::add_scope()`] for details.
9205 pub fn add_scopes<I, St>(
9206 mut self,
9207 scopes: I,
9208 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
9209 where
9210 I: IntoIterator<Item = St>,
9211 St: AsRef<str>,
9212 {
9213 self._scopes
9214 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9215 self
9216 }
9217
9218 /// Removes all scopes, and no default scope will be used either.
9219 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9220 /// for details).
9221 pub fn clear_scopes(mut self) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
9222 self._scopes.clear();
9223 self
9224 }
9225}
9226
9227/// Gets information about a location.
9228///
9229/// A builder for the *locations.get* method supported by a *project* resource.
9230/// It is not used directly, but through a [`ProjectMethods`] instance.
9231///
9232/// # Example
9233///
9234/// Instantiate a resource method builder
9235///
9236/// ```test_harness,no_run
9237/// # extern crate hyper;
9238/// # extern crate hyper_rustls;
9239/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
9240/// # async fn dox() {
9241/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9242///
9243/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9244/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9245/// # .with_native_roots()
9246/// # .unwrap()
9247/// # .https_only()
9248/// # .enable_http2()
9249/// # .build();
9250///
9251/// # let executor = hyper_util::rt::TokioExecutor::new();
9252/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9253/// # secret,
9254/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9255/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9256/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9257/// # ),
9258/// # ).build().await.unwrap();
9259///
9260/// # let client = hyper_util::client::legacy::Client::builder(
9261/// # hyper_util::rt::TokioExecutor::new()
9262/// # )
9263/// # .build(
9264/// # hyper_rustls::HttpsConnectorBuilder::new()
9265/// # .with_native_roots()
9266/// # .unwrap()
9267/// # .https_or_http()
9268/// # .enable_http2()
9269/// # .build()
9270/// # );
9271/// # let mut hub = CloudTasks::new(client, auth);
9272/// // You can configure optional parameters by calling the respective setters at will, and
9273/// // execute the final call using `doit()`.
9274/// // Values shown here are possibly random and not representative !
9275/// let result = hub.projects().locations_get("name")
9276/// .doit().await;
9277/// # }
9278/// ```
9279pub struct ProjectLocationGetCall<'a, C>
9280where
9281 C: 'a,
9282{
9283 hub: &'a CloudTasks<C>,
9284 _name: String,
9285 _delegate: Option<&'a mut dyn common::Delegate>,
9286 _additional_params: HashMap<String, String>,
9287 _scopes: BTreeSet<String>,
9288}
9289
9290impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
9291
9292impl<'a, C> ProjectLocationGetCall<'a, C>
9293where
9294 C: common::Connector,
9295{
9296 /// Perform the operation you have build so far.
9297 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
9298 use std::borrow::Cow;
9299 use std::io::{Read, Seek};
9300
9301 use common::{url::Params, ToParts};
9302 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9303
9304 let mut dd = common::DefaultDelegate;
9305 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9306 dlg.begin(common::MethodInfo {
9307 id: "cloudtasks.projects.locations.get",
9308 http_method: hyper::Method::GET,
9309 });
9310
9311 for &field in ["alt", "name"].iter() {
9312 if self._additional_params.contains_key(field) {
9313 dlg.finished(false);
9314 return Err(common::Error::FieldClash(field));
9315 }
9316 }
9317
9318 let mut params = Params::with_capacity(3 + self._additional_params.len());
9319 params.push("name", self._name);
9320
9321 params.extend(self._additional_params.iter());
9322
9323 params.push("alt", "json");
9324 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
9325 if self._scopes.is_empty() {
9326 self._scopes
9327 .insert(Scope::CloudPlatform.as_ref().to_string());
9328 }
9329
9330 #[allow(clippy::single_element_loop)]
9331 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9332 url = params.uri_replacement(url, param_name, find_this, true);
9333 }
9334 {
9335 let to_remove = ["name"];
9336 params.remove_params(&to_remove);
9337 }
9338
9339 let url = params.parse_with_url(&url);
9340
9341 loop {
9342 let token = match self
9343 .hub
9344 .auth
9345 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9346 .await
9347 {
9348 Ok(token) => token,
9349 Err(e) => match dlg.token(e) {
9350 Ok(token) => token,
9351 Err(e) => {
9352 dlg.finished(false);
9353 return Err(common::Error::MissingToken(e));
9354 }
9355 },
9356 };
9357 let mut req_result = {
9358 let client = &self.hub.client;
9359 dlg.pre_request();
9360 let mut req_builder = hyper::Request::builder()
9361 .method(hyper::Method::GET)
9362 .uri(url.as_str())
9363 .header(USER_AGENT, self.hub._user_agent.clone());
9364
9365 if let Some(token) = token.as_ref() {
9366 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9367 }
9368
9369 let request = req_builder
9370 .header(CONTENT_LENGTH, 0_u64)
9371 .body(common::to_body::<String>(None));
9372
9373 client.request(request.unwrap()).await
9374 };
9375
9376 match req_result {
9377 Err(err) => {
9378 if let common::Retry::After(d) = dlg.http_error(&err) {
9379 sleep(d).await;
9380 continue;
9381 }
9382 dlg.finished(false);
9383 return Err(common::Error::HttpError(err));
9384 }
9385 Ok(res) => {
9386 let (mut parts, body) = res.into_parts();
9387 let mut body = common::Body::new(body);
9388 if !parts.status.is_success() {
9389 let bytes = common::to_bytes(body).await.unwrap_or_default();
9390 let error = serde_json::from_str(&common::to_string(&bytes));
9391 let response = common::to_response(parts, bytes.into());
9392
9393 if let common::Retry::After(d) =
9394 dlg.http_failure(&response, error.as_ref().ok())
9395 {
9396 sleep(d).await;
9397 continue;
9398 }
9399
9400 dlg.finished(false);
9401
9402 return Err(match error {
9403 Ok(value) => common::Error::BadRequest(value),
9404 _ => common::Error::Failure(response),
9405 });
9406 }
9407 let response = {
9408 let bytes = common::to_bytes(body).await.unwrap_or_default();
9409 let encoded = common::to_string(&bytes);
9410 match serde_json::from_str(&encoded) {
9411 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9412 Err(error) => {
9413 dlg.response_json_decode_error(&encoded, &error);
9414 return Err(common::Error::JsonDecodeError(
9415 encoded.to_string(),
9416 error,
9417 ));
9418 }
9419 }
9420 };
9421
9422 dlg.finished(true);
9423 return Ok(response);
9424 }
9425 }
9426 }
9427 }
9428
9429 /// Resource name for the location.
9430 ///
9431 /// Sets the *name* path property to the given value.
9432 ///
9433 /// Even though the property as already been set when instantiating this call,
9434 /// we provide this method for API completeness.
9435 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
9436 self._name = new_value.to_string();
9437 self
9438 }
9439 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9440 /// while executing the actual API request.
9441 ///
9442 /// ````text
9443 /// It should be used to handle progress information, and to implement a certain level of resilience.
9444 /// ````
9445 ///
9446 /// Sets the *delegate* property to the given value.
9447 pub fn delegate(
9448 mut self,
9449 new_value: &'a mut dyn common::Delegate,
9450 ) -> ProjectLocationGetCall<'a, C> {
9451 self._delegate = Some(new_value);
9452 self
9453 }
9454
9455 /// Set any additional parameter of the query string used in the request.
9456 /// It should be used to set parameters which are not yet available through their own
9457 /// setters.
9458 ///
9459 /// Please note that this method must not be used to set any of the known parameters
9460 /// which have their own setter method. If done anyway, the request will fail.
9461 ///
9462 /// # Additional Parameters
9463 ///
9464 /// * *$.xgafv* (query-string) - V1 error format.
9465 /// * *access_token* (query-string) - OAuth access token.
9466 /// * *alt* (query-string) - Data format for response.
9467 /// * *callback* (query-string) - JSONP
9468 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9469 /// * *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.
9470 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9471 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9472 /// * *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.
9473 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9474 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9475 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
9476 where
9477 T: AsRef<str>,
9478 {
9479 self._additional_params
9480 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9481 self
9482 }
9483
9484 /// Identifies the authorization scope for the method you are building.
9485 ///
9486 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9487 /// [`Scope::CloudPlatform`].
9488 ///
9489 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9490 /// tokens for more than one scope.
9491 ///
9492 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9493 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9494 /// sufficient, a read-write scope will do as well.
9495 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
9496 where
9497 St: AsRef<str>,
9498 {
9499 self._scopes.insert(String::from(scope.as_ref()));
9500 self
9501 }
9502 /// Identifies the authorization scope(s) for the method you are building.
9503 ///
9504 /// See [`Self::add_scope()`] for details.
9505 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
9506 where
9507 I: IntoIterator<Item = St>,
9508 St: AsRef<str>,
9509 {
9510 self._scopes
9511 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9512 self
9513 }
9514
9515 /// Removes all scopes, and no default scope will be used either.
9516 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9517 /// for details).
9518 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
9519 self._scopes.clear();
9520 self
9521 }
9522}
9523
9524/// Gets the CMEK config. Gets the Customer Managed Encryption Key configured with the Cloud Tasks lcoation. By default there is no kms_key configured.
9525///
9526/// A builder for the *locations.getCmekConfig* method supported by a *project* resource.
9527/// It is not used directly, but through a [`ProjectMethods`] instance.
9528///
9529/// # Example
9530///
9531/// Instantiate a resource method builder
9532///
9533/// ```test_harness,no_run
9534/// # extern crate hyper;
9535/// # extern crate hyper_rustls;
9536/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
9537/// # async fn dox() {
9538/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9539///
9540/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9541/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9542/// # .with_native_roots()
9543/// # .unwrap()
9544/// # .https_only()
9545/// # .enable_http2()
9546/// # .build();
9547///
9548/// # let executor = hyper_util::rt::TokioExecutor::new();
9549/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9550/// # secret,
9551/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9552/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9553/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9554/// # ),
9555/// # ).build().await.unwrap();
9556///
9557/// # let client = hyper_util::client::legacy::Client::builder(
9558/// # hyper_util::rt::TokioExecutor::new()
9559/// # )
9560/// # .build(
9561/// # hyper_rustls::HttpsConnectorBuilder::new()
9562/// # .with_native_roots()
9563/// # .unwrap()
9564/// # .https_or_http()
9565/// # .enable_http2()
9566/// # .build()
9567/// # );
9568/// # let mut hub = CloudTasks::new(client, auth);
9569/// // You can configure optional parameters by calling the respective setters at will, and
9570/// // execute the final call using `doit()`.
9571/// // Values shown here are possibly random and not representative !
9572/// let result = hub.projects().locations_get_cmek_config("name")
9573/// .doit().await;
9574/// # }
9575/// ```
9576pub struct ProjectLocationGetCmekConfigCall<'a, C>
9577where
9578 C: 'a,
9579{
9580 hub: &'a CloudTasks<C>,
9581 _name: String,
9582 _delegate: Option<&'a mut dyn common::Delegate>,
9583 _additional_params: HashMap<String, String>,
9584 _scopes: BTreeSet<String>,
9585}
9586
9587impl<'a, C> common::CallBuilder for ProjectLocationGetCmekConfigCall<'a, C> {}
9588
9589impl<'a, C> ProjectLocationGetCmekConfigCall<'a, C>
9590where
9591 C: common::Connector,
9592{
9593 /// Perform the operation you have build so far.
9594 pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
9595 use std::borrow::Cow;
9596 use std::io::{Read, Seek};
9597
9598 use common::{url::Params, ToParts};
9599 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9600
9601 let mut dd = common::DefaultDelegate;
9602 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9603 dlg.begin(common::MethodInfo {
9604 id: "cloudtasks.projects.locations.getCmekConfig",
9605 http_method: hyper::Method::GET,
9606 });
9607
9608 for &field in ["alt", "name"].iter() {
9609 if self._additional_params.contains_key(field) {
9610 dlg.finished(false);
9611 return Err(common::Error::FieldClash(field));
9612 }
9613 }
9614
9615 let mut params = Params::with_capacity(3 + self._additional_params.len());
9616 params.push("name", self._name);
9617
9618 params.extend(self._additional_params.iter());
9619
9620 params.push("alt", "json");
9621 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
9622 if self._scopes.is_empty() {
9623 self._scopes
9624 .insert(Scope::CloudPlatform.as_ref().to_string());
9625 }
9626
9627 #[allow(clippy::single_element_loop)]
9628 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9629 url = params.uri_replacement(url, param_name, find_this, true);
9630 }
9631 {
9632 let to_remove = ["name"];
9633 params.remove_params(&to_remove);
9634 }
9635
9636 let url = params.parse_with_url(&url);
9637
9638 loop {
9639 let token = match self
9640 .hub
9641 .auth
9642 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9643 .await
9644 {
9645 Ok(token) => token,
9646 Err(e) => match dlg.token(e) {
9647 Ok(token) => token,
9648 Err(e) => {
9649 dlg.finished(false);
9650 return Err(common::Error::MissingToken(e));
9651 }
9652 },
9653 };
9654 let mut req_result = {
9655 let client = &self.hub.client;
9656 dlg.pre_request();
9657 let mut req_builder = hyper::Request::builder()
9658 .method(hyper::Method::GET)
9659 .uri(url.as_str())
9660 .header(USER_AGENT, self.hub._user_agent.clone());
9661
9662 if let Some(token) = token.as_ref() {
9663 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9664 }
9665
9666 let request = req_builder
9667 .header(CONTENT_LENGTH, 0_u64)
9668 .body(common::to_body::<String>(None));
9669
9670 client.request(request.unwrap()).await
9671 };
9672
9673 match req_result {
9674 Err(err) => {
9675 if let common::Retry::After(d) = dlg.http_error(&err) {
9676 sleep(d).await;
9677 continue;
9678 }
9679 dlg.finished(false);
9680 return Err(common::Error::HttpError(err));
9681 }
9682 Ok(res) => {
9683 let (mut parts, body) = res.into_parts();
9684 let mut body = common::Body::new(body);
9685 if !parts.status.is_success() {
9686 let bytes = common::to_bytes(body).await.unwrap_or_default();
9687 let error = serde_json::from_str(&common::to_string(&bytes));
9688 let response = common::to_response(parts, bytes.into());
9689
9690 if let common::Retry::After(d) =
9691 dlg.http_failure(&response, error.as_ref().ok())
9692 {
9693 sleep(d).await;
9694 continue;
9695 }
9696
9697 dlg.finished(false);
9698
9699 return Err(match error {
9700 Ok(value) => common::Error::BadRequest(value),
9701 _ => common::Error::Failure(response),
9702 });
9703 }
9704 let response = {
9705 let bytes = common::to_bytes(body).await.unwrap_or_default();
9706 let encoded = common::to_string(&bytes);
9707 match serde_json::from_str(&encoded) {
9708 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9709 Err(error) => {
9710 dlg.response_json_decode_error(&encoded, &error);
9711 return Err(common::Error::JsonDecodeError(
9712 encoded.to_string(),
9713 error,
9714 ));
9715 }
9716 }
9717 };
9718
9719 dlg.finished(true);
9720 return Ok(response);
9721 }
9722 }
9723 }
9724 }
9725
9726 /// Required. The config. For example: projects/PROJECT_ID/locations/LOCATION_ID/CmekConfig`
9727 ///
9728 /// Sets the *name* path property to the given value.
9729 ///
9730 /// Even though the property as already been set when instantiating this call,
9731 /// we provide this method for API completeness.
9732 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
9733 self._name = new_value.to_string();
9734 self
9735 }
9736 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9737 /// while executing the actual API request.
9738 ///
9739 /// ````text
9740 /// It should be used to handle progress information, and to implement a certain level of resilience.
9741 /// ````
9742 ///
9743 /// Sets the *delegate* property to the given value.
9744 pub fn delegate(
9745 mut self,
9746 new_value: &'a mut dyn common::Delegate,
9747 ) -> ProjectLocationGetCmekConfigCall<'a, C> {
9748 self._delegate = Some(new_value);
9749 self
9750 }
9751
9752 /// Set any additional parameter of the query string used in the request.
9753 /// It should be used to set parameters which are not yet available through their own
9754 /// setters.
9755 ///
9756 /// Please note that this method must not be used to set any of the known parameters
9757 /// which have their own setter method. If done anyway, the request will fail.
9758 ///
9759 /// # Additional Parameters
9760 ///
9761 /// * *$.xgafv* (query-string) - V1 error format.
9762 /// * *access_token* (query-string) - OAuth access token.
9763 /// * *alt* (query-string) - Data format for response.
9764 /// * *callback* (query-string) - JSONP
9765 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9766 /// * *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.
9767 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9768 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9769 /// * *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.
9770 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9771 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9772 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCmekConfigCall<'a, C>
9773 where
9774 T: AsRef<str>,
9775 {
9776 self._additional_params
9777 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9778 self
9779 }
9780
9781 /// Identifies the authorization scope for the method you are building.
9782 ///
9783 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9784 /// [`Scope::CloudPlatform`].
9785 ///
9786 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9787 /// tokens for more than one scope.
9788 ///
9789 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9790 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9791 /// sufficient, a read-write scope will do as well.
9792 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCmekConfigCall<'a, C>
9793 where
9794 St: AsRef<str>,
9795 {
9796 self._scopes.insert(String::from(scope.as_ref()));
9797 self
9798 }
9799 /// Identifies the authorization scope(s) for the method you are building.
9800 ///
9801 /// See [`Self::add_scope()`] for details.
9802 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCmekConfigCall<'a, C>
9803 where
9804 I: IntoIterator<Item = St>,
9805 St: AsRef<str>,
9806 {
9807 self._scopes
9808 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9809 self
9810 }
9811
9812 /// Removes all scopes, and no default scope will be used either.
9813 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9814 /// for details).
9815 pub fn clear_scopes(mut self) -> ProjectLocationGetCmekConfigCall<'a, C> {
9816 self._scopes.clear();
9817 self
9818 }
9819}
9820
9821/// Lists information about the supported locations for this service.
9822///
9823/// A builder for the *locations.list* method supported by a *project* resource.
9824/// It is not used directly, but through a [`ProjectMethods`] instance.
9825///
9826/// # Example
9827///
9828/// Instantiate a resource method builder
9829///
9830/// ```test_harness,no_run
9831/// # extern crate hyper;
9832/// # extern crate hyper_rustls;
9833/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
9834/// # async fn dox() {
9835/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9836///
9837/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9838/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9839/// # .with_native_roots()
9840/// # .unwrap()
9841/// # .https_only()
9842/// # .enable_http2()
9843/// # .build();
9844///
9845/// # let executor = hyper_util::rt::TokioExecutor::new();
9846/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9847/// # secret,
9848/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9849/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9850/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9851/// # ),
9852/// # ).build().await.unwrap();
9853///
9854/// # let client = hyper_util::client::legacy::Client::builder(
9855/// # hyper_util::rt::TokioExecutor::new()
9856/// # )
9857/// # .build(
9858/// # hyper_rustls::HttpsConnectorBuilder::new()
9859/// # .with_native_roots()
9860/// # .unwrap()
9861/// # .https_or_http()
9862/// # .enable_http2()
9863/// # .build()
9864/// # );
9865/// # let mut hub = CloudTasks::new(client, auth);
9866/// // You can configure optional parameters by calling the respective setters at will, and
9867/// // execute the final call using `doit()`.
9868/// // Values shown here are possibly random and not representative !
9869/// let result = hub.projects().locations_list("name")
9870/// .page_token("eos")
9871/// .page_size(-86)
9872/// .filter("sed")
9873/// .add_extra_location_types("duo")
9874/// .doit().await;
9875/// # }
9876/// ```
9877pub struct ProjectLocationListCall<'a, C>
9878where
9879 C: 'a,
9880{
9881 hub: &'a CloudTasks<C>,
9882 _name: String,
9883 _page_token: Option<String>,
9884 _page_size: Option<i32>,
9885 _filter: Option<String>,
9886 _extra_location_types: Vec<String>,
9887 _delegate: Option<&'a mut dyn common::Delegate>,
9888 _additional_params: HashMap<String, String>,
9889 _scopes: BTreeSet<String>,
9890}
9891
9892impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
9893
9894impl<'a, C> ProjectLocationListCall<'a, C>
9895where
9896 C: common::Connector,
9897{
9898 /// Perform the operation you have build so far.
9899 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
9900 use std::borrow::Cow;
9901 use std::io::{Read, Seek};
9902
9903 use common::{url::Params, ToParts};
9904 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9905
9906 let mut dd = common::DefaultDelegate;
9907 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9908 dlg.begin(common::MethodInfo {
9909 id: "cloudtasks.projects.locations.list",
9910 http_method: hyper::Method::GET,
9911 });
9912
9913 for &field in [
9914 "alt",
9915 "name",
9916 "pageToken",
9917 "pageSize",
9918 "filter",
9919 "extraLocationTypes",
9920 ]
9921 .iter()
9922 {
9923 if self._additional_params.contains_key(field) {
9924 dlg.finished(false);
9925 return Err(common::Error::FieldClash(field));
9926 }
9927 }
9928
9929 let mut params = Params::with_capacity(7 + self._additional_params.len());
9930 params.push("name", self._name);
9931 if let Some(value) = self._page_token.as_ref() {
9932 params.push("pageToken", value);
9933 }
9934 if let Some(value) = self._page_size.as_ref() {
9935 params.push("pageSize", value.to_string());
9936 }
9937 if let Some(value) = self._filter.as_ref() {
9938 params.push("filter", value);
9939 }
9940 if !self._extra_location_types.is_empty() {
9941 for f in self._extra_location_types.iter() {
9942 params.push("extraLocationTypes", f);
9943 }
9944 }
9945
9946 params.extend(self._additional_params.iter());
9947
9948 params.push("alt", "json");
9949 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}/locations";
9950 if self._scopes.is_empty() {
9951 self._scopes
9952 .insert(Scope::CloudPlatform.as_ref().to_string());
9953 }
9954
9955 #[allow(clippy::single_element_loop)]
9956 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9957 url = params.uri_replacement(url, param_name, find_this, true);
9958 }
9959 {
9960 let to_remove = ["name"];
9961 params.remove_params(&to_remove);
9962 }
9963
9964 let url = params.parse_with_url(&url);
9965
9966 loop {
9967 let token = match self
9968 .hub
9969 .auth
9970 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9971 .await
9972 {
9973 Ok(token) => token,
9974 Err(e) => match dlg.token(e) {
9975 Ok(token) => token,
9976 Err(e) => {
9977 dlg.finished(false);
9978 return Err(common::Error::MissingToken(e));
9979 }
9980 },
9981 };
9982 let mut req_result = {
9983 let client = &self.hub.client;
9984 dlg.pre_request();
9985 let mut req_builder = hyper::Request::builder()
9986 .method(hyper::Method::GET)
9987 .uri(url.as_str())
9988 .header(USER_AGENT, self.hub._user_agent.clone());
9989
9990 if let Some(token) = token.as_ref() {
9991 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9992 }
9993
9994 let request = req_builder
9995 .header(CONTENT_LENGTH, 0_u64)
9996 .body(common::to_body::<String>(None));
9997
9998 client.request(request.unwrap()).await
9999 };
10000
10001 match req_result {
10002 Err(err) => {
10003 if let common::Retry::After(d) = dlg.http_error(&err) {
10004 sleep(d).await;
10005 continue;
10006 }
10007 dlg.finished(false);
10008 return Err(common::Error::HttpError(err));
10009 }
10010 Ok(res) => {
10011 let (mut parts, body) = res.into_parts();
10012 let mut body = common::Body::new(body);
10013 if !parts.status.is_success() {
10014 let bytes = common::to_bytes(body).await.unwrap_or_default();
10015 let error = serde_json::from_str(&common::to_string(&bytes));
10016 let response = common::to_response(parts, bytes.into());
10017
10018 if let common::Retry::After(d) =
10019 dlg.http_failure(&response, error.as_ref().ok())
10020 {
10021 sleep(d).await;
10022 continue;
10023 }
10024
10025 dlg.finished(false);
10026
10027 return Err(match error {
10028 Ok(value) => common::Error::BadRequest(value),
10029 _ => common::Error::Failure(response),
10030 });
10031 }
10032 let response = {
10033 let bytes = common::to_bytes(body).await.unwrap_or_default();
10034 let encoded = common::to_string(&bytes);
10035 match serde_json::from_str(&encoded) {
10036 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10037 Err(error) => {
10038 dlg.response_json_decode_error(&encoded, &error);
10039 return Err(common::Error::JsonDecodeError(
10040 encoded.to_string(),
10041 error,
10042 ));
10043 }
10044 }
10045 };
10046
10047 dlg.finished(true);
10048 return Ok(response);
10049 }
10050 }
10051 }
10052 }
10053
10054 /// The resource that owns the locations collection, if applicable.
10055 ///
10056 /// Sets the *name* path property to the given value.
10057 ///
10058 /// Even though the property as already been set when instantiating this call,
10059 /// we provide this method for API completeness.
10060 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10061 self._name = new_value.to_string();
10062 self
10063 }
10064 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
10065 ///
10066 /// Sets the *page token* query property to the given value.
10067 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10068 self._page_token = Some(new_value.to_string());
10069 self
10070 }
10071 /// The maximum number of results to return. If not set, the service selects a default.
10072 ///
10073 /// Sets the *page size* query property to the given value.
10074 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
10075 self._page_size = Some(new_value);
10076 self
10077 }
10078 /// 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).
10079 ///
10080 /// Sets the *filter* query property to the given value.
10081 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10082 self._filter = Some(new_value.to_string());
10083 self
10084 }
10085 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
10086 ///
10087 /// Append the given value to the *extra location types* query property.
10088 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10089 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10090 self._extra_location_types.push(new_value.to_string());
10091 self
10092 }
10093 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10094 /// while executing the actual API request.
10095 ///
10096 /// ````text
10097 /// It should be used to handle progress information, and to implement a certain level of resilience.
10098 /// ````
10099 ///
10100 /// Sets the *delegate* property to the given value.
10101 pub fn delegate(
10102 mut self,
10103 new_value: &'a mut dyn common::Delegate,
10104 ) -> ProjectLocationListCall<'a, C> {
10105 self._delegate = Some(new_value);
10106 self
10107 }
10108
10109 /// Set any additional parameter of the query string used in the request.
10110 /// It should be used to set parameters which are not yet available through their own
10111 /// setters.
10112 ///
10113 /// Please note that this method must not be used to set any of the known parameters
10114 /// which have their own setter method. If done anyway, the request will fail.
10115 ///
10116 /// # Additional Parameters
10117 ///
10118 /// * *$.xgafv* (query-string) - V1 error format.
10119 /// * *access_token* (query-string) - OAuth access token.
10120 /// * *alt* (query-string) - Data format for response.
10121 /// * *callback* (query-string) - JSONP
10122 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10123 /// * *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.
10124 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10125 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10126 /// * *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.
10127 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10128 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10129 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
10130 where
10131 T: AsRef<str>,
10132 {
10133 self._additional_params
10134 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10135 self
10136 }
10137
10138 /// Identifies the authorization scope for the method you are building.
10139 ///
10140 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10141 /// [`Scope::CloudPlatform`].
10142 ///
10143 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10144 /// tokens for more than one scope.
10145 ///
10146 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10147 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10148 /// sufficient, a read-write scope will do as well.
10149 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
10150 where
10151 St: AsRef<str>,
10152 {
10153 self._scopes.insert(String::from(scope.as_ref()));
10154 self
10155 }
10156 /// Identifies the authorization scope(s) for the method you are building.
10157 ///
10158 /// See [`Self::add_scope()`] for details.
10159 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
10160 where
10161 I: IntoIterator<Item = St>,
10162 St: AsRef<str>,
10163 {
10164 self._scopes
10165 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10166 self
10167 }
10168
10169 /// Removes all scopes, and no default scope will be used either.
10170 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10171 /// for details).
10172 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
10173 self._scopes.clear();
10174 self
10175 }
10176}
10177
10178/// Creates or Updates a CMEK config. Updates the Customer Managed Encryption Key assotiated with the Cloud Tasks location (Creates if the key does not already exist). All new tasks created in the location will be encrypted at-rest with the KMS-key provided in the config.
10179///
10180/// A builder for the *locations.updateCmekConfig* method supported by a *project* resource.
10181/// It is not used directly, but through a [`ProjectMethods`] instance.
10182///
10183/// # Example
10184///
10185/// Instantiate a resource method builder
10186///
10187/// ```test_harness,no_run
10188/// # extern crate hyper;
10189/// # extern crate hyper_rustls;
10190/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
10191/// use cloudtasks2_beta2::api::CmekConfig;
10192/// # async fn dox() {
10193/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10194///
10195/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10196/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10197/// # .with_native_roots()
10198/// # .unwrap()
10199/// # .https_only()
10200/// # .enable_http2()
10201/// # .build();
10202///
10203/// # let executor = hyper_util::rt::TokioExecutor::new();
10204/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10205/// # secret,
10206/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10207/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10208/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10209/// # ),
10210/// # ).build().await.unwrap();
10211///
10212/// # let client = hyper_util::client::legacy::Client::builder(
10213/// # hyper_util::rt::TokioExecutor::new()
10214/// # )
10215/// # .build(
10216/// # hyper_rustls::HttpsConnectorBuilder::new()
10217/// # .with_native_roots()
10218/// # .unwrap()
10219/// # .https_or_http()
10220/// # .enable_http2()
10221/// # .build()
10222/// # );
10223/// # let mut hub = CloudTasks::new(client, auth);
10224/// // As the method needs a request, you would usually fill it with the desired information
10225/// // into the respective structure. Some of the parts shown here might not be applicable !
10226/// // Values shown here are possibly random and not representative !
10227/// let mut req = CmekConfig::default();
10228///
10229/// // You can configure optional parameters by calling the respective setters at will, and
10230/// // execute the final call using `doit()`.
10231/// // Values shown here are possibly random and not representative !
10232/// let result = hub.projects().locations_update_cmek_config(req, "name")
10233/// .update_mask(FieldMask::new::<&str>(&[]))
10234/// .doit().await;
10235/// # }
10236/// ```
10237pub struct ProjectLocationUpdateCmekConfigCall<'a, C>
10238where
10239 C: 'a,
10240{
10241 hub: &'a CloudTasks<C>,
10242 _request: CmekConfig,
10243 _name: String,
10244 _update_mask: Option<common::FieldMask>,
10245 _delegate: Option<&'a mut dyn common::Delegate>,
10246 _additional_params: HashMap<String, String>,
10247 _scopes: BTreeSet<String>,
10248}
10249
10250impl<'a, C> common::CallBuilder for ProjectLocationUpdateCmekConfigCall<'a, C> {}
10251
10252impl<'a, C> ProjectLocationUpdateCmekConfigCall<'a, C>
10253where
10254 C: common::Connector,
10255{
10256 /// Perform the operation you have build so far.
10257 pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
10258 use std::borrow::Cow;
10259 use std::io::{Read, Seek};
10260
10261 use common::{url::Params, ToParts};
10262 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10263
10264 let mut dd = common::DefaultDelegate;
10265 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10266 dlg.begin(common::MethodInfo {
10267 id: "cloudtasks.projects.locations.updateCmekConfig",
10268 http_method: hyper::Method::PATCH,
10269 });
10270
10271 for &field in ["alt", "name", "updateMask"].iter() {
10272 if self._additional_params.contains_key(field) {
10273 dlg.finished(false);
10274 return Err(common::Error::FieldClash(field));
10275 }
10276 }
10277
10278 let mut params = Params::with_capacity(5 + self._additional_params.len());
10279 params.push("name", self._name);
10280 if let Some(value) = self._update_mask.as_ref() {
10281 params.push("updateMask", value.to_string());
10282 }
10283
10284 params.extend(self._additional_params.iter());
10285
10286 params.push("alt", "json");
10287 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
10288 if self._scopes.is_empty() {
10289 self._scopes
10290 .insert(Scope::CloudPlatform.as_ref().to_string());
10291 }
10292
10293 #[allow(clippy::single_element_loop)]
10294 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10295 url = params.uri_replacement(url, param_name, find_this, true);
10296 }
10297 {
10298 let to_remove = ["name"];
10299 params.remove_params(&to_remove);
10300 }
10301
10302 let url = params.parse_with_url(&url);
10303
10304 let mut json_mime_type = mime::APPLICATION_JSON;
10305 let mut request_value_reader = {
10306 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10307 common::remove_json_null_values(&mut value);
10308 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10309 serde_json::to_writer(&mut dst, &value).unwrap();
10310 dst
10311 };
10312 let request_size = request_value_reader
10313 .seek(std::io::SeekFrom::End(0))
10314 .unwrap();
10315 request_value_reader
10316 .seek(std::io::SeekFrom::Start(0))
10317 .unwrap();
10318
10319 loop {
10320 let token = match self
10321 .hub
10322 .auth
10323 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10324 .await
10325 {
10326 Ok(token) => token,
10327 Err(e) => match dlg.token(e) {
10328 Ok(token) => token,
10329 Err(e) => {
10330 dlg.finished(false);
10331 return Err(common::Error::MissingToken(e));
10332 }
10333 },
10334 };
10335 request_value_reader
10336 .seek(std::io::SeekFrom::Start(0))
10337 .unwrap();
10338 let mut req_result = {
10339 let client = &self.hub.client;
10340 dlg.pre_request();
10341 let mut req_builder = hyper::Request::builder()
10342 .method(hyper::Method::PATCH)
10343 .uri(url.as_str())
10344 .header(USER_AGENT, self.hub._user_agent.clone());
10345
10346 if let Some(token) = token.as_ref() {
10347 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10348 }
10349
10350 let request = req_builder
10351 .header(CONTENT_TYPE, json_mime_type.to_string())
10352 .header(CONTENT_LENGTH, request_size as u64)
10353 .body(common::to_body(
10354 request_value_reader.get_ref().clone().into(),
10355 ));
10356
10357 client.request(request.unwrap()).await
10358 };
10359
10360 match req_result {
10361 Err(err) => {
10362 if let common::Retry::After(d) = dlg.http_error(&err) {
10363 sleep(d).await;
10364 continue;
10365 }
10366 dlg.finished(false);
10367 return Err(common::Error::HttpError(err));
10368 }
10369 Ok(res) => {
10370 let (mut parts, body) = res.into_parts();
10371 let mut body = common::Body::new(body);
10372 if !parts.status.is_success() {
10373 let bytes = common::to_bytes(body).await.unwrap_or_default();
10374 let error = serde_json::from_str(&common::to_string(&bytes));
10375 let response = common::to_response(parts, bytes.into());
10376
10377 if let common::Retry::After(d) =
10378 dlg.http_failure(&response, error.as_ref().ok())
10379 {
10380 sleep(d).await;
10381 continue;
10382 }
10383
10384 dlg.finished(false);
10385
10386 return Err(match error {
10387 Ok(value) => common::Error::BadRequest(value),
10388 _ => common::Error::Failure(response),
10389 });
10390 }
10391 let response = {
10392 let bytes = common::to_bytes(body).await.unwrap_or_default();
10393 let encoded = common::to_string(&bytes);
10394 match serde_json::from_str(&encoded) {
10395 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10396 Err(error) => {
10397 dlg.response_json_decode_error(&encoded, &error);
10398 return Err(common::Error::JsonDecodeError(
10399 encoded.to_string(),
10400 error,
10401 ));
10402 }
10403 }
10404 };
10405
10406 dlg.finished(true);
10407 return Ok(response);
10408 }
10409 }
10410 }
10411 }
10412
10413 ///
10414 /// Sets the *request* property to the given value.
10415 ///
10416 /// Even though the property as already been set when instantiating this call,
10417 /// we provide this method for API completeness.
10418 pub fn request(mut self, new_value: CmekConfig) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10419 self._request = new_value;
10420 self
10421 }
10422 /// Output only. The config resource name which includes the project and location and must end in 'cmekConfig', in the format projects/PROJECT_ID/locations/LOCATION_ID/cmekConfig`
10423 ///
10424 /// Sets the *name* path property to the given value.
10425 ///
10426 /// Even though the property as already been set when instantiating this call,
10427 /// we provide this method for API completeness.
10428 pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10429 self._name = new_value.to_string();
10430 self
10431 }
10432 /// List of fields to be updated in this request.
10433 ///
10434 /// Sets the *update mask* query property to the given value.
10435 pub fn update_mask(
10436 mut self,
10437 new_value: common::FieldMask,
10438 ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10439 self._update_mask = Some(new_value);
10440 self
10441 }
10442 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10443 /// while executing the actual API request.
10444 ///
10445 /// ````text
10446 /// It should be used to handle progress information, and to implement a certain level of resilience.
10447 /// ````
10448 ///
10449 /// Sets the *delegate* property to the given value.
10450 pub fn delegate(
10451 mut self,
10452 new_value: &'a mut dyn common::Delegate,
10453 ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10454 self._delegate = Some(new_value);
10455 self
10456 }
10457
10458 /// Set any additional parameter of the query string used in the request.
10459 /// It should be used to set parameters which are not yet available through their own
10460 /// setters.
10461 ///
10462 /// Please note that this method must not be used to set any of the known parameters
10463 /// which have their own setter method. If done anyway, the request will fail.
10464 ///
10465 /// # Additional Parameters
10466 ///
10467 /// * *$.xgafv* (query-string) - V1 error format.
10468 /// * *access_token* (query-string) - OAuth access token.
10469 /// * *alt* (query-string) - Data format for response.
10470 /// * *callback* (query-string) - JSONP
10471 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10472 /// * *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.
10473 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10474 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10475 /// * *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.
10476 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10477 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10478 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateCmekConfigCall<'a, C>
10479 where
10480 T: AsRef<str>,
10481 {
10482 self._additional_params
10483 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10484 self
10485 }
10486
10487 /// Identifies the authorization scope for the method you are building.
10488 ///
10489 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10490 /// [`Scope::CloudPlatform`].
10491 ///
10492 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10493 /// tokens for more than one scope.
10494 ///
10495 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10496 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10497 /// sufficient, a read-write scope will do as well.
10498 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateCmekConfigCall<'a, C>
10499 where
10500 St: AsRef<str>,
10501 {
10502 self._scopes.insert(String::from(scope.as_ref()));
10503 self
10504 }
10505 /// Identifies the authorization scope(s) for the method you are building.
10506 ///
10507 /// See [`Self::add_scope()`] for details.
10508 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateCmekConfigCall<'a, C>
10509 where
10510 I: IntoIterator<Item = St>,
10511 St: AsRef<str>,
10512 {
10513 self._scopes
10514 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10515 self
10516 }
10517
10518 /// Removes all scopes, and no default scope will be used either.
10519 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10520 /// for details).
10521 pub fn clear_scopes(mut self) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10522 self._scopes.clear();
10523 self
10524 }
10525}