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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = CloudTasks::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Queue::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_queues_patch(req, "name")
88/// .update_mask(FieldMask::new::<&str>(&[]))
89/// .doit().await;
90///
91/// match result {
92/// Err(e) => match e {
93/// // The Error enum provides details about what exactly happened.
94/// // You can also just use its `Debug`, `Display` or `Error` traits
95/// Error::HttpError(_)
96/// |Error::Io(_)
97/// |Error::MissingAPIKey
98/// |Error::MissingToken(_)
99/// |Error::Cancelled
100/// |Error::UploadSizeLimitExceeded(_, _)
101/// |Error::Failure(_)
102/// |Error::BadRequest(_)
103/// |Error::FieldClash(_)
104/// |Error::JsonDecodeError(_, _) => println!("{}", e),
105/// },
106/// Ok(res) => println!("Success: {:?}", res),
107/// }
108/// # }
109/// ```
110#[derive(Clone)]
111pub struct CloudTasks<C> {
112 pub client: common::Client<C>,
113 pub auth: Box<dyn common::GetToken>,
114 _user_agent: String,
115 _base_url: String,
116 _root_url: String,
117}
118
119impl<C> common::Hub for CloudTasks<C> {}
120
121impl<'a, C> CloudTasks<C> {
122 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudTasks<C> {
123 CloudTasks {
124 client,
125 auth: Box::new(auth),
126 _user_agent: "google-api-rust-client/6.0.0".to_string(),
127 _base_url: "https://cloudtasks.googleapis.com/".to_string(),
128 _root_url: "https://cloudtasks.googleapis.com/".to_string(),
129 }
130 }
131
132 pub fn api(&'a self) -> ApiMethods<'a, C> {
133 ApiMethods { hub: self }
134 }
135 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136 ProjectMethods { hub: self }
137 }
138
139 /// Set the user-agent header field to use in all requests to the server.
140 /// It defaults to `google-api-rust-client/6.0.0`.
141 ///
142 /// Returns the previously set user-agent.
143 pub fn user_agent(&mut self, agent_name: String) -> String {
144 std::mem::replace(&mut self._user_agent, agent_name)
145 }
146
147 /// Set the base url to use in all requests to the server.
148 /// It defaults to `https://cloudtasks.googleapis.com/`.
149 ///
150 /// Returns the previously set base url.
151 pub fn base_url(&mut self, new_base_url: String) -> String {
152 std::mem::replace(&mut self._base_url, new_base_url)
153 }
154
155 /// Set the root url to use in all requests to the server.
156 /// It defaults to `https://cloudtasks.googleapis.com/`.
157 ///
158 /// Returns the previously set root url.
159 pub fn root_url(&mut self, new_root_url: String) -> String {
160 std::mem::replace(&mut self._root_url, new_root_url)
161 }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// Request message for acknowledging a task using AcknowledgeTask.
168///
169/// # Activities
170///
171/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
172/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
173///
174/// * [locations queues tasks acknowledge projects](ProjectLocationQueueTaskAcknowledgeCall) (request)
175#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
176#[serde_with::serde_as]
177#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
178pub struct AcknowledgeTaskRequest {
179 /// 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.
180 #[serde(rename = "scheduleTime")]
181 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
182}
183
184impl common::RequestValue for AcknowledgeTaskRequest {}
185
186/// 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.
187///
188/// This type is not used in any activity, and only used as *part* of another schema.
189///
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct AppEngineHttpRequest {
194 /// 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.
195 #[serde(rename = "appEngineRouting")]
196 pub app_engine_routing: Option<AppEngineRouting>,
197 /// 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.
198 pub headers: Option<HashMap<String, String>>,
199 /// 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).
200 #[serde(rename = "httpMethod")]
201 pub http_method: Option<String>,
202 /// 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.
203 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
204 pub payload: Option<Vec<u8>>,
205 /// 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.
206 #[serde(rename = "relativeUrl")]
207 pub relative_url: Option<String>,
208}
209
210impl common::Part for AppEngineHttpRequest {}
211
212/// 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`
213///
214/// This type is not used in any activity, and only used as *part* of another schema.
215///
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct AppEngineHttpTarget {
220 /// 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.
221 #[serde(rename = "appEngineRoutingOverride")]
222 pub app_engine_routing_override: Option<AppEngineRouting>,
223}
224
225impl common::Part for AppEngineHttpTarget {}
226
227/// 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).
228///
229/// This type is not used in any activity, and only used as *part* of another schema.
230///
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct AppEngineRouting {
235 /// 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.
236 pub host: Option<String>,
237 /// 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).
238 pub instance: Option<String>,
239 /// 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.
240 pub service: Option<String>,
241 /// 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.
242 pub version: Option<String>,
243}
244
245impl common::Part for AppEngineRouting {}
246
247/// The status of a task attempt.
248///
249/// This type is not used in any activity, and only used as *part* of another schema.
250///
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct AttemptStatus {
255 /// Output only. The time that this attempt was dispatched. `dispatch_time` will be truncated to the nearest microsecond.
256 #[serde(rename = "dispatchTime")]
257 pub dispatch_time: Option<chrono::DateTime<chrono::offset::Utc>>,
258 /// 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.
259 #[serde(rename = "responseStatus")]
260 pub response_status: Option<Status>,
261 /// Output only. The time that this attempt response was received. `response_time` will be truncated to the nearest microsecond.
262 #[serde(rename = "responseTime")]
263 pub response_time: Option<chrono::DateTime<chrono::offset::Utc>>,
264 /// Output only. The time that this attempt was scheduled. `schedule_time` will be truncated to the nearest microsecond.
265 #[serde(rename = "scheduleTime")]
266 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
267}
268
269impl common::Part for AttemptStatus {}
270
271/// Associates `members`, or principals, with a `role`.
272///
273/// This type is not used in any activity, and only used as *part* of another schema.
274///
275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
276#[serde_with::serde_as]
277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
278pub struct Binding {
279 /// 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).
280 pub condition: Option<Expr>,
281 /// 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`.
282 pub members: Option<Vec<String>>,
283 /// 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).
284 pub role: Option<String>,
285}
286
287impl common::Part for Binding {}
288
289/// Request message for BufferTask.
290///
291/// # Activities
292///
293/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
294/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
295///
296/// * [locations queues tasks buffer projects](ProjectLocationQueueTaskBufferCall) (request)
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct BufferTaskRequest {
301 /// Optional. Body of the HTTP request. The body can take any generic value. The value is written to the HttpRequest of the [Task].
302 pub body: Option<HttpBody>,
303}
304
305impl common::RequestValue for BufferTaskRequest {}
306
307/// Response message for BufferTask.
308///
309/// # Activities
310///
311/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
312/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
313///
314/// * [locations queues tasks buffer projects](ProjectLocationQueueTaskBufferCall) (response)
315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
316#[serde_with::serde_as]
317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
318pub struct BufferTaskResponse {
319 /// The created task.
320 pub task: Option<Task>,
321}
322
323impl common::ResponseResult for BufferTaskResponse {}
324
325/// Request message for canceling a lease using CancelLease.
326///
327/// # Activities
328///
329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
331///
332/// * [locations queues tasks cancel lease projects](ProjectLocationQueueTaskCancelLeaseCall) (request)
333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
334#[serde_with::serde_as]
335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
336pub struct CancelLeaseRequest {
337 /// 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.
338 #[serde(rename = "responseView")]
339 pub response_view: Option<String>,
340 /// 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.
341 #[serde(rename = "scheduleTime")]
342 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
343}
344
345impl common::RequestValue for CancelLeaseRequest {}
346
347/// Describes the customer-managed encryption key (CMEK) configuration associated with a project and location.
348///
349/// # Activities
350///
351/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
352/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
353///
354/// * [locations get cmek config projects](ProjectLocationGetCmekConfigCall) (response)
355/// * [locations update cmek config projects](ProjectLocationUpdateCmekConfigCall) (request|response)
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct CmekConfig {
360 /// 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.
361 #[serde(rename = "kmsKey")]
362 pub kms_key: Option<String>,
363 /// 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`
364 pub name: Option<String>,
365}
366
367impl common::RequestValue for CmekConfig {}
368impl common::ResponseResult for CmekConfig {}
369
370/// Request message for CreateTask.
371///
372/// # Activities
373///
374/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
375/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
376///
377/// * [locations queues tasks create projects](ProjectLocationQueueTaskCreateCall) (request)
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct CreateTaskRequest {
382 /// 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.
383 #[serde(rename = "responseView")]
384 pub response_view: Option<String>,
385 /// 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 4 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.
386 pub task: Option<Task>,
387}
388
389impl common::RequestValue for CreateTaskRequest {}
390
391/// 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); }
392///
393/// # Activities
394///
395/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
396/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
397///
398/// * [queue update api](ApiQueueUpdateCall) (response)
399/// * [locations queues tasks acknowledge projects](ProjectLocationQueueTaskAcknowledgeCall) (response)
400/// * [locations queues tasks delete projects](ProjectLocationQueueTaskDeleteCall) (response)
401/// * [locations queues delete projects](ProjectLocationQueueDeleteCall) (response)
402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
403#[serde_with::serde_as]
404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
405pub struct Empty {
406 _never_set: Option<bool>,
407}
408
409impl common::ResponseResult for Empty {}
410
411/// 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.
412///
413/// This type is not used in any activity, and only used as *part* of another schema.
414///
415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
416#[serde_with::serde_as]
417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
418pub struct Expr {
419 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
420 pub description: Option<String>,
421 /// Textual representation of an expression in Common Expression Language syntax.
422 pub expression: Option<String>,
423 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
424 pub location: Option<String>,
425 /// 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.
426 pub title: Option<String>,
427}
428
429impl common::Part for Expr {}
430
431/// Request message for `GetIamPolicy` method.
432///
433/// # Activities
434///
435/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
436/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
437///
438/// * [locations queues get iam policy projects](ProjectLocationQueueGetIamPolicyCall) (request)
439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
440#[serde_with::serde_as]
441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
442pub struct GetIamPolicyRequest {
443 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
444 pub options: Option<GetPolicyOptions>,
445}
446
447impl common::RequestValue for GetIamPolicyRequest {}
448
449/// Encapsulates settings provided to GetIamPolicy.
450///
451/// This type is not used in any activity, and only used as *part* of another schema.
452///
453#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
454#[serde_with::serde_as]
455#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
456pub struct GetPolicyOptions {
457 /// 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).
458 #[serde(rename = "requestedPolicyVersion")]
459 pub requested_policy_version: Option<i32>,
460}
461
462impl common::Part for GetPolicyOptions {}
463
464/// Defines a header message. A header can have a key and a value.
465///
466/// This type is not used in any activity, and only used as *part* of another schema.
467///
468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
469#[serde_with::serde_as]
470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
471pub struct Header {
472 /// The key of the header.
473 pub key: Option<String>,
474 /// The value of the header.
475 pub value: Option<String>,
476}
477
478impl common::Part for Header {}
479
480/// Wraps the Header object.
481///
482/// This type is not used in any activity, and only used as *part* of another schema.
483///
484#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
485#[serde_with::serde_as]
486#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
487pub struct HeaderOverride {
488 /// 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).
489 pub header: Option<Header>,
490}
491
492impl common::Part for HeaderOverride {}
493
494/// 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.
495///
496/// # Activities
497///
498/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
499/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
500///
501/// * [queue update api](ApiQueueUpdateCall) (request)
502#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
503#[serde_with::serde_as]
504#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
505pub struct HttpBody {
506 /// The HTTP Content-Type header value specifying the content type of the body.
507 #[serde(rename = "contentType")]
508 pub content_type: Option<String>,
509 /// The HTTP request/response body as raw binary.
510 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
511 pub data: Option<Vec<u8>>,
512 /// Application specific response metadata. Must be set in the first response for streaming APIs.
513 pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
514}
515
516impl common::RequestValue for HttpBody {}
517
518/// 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.
519///
520/// This type is not used in any activity, and only used as *part* of another schema.
521///
522#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
523#[serde_with::serde_as]
524#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
525pub struct HttpRequest {
526 /// 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.
527 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
528 pub body: Option<Vec<u8>>,
529 /// 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.
530 pub headers: Option<HashMap<String, String>>,
531 /// The HTTP method to use for the request. The default is POST.
532 #[serde(rename = "httpMethod")]
533 pub http_method: Option<String>,
534 /// 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.
535 #[serde(rename = "oauthToken")]
536 pub oauth_token: Option<OAuthToken>,
537 /// 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.
538 #[serde(rename = "oidcToken")]
539 pub oidc_token: Option<OidcToken>,
540 /// 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.
541 pub url: Option<String>,
542}
543
544impl common::Part for HttpRequest {}
545
546/// HTTP target. When specified as a Queue, all the tasks with [HttpRequest] will be overridden according to the target.
547///
548/// This type is not used in any activity, and only used as *part* of another schema.
549///
550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
551#[serde_with::serde_as]
552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
553pub struct HttpTarget {
554 /// 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).
555 #[serde(rename = "headerOverrides")]
556 pub header_overrides: Option<Vec<HeaderOverride>>,
557 /// 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.
558 #[serde(rename = "httpMethod")]
559 pub http_method: Option<String>,
560 /// 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.
561 #[serde(rename = "oauthToken")]
562 pub oauth_token: Option<OAuthToken>,
563 /// 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.
564 #[serde(rename = "oidcToken")]
565 pub oidc_token: Option<OidcToken>,
566 /// Uri override. When specified, overrides the execution Uri for all the tasks in the queue.
567 #[serde(rename = "uriOverride")]
568 pub uri_override: Option<UriOverride>,
569}
570
571impl common::Part for HttpTarget {}
572
573/// Request message for leasing tasks using LeaseTasks.
574///
575/// # Activities
576///
577/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
578/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
579///
580/// * [locations queues tasks lease projects](ProjectLocationQueueTaskLeaseCall) (request)
581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
582#[serde_with::serde_as]
583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
584pub struct LeaseTasksRequest {
585 /// `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.
586 pub filter: Option<String>,
587 /// 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.
588 #[serde(rename = "leaseDuration")]
589 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
590 pub lease_duration: Option<chrono::Duration>,
591 /// 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.
592 #[serde(rename = "maxTasks")]
593 pub max_tasks: Option<i32>,
594 /// 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.
595 #[serde(rename = "responseView")]
596 pub response_view: Option<String>,
597}
598
599impl common::RequestValue for LeaseTasksRequest {}
600
601/// Response message for leasing tasks using LeaseTasks.
602///
603/// # Activities
604///
605/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
606/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
607///
608/// * [locations queues tasks lease projects](ProjectLocationQueueTaskLeaseCall) (response)
609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
610#[serde_with::serde_as]
611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
612pub struct LeaseTasksResponse {
613 /// The leased tasks.
614 pub tasks: Option<Vec<Task>>,
615}
616
617impl common::ResponseResult for LeaseTasksResponse {}
618
619/// The response message for Locations.ListLocations.
620///
621/// # Activities
622///
623/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
624/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
625///
626/// * [locations list projects](ProjectLocationListCall) (response)
627#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
628#[serde_with::serde_as]
629#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
630pub struct ListLocationsResponse {
631 /// A list of locations that matches the specified filter in the request.
632 pub locations: Option<Vec<Location>>,
633 /// The standard List next-page token.
634 #[serde(rename = "nextPageToken")]
635 pub next_page_token: Option<String>,
636}
637
638impl common::ResponseResult for ListLocationsResponse {}
639
640/// Response message for ListQueues.
641///
642/// # Activities
643///
644/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
645/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
646///
647/// * [locations queues list projects](ProjectLocationQueueListCall) (response)
648#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
649#[serde_with::serde_as]
650#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
651pub struct ListQueuesResponse {
652 /// 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.
653 #[serde(rename = "nextPageToken")]
654 pub next_page_token: Option<String>,
655 /// The list of queues.
656 pub queues: Option<Vec<Queue>>,
657}
658
659impl common::ResponseResult for ListQueuesResponse {}
660
661/// Response message for listing tasks using ListTasks.
662///
663/// # Activities
664///
665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
667///
668/// * [locations queues tasks list projects](ProjectLocationQueueTaskListCall) (response)
669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
670#[serde_with::serde_as]
671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
672pub struct ListTasksResponse {
673 /// 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.
674 #[serde(rename = "nextPageToken")]
675 pub next_page_token: Option<String>,
676 /// The list of tasks.
677 pub tasks: Option<Vec<Task>>,
678}
679
680impl common::ResponseResult for ListTasksResponse {}
681
682/// A resource that represents a Google Cloud location.
683///
684/// # Activities
685///
686/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
687/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
688///
689/// * [locations get projects](ProjectLocationGetCall) (response)
690#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
691#[serde_with::serde_as]
692#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
693pub struct Location {
694 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
695 #[serde(rename = "displayName")]
696 pub display_name: Option<String>,
697 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
698 pub labels: Option<HashMap<String, String>>,
699 /// The canonical id for this location. For example: `"us-east1"`.
700 #[serde(rename = "locationId")]
701 pub location_id: Option<String>,
702 /// Service-specific metadata. For example the available capacity at the given location.
703 pub metadata: Option<HashMap<String, serde_json::Value>>,
704 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
705 pub name: Option<String>,
706}
707
708impl common::ResponseResult for Location {}
709
710/// 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.
711///
712/// This type is not used in any activity, and only used as *part* of another schema.
713///
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct OAuthToken {
718 /// OAuth scope to be used for generating OAuth access token. If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used.
719 pub scope: Option<String>,
720 /// [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.
721 #[serde(rename = "serviceAccountEmail")]
722 pub service_account_email: Option<String>,
723}
724
725impl common::Part for OAuthToken {}
726
727/// 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.
728///
729/// This type is not used in any activity, and only used as *part* of another schema.
730///
731#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
732#[serde_with::serde_as]
733#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
734pub struct OidcToken {
735 /// Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used.
736 pub audience: Option<String>,
737 /// [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.
738 #[serde(rename = "serviceAccountEmail")]
739 pub service_account_email: Option<String>,
740}
741
742impl common::Part for OidcToken {}
743
744/// PathOverride. Path message defines path override for HTTP targets.
745///
746/// This type is not used in any activity, and only used as *part* of another schema.
747///
748#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
749#[serde_with::serde_as]
750#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
751pub struct PathOverride {
752 /// The URI path (e.g., /users/1234). Default is an empty string.
753 pub path: Option<String>,
754}
755
756impl common::Part for PathOverride {}
757
758/// Request message for PauseQueue.
759///
760/// # Activities
761///
762/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
763/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
764///
765/// * [locations queues pause projects](ProjectLocationQueuePauseCall) (request)
766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
767#[serde_with::serde_as]
768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
769pub struct PauseQueueRequest {
770 _never_set: Option<bool>,
771}
772
773impl common::RequestValue for PauseQueueRequest {}
774
775/// 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/).
776///
777/// # Activities
778///
779/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
780/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
781///
782/// * [locations queues get iam policy projects](ProjectLocationQueueGetIamPolicyCall) (response)
783/// * [locations queues set iam policy projects](ProjectLocationQueueSetIamPolicyCall) (response)
784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
785#[serde_with::serde_as]
786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
787pub struct Policy {
788 /// 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`.
789 pub bindings: Option<Vec<Binding>>,
790 /// `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.
791 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
792 pub etag: Option<Vec<u8>>,
793 /// 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).
794 pub version: Option<i32>,
795}
796
797impl common::ResponseResult for Policy {}
798
799/// 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.
800///
801/// This type is not used in any activity, and only used as *part* of another schema.
802///
803#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
804#[serde_with::serde_as]
805#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
806pub struct PullMessage {
807 /// A data payload consumed by the worker to execute the task.
808 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
809 pub payload: Option<Vec<u8>>,
810 /// 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.
811 pub tag: Option<String>,
812}
813
814impl common::Part for PullMessage {}
815
816/// Pull target.
817///
818/// This type is not used in any activity, and only used as *part* of another schema.
819///
820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
821#[serde_with::serde_as]
822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
823pub struct PullTarget {
824 _never_set: Option<bool>,
825}
826
827impl common::Part for PullTarget {}
828
829/// Request message for PurgeQueue.
830///
831/// # Activities
832///
833/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
834/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
835///
836/// * [locations queues purge projects](ProjectLocationQueuePurgeCall) (request)
837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
838#[serde_with::serde_as]
839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
840pub struct PurgeQueueRequest {
841 _never_set: Option<bool>,
842}
843
844impl common::RequestValue for PurgeQueueRequest {}
845
846/// QueryOverride. Query message defines query override for HTTP targets.
847///
848/// This type is not used in any activity, and only used as *part* of another schema.
849///
850#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
851#[serde_with::serde_as]
852#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
853pub struct QueryOverride {
854 /// The query parameters (e.g., qparam1=123&qparam2=456). Default is an empty string.
855 #[serde(rename = "queryParams")]
856 pub query_params: Option<String>,
857}
858
859impl common::Part for QueryOverride {}
860
861/// 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.
862///
863/// # Activities
864///
865/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
866/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
867///
868/// * [locations queues create projects](ProjectLocationQueueCreateCall) (request|response)
869/// * [locations queues get projects](ProjectLocationQueueGetCall) (response)
870/// * [locations queues patch projects](ProjectLocationQueuePatchCall) (request|response)
871/// * [locations queues pause projects](ProjectLocationQueuePauseCall) (response)
872/// * [locations queues purge projects](ProjectLocationQueuePurgeCall) (response)
873/// * [locations queues resume projects](ProjectLocationQueueResumeCall) (response)
874#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
875#[serde_with::serde_as]
876#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
877pub struct Queue {
878 /// App Engine HTTP target. An App Engine queue is a queue that has an AppEngineHttpTarget.
879 #[serde(rename = "appEngineHttpTarget")]
880 pub app_engine_http_target: Option<AppEngineHttpTarget>,
881 /// An http_target is used to override the target values for HTTP tasks.
882 #[serde(rename = "httpTarget")]
883 pub http_target: Option<HttpTarget>,
884 /// 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.
885 pub name: Option<String>,
886 /// Pull target. A pull queue is a queue that has a PullTarget.
887 #[serde(rename = "pullTarget")]
888 pub pull_target: Option<PullTarget>,
889 /// 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.
890 #[serde(rename = "purgeTime")]
891 pub purge_time: Option<chrono::DateTime<chrono::offset::Utc>>,
892 /// 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).
893 #[serde(rename = "rateLimits")]
894 pub rate_limits: Option<RateLimits>,
895 /// 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).
896 #[serde(rename = "retryConfig")]
897 pub retry_config: Option<RetryConfig>,
898 /// 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`.
899 pub state: Option<String>,
900 /// Output only. The realtime, informational statistics for a queue. In order to receive the statistics the caller should include this field in the FieldMask.
901 pub stats: Option<QueueStats>,
902 /// 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.
903 #[serde(rename = "taskTtl")]
904 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
905 pub task_ttl: Option<chrono::Duration>,
906 /// 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.
907 #[serde(rename = "tombstoneTtl")]
908 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
909 pub tombstone_ttl: Option<chrono::Duration>,
910}
911
912impl common::RequestValue for Queue {}
913impl common::ResponseResult for Queue {}
914
915/// Statistics for a queue.
916///
917/// This type is not used in any activity, and only used as *part* of another schema.
918///
919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
920#[serde_with::serde_as]
921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
922pub struct QueueStats {
923 /// Output only. The number of requests that the queue has dispatched but has not received a reply for yet.
924 #[serde(rename = "concurrentDispatchesCount")]
925 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
926 pub concurrent_dispatches_count: Option<i64>,
927 /// 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.
928 #[serde(rename = "effectiveExecutionRate")]
929 pub effective_execution_rate: Option<f64>,
930 /// 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.
931 #[serde(rename = "executedLastMinuteCount")]
932 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
933 pub executed_last_minute_count: Option<i64>,
934 /// Output only. An estimation of the nearest time in the future where a task in the queue is scheduled to be executed.
935 #[serde(rename = "oldestEstimatedArrivalTime")]
936 pub oldest_estimated_arrival_time: Option<chrono::DateTime<chrono::offset::Utc>>,
937 /// 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.
938 #[serde(rename = "tasksCount")]
939 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
940 pub tasks_count: Option<i64>,
941}
942
943impl common::Part for QueueStats {}
944
945/// 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.
946///
947/// This type is not used in any activity, and only used as *part* of another schema.
948///
949#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
950#[serde_with::serde_as]
951#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
952pub struct RateLimits {
953 /// 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.
954 #[serde(rename = "maxBurstSize")]
955 pub max_burst_size: Option<i32>,
956 /// 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).
957 #[serde(rename = "maxConcurrentTasks")]
958 pub max_concurrent_tasks: Option<i32>,
959 /// 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).
960 #[serde(rename = "maxTasksDispatchedPerSecond")]
961 pub max_tasks_dispatched_per_second: Option<f64>,
962}
963
964impl common::Part for RateLimits {}
965
966/// Request message for renewing a lease using RenewLease.
967///
968/// # Activities
969///
970/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
971/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
972///
973/// * [locations queues tasks renew lease projects](ProjectLocationQueueTaskRenewLeaseCall) (request)
974#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
975#[serde_with::serde_as]
976#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
977pub struct RenewLeaseRequest {
978 /// 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.
979 #[serde(rename = "leaseDuration")]
980 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
981 pub lease_duration: Option<chrono::Duration>,
982 /// 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.
983 #[serde(rename = "responseView")]
984 pub response_view: Option<String>,
985 /// 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.
986 #[serde(rename = "scheduleTime")]
987 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
988}
989
990impl common::RequestValue for RenewLeaseRequest {}
991
992/// Request message for ResumeQueue.
993///
994/// # Activities
995///
996/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
997/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
998///
999/// * [locations queues resume projects](ProjectLocationQueueResumeCall) (request)
1000#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1001#[serde_with::serde_as]
1002#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1003pub struct ResumeQueueRequest {
1004 _never_set: Option<bool>,
1005}
1006
1007impl common::RequestValue for ResumeQueueRequest {}
1008
1009/// Retry config. These settings determine how a failed task attempt is retried.
1010///
1011/// This type is not used in any activity, and only used as *part* of another schema.
1012///
1013#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1014#[serde_with::serde_as]
1015#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1016pub struct RetryConfig {
1017 /// 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.
1018 #[serde(rename = "maxAttempts")]
1019 pub max_attempts: Option<i32>,
1020 /// 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).
1021 #[serde(rename = "maxBackoff")]
1022 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1023 pub max_backoff: Option<chrono::Duration>,
1024 /// 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).
1025 #[serde(rename = "maxDoublings")]
1026 pub max_doublings: Option<i32>,
1027 /// 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).
1028 #[serde(rename = "maxRetryDuration")]
1029 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1030 pub max_retry_duration: Option<chrono::Duration>,
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. `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).
1032 #[serde(rename = "minBackoff")]
1033 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1034 pub min_backoff: Option<chrono::Duration>,
1035 /// If true, then the number of attempts is unlimited.
1036 #[serde(rename = "unlimitedAttempts")]
1037 pub unlimited_attempts: Option<bool>,
1038}
1039
1040impl common::Part for RetryConfig {}
1041
1042/// Request message for forcing a task to run now using RunTask.
1043///
1044/// # Activities
1045///
1046/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1047/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1048///
1049/// * [locations queues tasks run projects](ProjectLocationQueueTaskRunCall) (request)
1050#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1051#[serde_with::serde_as]
1052#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1053pub struct RunTaskRequest {
1054 /// 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.
1055 #[serde(rename = "responseView")]
1056 pub response_view: Option<String>,
1057}
1058
1059impl common::RequestValue for RunTaskRequest {}
1060
1061/// Request message for `SetIamPolicy` method.
1062///
1063/// # Activities
1064///
1065/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1066/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1067///
1068/// * [locations queues set iam policy projects](ProjectLocationQueueSetIamPolicyCall) (request)
1069#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1070#[serde_with::serde_as]
1071#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1072pub struct SetIamPolicyRequest {
1073 /// 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.
1074 pub policy: Option<Policy>,
1075}
1076
1077impl common::RequestValue for SetIamPolicyRequest {}
1078
1079/// 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).
1080///
1081/// This type is not used in any activity, and only used as *part* of another schema.
1082///
1083#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1084#[serde_with::serde_as]
1085#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1086pub struct Status {
1087 /// The status code, which should be an enum value of google.rpc.Code.
1088 pub code: Option<i32>,
1089 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1090 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1091 /// 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.
1092 pub message: Option<String>,
1093}
1094
1095impl common::Part for Status {}
1096
1097/// A unit of scheduled work.
1098///
1099/// # Activities
1100///
1101/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1102/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1103///
1104/// * [locations queues tasks cancel lease projects](ProjectLocationQueueTaskCancelLeaseCall) (response)
1105/// * [locations queues tasks create projects](ProjectLocationQueueTaskCreateCall) (response)
1106/// * [locations queues tasks get projects](ProjectLocationQueueTaskGetCall) (response)
1107/// * [locations queues tasks renew lease projects](ProjectLocationQueueTaskRenewLeaseCall) (response)
1108/// * [locations queues tasks run projects](ProjectLocationQueueTaskRunCall) (response)
1109#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1110#[serde_with::serde_as]
1111#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1112pub struct Task {
1113 /// 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.
1114 #[serde(rename = "appEngineHttpRequest")]
1115 pub app_engine_http_request: Option<AppEngineHttpRequest>,
1116 /// Output only. The time that the task was created. `create_time` will be truncated to the nearest second.
1117 #[serde(rename = "createTime")]
1118 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1119 /// HTTP request that is sent to the task's target. An HTTP task is a task that has HttpRequest set.
1120 #[serde(rename = "httpRequest")]
1121 pub http_request: Option<HttpRequest>,
1122 /// 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.
1123 pub name: Option<String>,
1124 /// 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.
1125 #[serde(rename = "pullMessage")]
1126 pub pull_message: Option<PullMessage>,
1127 /// 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.
1128 #[serde(rename = "scheduleTime")]
1129 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1130 /// Output only. The task status.
1131 pub status: Option<TaskStatus>,
1132 /// Output only. The view specifies which subset of the Task has been returned.
1133 pub view: Option<String>,
1134}
1135
1136impl common::ResponseResult for Task {}
1137
1138/// Status of the task.
1139///
1140/// This type is not used in any activity, and only used as *part* of another schema.
1141///
1142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1143#[serde_with::serde_as]
1144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1145pub struct TaskStatus {
1146 /// Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response.
1147 #[serde(rename = "attemptDispatchCount")]
1148 pub attempt_dispatch_count: Option<i32>,
1149 /// Output only. The number of attempts which have received a response. This field is not calculated for pull tasks.
1150 #[serde(rename = "attemptResponseCount")]
1151 pub attempt_response_count: Option<i32>,
1152 /// 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.
1153 #[serde(rename = "firstAttemptStatus")]
1154 pub first_attempt_status: Option<AttemptStatus>,
1155 /// Output only. The status of the task's last attempt. This field is not calculated for pull tasks.
1156 #[serde(rename = "lastAttemptStatus")]
1157 pub last_attempt_status: Option<AttemptStatus>,
1158}
1159
1160impl common::Part for TaskStatus {}
1161
1162/// Request message for `TestIamPermissions` method.
1163///
1164/// # Activities
1165///
1166/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1167/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1168///
1169/// * [locations queues test iam permissions projects](ProjectLocationQueueTestIamPermissionCall) (request)
1170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1171#[serde_with::serde_as]
1172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1173pub struct TestIamPermissionsRequest {
1174 /// 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).
1175 pub permissions: Option<Vec<String>>,
1176}
1177
1178impl common::RequestValue for TestIamPermissionsRequest {}
1179
1180/// Response message for `TestIamPermissions` method.
1181///
1182/// # Activities
1183///
1184/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1185/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1186///
1187/// * [locations queues test iam permissions projects](ProjectLocationQueueTestIamPermissionCall) (response)
1188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1189#[serde_with::serde_as]
1190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1191pub struct TestIamPermissionsResponse {
1192 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1193 pub permissions: Option<Vec<String>>,
1194}
1195
1196impl common::ResponseResult for TestIamPermissionsResponse {}
1197
1198/// Uri Override. When specified, all the HTTP tasks inside the queue will be partially or fully overridden depending on the configured values.
1199///
1200/// This type is not used in any activity, and only used as *part* of another schema.
1201///
1202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1203#[serde_with::serde_as]
1204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1205pub struct UriOverride {
1206 /// 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).
1207 pub host: Option<String>,
1208 /// 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.
1209 #[serde(rename = "pathOverride")]
1210 pub path_override: Option<PathOverride>,
1211 /// Port override. When specified, replaces the port part of the task URI. For instance, for a URI http://www.google.com/foo and port=123, the overridden URI becomes http://www.google.com:123/foo. Note that the port value must be a positive integer. Setting the port to 0 (Zero) clears the URI port.
1212 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1213 pub port: Option<i64>,
1214 /// 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.
1215 #[serde(rename = "queryOverride")]
1216 pub query_override: Option<QueryOverride>,
1217 /// Scheme override. When specified, the task URI scheme is replaced by the provided value (HTTP or HTTPS).
1218 pub scheme: Option<String>,
1219 /// URI Override Enforce Mode When specified, determines the Target UriOverride mode. If not specified, it defaults to ALWAYS.
1220 #[serde(rename = "uriOverrideEnforceMode")]
1221 pub uri_override_enforce_mode: Option<String>,
1222}
1223
1224impl common::Part for UriOverride {}
1225
1226// ###################
1227// MethodBuilders ###
1228// #################
1229
1230/// A builder providing access to all methods supported on *api* resources.
1231/// It is not used directly, but through the [`CloudTasks`] hub.
1232///
1233/// # Example
1234///
1235/// Instantiate a resource builder
1236///
1237/// ```test_harness,no_run
1238/// extern crate hyper;
1239/// extern crate hyper_rustls;
1240/// extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
1241///
1242/// # async fn dox() {
1243/// use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1244///
1245/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1246/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1247/// secret,
1248/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1249/// ).build().await.unwrap();
1250///
1251/// let client = hyper_util::client::legacy::Client::builder(
1252/// hyper_util::rt::TokioExecutor::new()
1253/// )
1254/// .build(
1255/// hyper_rustls::HttpsConnectorBuilder::new()
1256/// .with_native_roots()
1257/// .unwrap()
1258/// .https_or_http()
1259/// .enable_http1()
1260/// .build()
1261/// );
1262/// let mut hub = CloudTasks::new(client, auth);
1263/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1264/// // like `queue_update(...)`
1265/// // to build up your call.
1266/// let rb = hub.api();
1267/// # }
1268/// ```
1269pub struct ApiMethods<'a, C>
1270where
1271 C: 'a,
1272{
1273 hub: &'a CloudTasks<C>,
1274}
1275
1276impl<'a, C> common::MethodsBuilder for ApiMethods<'a, C> {}
1277
1278impl<'a, C> ApiMethods<'a, C> {
1279 /// Create a builder to help you perform the following task:
1280 ///
1281 /// 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.
1282 ///
1283 /// # Arguments
1284 ///
1285 /// * `request` - No description provided.
1286 pub fn queue_update(&self, request: HttpBody) -> ApiQueueUpdateCall<'a, C> {
1287 ApiQueueUpdateCall {
1288 hub: self.hub,
1289 _request: request,
1290 _app_id: Default::default(),
1291 _delegate: Default::default(),
1292 _additional_params: Default::default(),
1293 _scopes: Default::default(),
1294 }
1295 }
1296}
1297
1298/// A builder providing access to all methods supported on *project* resources.
1299/// It is not used directly, but through the [`CloudTasks`] hub.
1300///
1301/// # Example
1302///
1303/// Instantiate a resource builder
1304///
1305/// ```test_harness,no_run
1306/// extern crate hyper;
1307/// extern crate hyper_rustls;
1308/// extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
1309///
1310/// # async fn dox() {
1311/// use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1312///
1313/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1314/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1315/// secret,
1316/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1317/// ).build().await.unwrap();
1318///
1319/// let client = hyper_util::client::legacy::Client::builder(
1320/// hyper_util::rt::TokioExecutor::new()
1321/// )
1322/// .build(
1323/// hyper_rustls::HttpsConnectorBuilder::new()
1324/// .with_native_roots()
1325/// .unwrap()
1326/// .https_or_http()
1327/// .enable_http1()
1328/// .build()
1329/// );
1330/// let mut hub = CloudTasks::new(client, auth);
1331/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1332/// // 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(...)`
1333/// // to build up your call.
1334/// let rb = hub.projects();
1335/// # }
1336/// ```
1337pub struct ProjectMethods<'a, C>
1338where
1339 C: 'a,
1340{
1341 hub: &'a CloudTasks<C>,
1342}
1343
1344impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1345
1346impl<'a, C> ProjectMethods<'a, C> {
1347 /// Create a builder to help you perform the following task:
1348 ///
1349 /// 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.
1350 ///
1351 /// # Arguments
1352 ///
1353 /// * `request` - No description provided.
1354 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1355 pub fn locations_queues_tasks_acknowledge(
1356 &self,
1357 request: AcknowledgeTaskRequest,
1358 name: &str,
1359 ) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
1360 ProjectLocationQueueTaskAcknowledgeCall {
1361 hub: self.hub,
1362 _request: request,
1363 _name: name.to_string(),
1364 _delegate: Default::default(),
1365 _additional_params: Default::default(),
1366 _scopes: Default::default(),
1367 }
1368 }
1369
1370 /// Create a builder to help you perform the following task:
1371 ///
1372 /// 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.
1373 ///
1374 /// # Arguments
1375 ///
1376 /// * `request` - No description provided.
1377 /// * `queue` - Required. The parent queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1378 /// * `taskId` - Optional. Task ID for the task being created. If not provided, a random task ID is assigned to the task.
1379 pub fn locations_queues_tasks_buffer(
1380 &self,
1381 request: BufferTaskRequest,
1382 queue: &str,
1383 task_id: &str,
1384 ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1385 ProjectLocationQueueTaskBufferCall {
1386 hub: self.hub,
1387 _request: request,
1388 _queue: queue.to_string(),
1389 _task_id: task_id.to_string(),
1390 _delegate: Default::default(),
1391 _additional_params: Default::default(),
1392 _scopes: Default::default(),
1393 }
1394 }
1395
1396 /// Create a builder to help you perform the following task:
1397 ///
1398 /// 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.
1399 ///
1400 /// # Arguments
1401 ///
1402 /// * `request` - No description provided.
1403 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1404 pub fn locations_queues_tasks_cancel_lease(
1405 &self,
1406 request: CancelLeaseRequest,
1407 name: &str,
1408 ) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
1409 ProjectLocationQueueTaskCancelLeaseCall {
1410 hub: self.hub,
1411 _request: request,
1412 _name: name.to_string(),
1413 _delegate: Default::default(),
1414 _additional_params: Default::default(),
1415 _scopes: Default::default(),
1416 }
1417 }
1418
1419 /// Create a builder to help you perform the following task:
1420 ///
1421 /// 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.
1422 ///
1423 /// # Arguments
1424 ///
1425 /// * `request` - No description provided.
1426 /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1427 pub fn locations_queues_tasks_create(
1428 &self,
1429 request: CreateTaskRequest,
1430 parent: &str,
1431 ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
1432 ProjectLocationQueueTaskCreateCall {
1433 hub: self.hub,
1434 _request: request,
1435 _parent: parent.to_string(),
1436 _delegate: Default::default(),
1437 _additional_params: Default::default(),
1438 _scopes: Default::default(),
1439 }
1440 }
1441
1442 /// Create a builder to help you perform the following task:
1443 ///
1444 /// 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.
1445 ///
1446 /// # Arguments
1447 ///
1448 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1449 pub fn locations_queues_tasks_delete(
1450 &self,
1451 name: &str,
1452 ) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
1453 ProjectLocationQueueTaskDeleteCall {
1454 hub: self.hub,
1455 _name: name.to_string(),
1456 _delegate: Default::default(),
1457 _additional_params: Default::default(),
1458 _scopes: Default::default(),
1459 }
1460 }
1461
1462 /// Create a builder to help you perform the following task:
1463 ///
1464 /// Gets a task.
1465 ///
1466 /// # Arguments
1467 ///
1468 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1469 pub fn locations_queues_tasks_get(&self, name: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
1470 ProjectLocationQueueTaskGetCall {
1471 hub: self.hub,
1472 _name: name.to_string(),
1473 _response_view: Default::default(),
1474 _delegate: Default::default(),
1475 _additional_params: Default::default(),
1476 _scopes: Default::default(),
1477 }
1478 }
1479
1480 /// Create a builder to help you perform the following task:
1481 ///
1482 /// 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.
1483 ///
1484 /// # Arguments
1485 ///
1486 /// * `request` - No description provided.
1487 /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1488 pub fn locations_queues_tasks_lease(
1489 &self,
1490 request: LeaseTasksRequest,
1491 parent: &str,
1492 ) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
1493 ProjectLocationQueueTaskLeaseCall {
1494 hub: self.hub,
1495 _request: request,
1496 _parent: parent.to_string(),
1497 _delegate: Default::default(),
1498 _additional_params: Default::default(),
1499 _scopes: Default::default(),
1500 }
1501 }
1502
1503 /// Create a builder to help you perform the following task:
1504 ///
1505 /// 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.
1506 ///
1507 /// # Arguments
1508 ///
1509 /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1510 pub fn locations_queues_tasks_list(
1511 &self,
1512 parent: &str,
1513 ) -> ProjectLocationQueueTaskListCall<'a, C> {
1514 ProjectLocationQueueTaskListCall {
1515 hub: self.hub,
1516 _parent: parent.to_string(),
1517 _response_view: Default::default(),
1518 _page_token: Default::default(),
1519 _page_size: Default::default(),
1520 _delegate: Default::default(),
1521 _additional_params: Default::default(),
1522 _scopes: Default::default(),
1523 }
1524 }
1525
1526 /// Create a builder to help you perform the following task:
1527 ///
1528 /// 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.
1529 ///
1530 /// # Arguments
1531 ///
1532 /// * `request` - No description provided.
1533 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1534 pub fn locations_queues_tasks_renew_lease(
1535 &self,
1536 request: RenewLeaseRequest,
1537 name: &str,
1538 ) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
1539 ProjectLocationQueueTaskRenewLeaseCall {
1540 hub: self.hub,
1541 _request: request,
1542 _name: name.to_string(),
1543 _delegate: Default::default(),
1544 _additional_params: Default::default(),
1545 _scopes: Default::default(),
1546 }
1547 }
1548
1549 /// Create a builder to help you perform the following task:
1550 ///
1551 /// 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.
1552 ///
1553 /// # Arguments
1554 ///
1555 /// * `request` - No description provided.
1556 /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1557 pub fn locations_queues_tasks_run(
1558 &self,
1559 request: RunTaskRequest,
1560 name: &str,
1561 ) -> ProjectLocationQueueTaskRunCall<'a, C> {
1562 ProjectLocationQueueTaskRunCall {
1563 hub: self.hub,
1564 _request: request,
1565 _name: name.to_string(),
1566 _delegate: Default::default(),
1567 _additional_params: Default::default(),
1568 _scopes: Default::default(),
1569 }
1570 }
1571
1572 /// Create a builder to help you perform the following task:
1573 ///
1574 /// 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.
1575 ///
1576 /// # Arguments
1577 ///
1578 /// * `request` - No description provided.
1579 /// * `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.
1580 pub fn locations_queues_create(
1581 &self,
1582 request: Queue,
1583 parent: &str,
1584 ) -> ProjectLocationQueueCreateCall<'a, C> {
1585 ProjectLocationQueueCreateCall {
1586 hub: self.hub,
1587 _request: request,
1588 _parent: parent.to_string(),
1589 _delegate: Default::default(),
1590 _additional_params: Default::default(),
1591 _scopes: Default::default(),
1592 }
1593 }
1594
1595 /// Create a builder to help you perform the following task:
1596 ///
1597 /// 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.
1598 ///
1599 /// # Arguments
1600 ///
1601 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1602 pub fn locations_queues_delete(&self, name: &str) -> ProjectLocationQueueDeleteCall<'a, C> {
1603 ProjectLocationQueueDeleteCall {
1604 hub: self.hub,
1605 _name: name.to_string(),
1606 _delegate: Default::default(),
1607 _additional_params: Default::default(),
1608 _scopes: Default::default(),
1609 }
1610 }
1611
1612 /// Create a builder to help you perform the following task:
1613 ///
1614 /// Gets a queue.
1615 ///
1616 /// # Arguments
1617 ///
1618 /// * `name` - Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1619 pub fn locations_queues_get(&self, name: &str) -> ProjectLocationQueueGetCall<'a, C> {
1620 ProjectLocationQueueGetCall {
1621 hub: self.hub,
1622 _name: name.to_string(),
1623 _read_mask: Default::default(),
1624 _delegate: Default::default(),
1625 _additional_params: Default::default(),
1626 _scopes: Default::default(),
1627 }
1628 }
1629
1630 /// Create a builder to help you perform the following task:
1631 ///
1632 /// 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`
1633 ///
1634 /// # Arguments
1635 ///
1636 /// * `request` - No description provided.
1637 /// * `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.
1638 pub fn locations_queues_get_iam_policy(
1639 &self,
1640 request: GetIamPolicyRequest,
1641 resource: &str,
1642 ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
1643 ProjectLocationQueueGetIamPolicyCall {
1644 hub: self.hub,
1645 _request: request,
1646 _resource: resource.to_string(),
1647 _delegate: Default::default(),
1648 _additional_params: Default::default(),
1649 _scopes: Default::default(),
1650 }
1651 }
1652
1653 /// Create a builder to help you perform the following task:
1654 ///
1655 /// Lists queues. Queues are returned in lexicographical order.
1656 ///
1657 /// # Arguments
1658 ///
1659 /// * `parent` - Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`
1660 pub fn locations_queues_list(&self, parent: &str) -> ProjectLocationQueueListCall<'a, C> {
1661 ProjectLocationQueueListCall {
1662 hub: self.hub,
1663 _parent: parent.to_string(),
1664 _read_mask: Default::default(),
1665 _page_token: Default::default(),
1666 _page_size: Default::default(),
1667 _filter: Default::default(),
1668 _delegate: Default::default(),
1669 _additional_params: Default::default(),
1670 _scopes: Default::default(),
1671 }
1672 }
1673
1674 /// Create a builder to help you perform the following task:
1675 ///
1676 /// 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.
1677 ///
1678 /// # Arguments
1679 ///
1680 /// * `request` - No description provided.
1681 /// * `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.
1682 pub fn locations_queues_patch(
1683 &self,
1684 request: Queue,
1685 name: &str,
1686 ) -> ProjectLocationQueuePatchCall<'a, C> {
1687 ProjectLocationQueuePatchCall {
1688 hub: self.hub,
1689 _request: request,
1690 _name: name.to_string(),
1691 _update_mask: Default::default(),
1692 _delegate: Default::default(),
1693 _additional_params: Default::default(),
1694 _scopes: Default::default(),
1695 }
1696 }
1697
1698 /// Create a builder to help you perform the following task:
1699 ///
1700 /// 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.
1701 ///
1702 /// # Arguments
1703 ///
1704 /// * `request` - No description provided.
1705 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1706 pub fn locations_queues_pause(
1707 &self,
1708 request: PauseQueueRequest,
1709 name: &str,
1710 ) -> ProjectLocationQueuePauseCall<'a, C> {
1711 ProjectLocationQueuePauseCall {
1712 hub: self.hub,
1713 _request: request,
1714 _name: name.to_string(),
1715 _delegate: Default::default(),
1716 _additional_params: Default::default(),
1717 _scopes: Default::default(),
1718 }
1719 }
1720
1721 /// Create a builder to help you perform the following task:
1722 ///
1723 /// 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.
1724 ///
1725 /// # Arguments
1726 ///
1727 /// * `request` - No description provided.
1728 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1729 pub fn locations_queues_purge(
1730 &self,
1731 request: PurgeQueueRequest,
1732 name: &str,
1733 ) -> ProjectLocationQueuePurgeCall<'a, C> {
1734 ProjectLocationQueuePurgeCall {
1735 hub: self.hub,
1736 _request: request,
1737 _name: name.to_string(),
1738 _delegate: Default::default(),
1739 _additional_params: Default::default(),
1740 _scopes: Default::default(),
1741 }
1742 }
1743
1744 /// Create a builder to help you perform the following task:
1745 ///
1746 /// 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).
1747 ///
1748 /// # Arguments
1749 ///
1750 /// * `request` - No description provided.
1751 /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1752 pub fn locations_queues_resume(
1753 &self,
1754 request: ResumeQueueRequest,
1755 name: &str,
1756 ) -> ProjectLocationQueueResumeCall<'a, C> {
1757 ProjectLocationQueueResumeCall {
1758 hub: self.hub,
1759 _request: request,
1760 _name: name.to_string(),
1761 _delegate: Default::default(),
1762 _additional_params: Default::default(),
1763 _scopes: Default::default(),
1764 }
1765 }
1766
1767 /// Create a builder to help you perform the following task:
1768 ///
1769 /// 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`
1770 ///
1771 /// # Arguments
1772 ///
1773 /// * `request` - No description provided.
1774 /// * `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.
1775 pub fn locations_queues_set_iam_policy(
1776 &self,
1777 request: SetIamPolicyRequest,
1778 resource: &str,
1779 ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
1780 ProjectLocationQueueSetIamPolicyCall {
1781 hub: self.hub,
1782 _request: request,
1783 _resource: resource.to_string(),
1784 _delegate: Default::default(),
1785 _additional_params: Default::default(),
1786 _scopes: Default::default(),
1787 }
1788 }
1789
1790 /// Create a builder to help you perform the following task:
1791 ///
1792 /// 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.
1793 ///
1794 /// # Arguments
1795 ///
1796 /// * `request` - No description provided.
1797 /// * `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.
1798 pub fn locations_queues_test_iam_permissions(
1799 &self,
1800 request: TestIamPermissionsRequest,
1801 resource: &str,
1802 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
1803 ProjectLocationQueueTestIamPermissionCall {
1804 hub: self.hub,
1805 _request: request,
1806 _resource: resource.to_string(),
1807 _delegate: Default::default(),
1808 _additional_params: Default::default(),
1809 _scopes: Default::default(),
1810 }
1811 }
1812
1813 /// Create a builder to help you perform the following task:
1814 ///
1815 /// Gets information about a location.
1816 ///
1817 /// # Arguments
1818 ///
1819 /// * `name` - Resource name for the location.
1820 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1821 ProjectLocationGetCall {
1822 hub: self.hub,
1823 _name: name.to_string(),
1824 _delegate: Default::default(),
1825 _additional_params: Default::default(),
1826 _scopes: Default::default(),
1827 }
1828 }
1829
1830 /// Create a builder to help you perform the following task:
1831 ///
1832 /// Gets the CMEK config. Gets the Customer Managed Encryption Key configured with the Cloud Tasks lcoation. By default there is no kms_key configured.
1833 ///
1834 /// # Arguments
1835 ///
1836 /// * `name` - Required. The config. For example: projects/PROJECT_ID/locations/LOCATION_ID/CmekConfig`
1837 pub fn locations_get_cmek_config(&self, name: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
1838 ProjectLocationGetCmekConfigCall {
1839 hub: self.hub,
1840 _name: name.to_string(),
1841 _delegate: Default::default(),
1842 _additional_params: Default::default(),
1843 _scopes: Default::default(),
1844 }
1845 }
1846
1847 /// Create a builder to help you perform the following task:
1848 ///
1849 /// Lists information about the supported locations for this service.
1850 ///
1851 /// # Arguments
1852 ///
1853 /// * `name` - The resource that owns the locations collection, if applicable.
1854 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1855 ProjectLocationListCall {
1856 hub: self.hub,
1857 _name: name.to_string(),
1858 _page_token: Default::default(),
1859 _page_size: Default::default(),
1860 _filter: Default::default(),
1861 _delegate: Default::default(),
1862 _additional_params: Default::default(),
1863 _scopes: Default::default(),
1864 }
1865 }
1866
1867 /// Create a builder to help you perform the following task:
1868 ///
1869 /// 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.
1870 ///
1871 /// # Arguments
1872 ///
1873 /// * `request` - No description provided.
1874 /// * `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`
1875 pub fn locations_update_cmek_config(
1876 &self,
1877 request: CmekConfig,
1878 name: &str,
1879 ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
1880 ProjectLocationUpdateCmekConfigCall {
1881 hub: self.hub,
1882 _request: request,
1883 _name: name.to_string(),
1884 _update_mask: Default::default(),
1885 _delegate: Default::default(),
1886 _additional_params: Default::default(),
1887 _scopes: Default::default(),
1888 }
1889 }
1890}
1891
1892// ###################
1893// CallBuilders ###
1894// #################
1895
1896/// 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.
1897///
1898/// A builder for the *queue.update* method supported by a *api* resource.
1899/// It is not used directly, but through a [`ApiMethods`] instance.
1900///
1901/// # Example
1902///
1903/// Instantiate a resource method builder
1904///
1905/// ```test_harness,no_run
1906/// # extern crate hyper;
1907/// # extern crate hyper_rustls;
1908/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
1909/// use cloudtasks2_beta2::api::HttpBody;
1910/// # async fn dox() {
1911/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1912///
1913/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1914/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1915/// # secret,
1916/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1917/// # ).build().await.unwrap();
1918///
1919/// # let client = hyper_util::client::legacy::Client::builder(
1920/// # hyper_util::rt::TokioExecutor::new()
1921/// # )
1922/// # .build(
1923/// # hyper_rustls::HttpsConnectorBuilder::new()
1924/// # .with_native_roots()
1925/// # .unwrap()
1926/// # .https_or_http()
1927/// # .enable_http1()
1928/// # .build()
1929/// # );
1930/// # let mut hub = CloudTasks::new(client, auth);
1931/// // As the method needs a request, you would usually fill it with the desired information
1932/// // into the respective structure. Some of the parts shown here might not be applicable !
1933/// // Values shown here are possibly random and not representative !
1934/// let mut req = HttpBody::default();
1935///
1936/// // You can configure optional parameters by calling the respective setters at will, and
1937/// // execute the final call using `doit()`.
1938/// // Values shown here are possibly random and not representative !
1939/// let result = hub.api().queue_update(req)
1940/// .app_id("ipsum")
1941/// .doit().await;
1942/// # }
1943/// ```
1944pub struct ApiQueueUpdateCall<'a, C>
1945where
1946 C: 'a,
1947{
1948 hub: &'a CloudTasks<C>,
1949 _request: HttpBody,
1950 _app_id: Option<String>,
1951 _delegate: Option<&'a mut dyn common::Delegate>,
1952 _additional_params: HashMap<String, String>,
1953 _scopes: BTreeSet<String>,
1954}
1955
1956impl<'a, C> common::CallBuilder for ApiQueueUpdateCall<'a, C> {}
1957
1958impl<'a, C> ApiQueueUpdateCall<'a, C>
1959where
1960 C: common::Connector,
1961{
1962 /// Perform the operation you have build so far.
1963 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1964 use std::borrow::Cow;
1965 use std::io::{Read, Seek};
1966
1967 use common::{url::Params, ToParts};
1968 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1969
1970 let mut dd = common::DefaultDelegate;
1971 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1972 dlg.begin(common::MethodInfo {
1973 id: "cloudtasks.api.queue.update",
1974 http_method: hyper::Method::POST,
1975 });
1976
1977 for &field in ["alt", "appId"].iter() {
1978 if self._additional_params.contains_key(field) {
1979 dlg.finished(false);
1980 return Err(common::Error::FieldClash(field));
1981 }
1982 }
1983
1984 let mut params = Params::with_capacity(4 + self._additional_params.len());
1985 if let Some(value) = self._app_id.as_ref() {
1986 params.push("appId", value);
1987 }
1988
1989 params.extend(self._additional_params.iter());
1990
1991 params.push("alt", "json");
1992 let mut url = self.hub._base_url.clone() + "api/queue/update";
1993 if self._scopes.is_empty() {
1994 self._scopes
1995 .insert(Scope::CloudPlatform.as_ref().to_string());
1996 }
1997
1998 let url = params.parse_with_url(&url);
1999
2000 let mut json_mime_type = mime::APPLICATION_JSON;
2001 let mut request_value_reader = {
2002 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2003 common::remove_json_null_values(&mut value);
2004 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2005 serde_json::to_writer(&mut dst, &value).unwrap();
2006 dst
2007 };
2008 let request_size = request_value_reader
2009 .seek(std::io::SeekFrom::End(0))
2010 .unwrap();
2011 request_value_reader
2012 .seek(std::io::SeekFrom::Start(0))
2013 .unwrap();
2014
2015 loop {
2016 let token = match self
2017 .hub
2018 .auth
2019 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2020 .await
2021 {
2022 Ok(token) => token,
2023 Err(e) => match dlg.token(e) {
2024 Ok(token) => token,
2025 Err(e) => {
2026 dlg.finished(false);
2027 return Err(common::Error::MissingToken(e));
2028 }
2029 },
2030 };
2031 request_value_reader
2032 .seek(std::io::SeekFrom::Start(0))
2033 .unwrap();
2034 let mut req_result = {
2035 let client = &self.hub.client;
2036 dlg.pre_request();
2037 let mut req_builder = hyper::Request::builder()
2038 .method(hyper::Method::POST)
2039 .uri(url.as_str())
2040 .header(USER_AGENT, self.hub._user_agent.clone());
2041
2042 if let Some(token) = token.as_ref() {
2043 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2044 }
2045
2046 let request = req_builder
2047 .header(CONTENT_TYPE, json_mime_type.to_string())
2048 .header(CONTENT_LENGTH, request_size as u64)
2049 .body(common::to_body(
2050 request_value_reader.get_ref().clone().into(),
2051 ));
2052
2053 client.request(request.unwrap()).await
2054 };
2055
2056 match req_result {
2057 Err(err) => {
2058 if let common::Retry::After(d) = dlg.http_error(&err) {
2059 sleep(d).await;
2060 continue;
2061 }
2062 dlg.finished(false);
2063 return Err(common::Error::HttpError(err));
2064 }
2065 Ok(res) => {
2066 let (mut parts, body) = res.into_parts();
2067 let mut body = common::Body::new(body);
2068 if !parts.status.is_success() {
2069 let bytes = common::to_bytes(body).await.unwrap_or_default();
2070 let error = serde_json::from_str(&common::to_string(&bytes));
2071 let response = common::to_response(parts, bytes.into());
2072
2073 if let common::Retry::After(d) =
2074 dlg.http_failure(&response, error.as_ref().ok())
2075 {
2076 sleep(d).await;
2077 continue;
2078 }
2079
2080 dlg.finished(false);
2081
2082 return Err(match error {
2083 Ok(value) => common::Error::BadRequest(value),
2084 _ => common::Error::Failure(response),
2085 });
2086 }
2087 let response = {
2088 let bytes = common::to_bytes(body).await.unwrap_or_default();
2089 let encoded = common::to_string(&bytes);
2090 match serde_json::from_str(&encoded) {
2091 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2092 Err(error) => {
2093 dlg.response_json_decode_error(&encoded, &error);
2094 return Err(common::Error::JsonDecodeError(
2095 encoded.to_string(),
2096 error,
2097 ));
2098 }
2099 }
2100 };
2101
2102 dlg.finished(true);
2103 return Ok(response);
2104 }
2105 }
2106 }
2107 }
2108
2109 ///
2110 /// Sets the *request* property to the given value.
2111 ///
2112 /// Even though the property as already been set when instantiating this call,
2113 /// we provide this method for API completeness.
2114 pub fn request(mut self, new_value: HttpBody) -> ApiQueueUpdateCall<'a, C> {
2115 self._request = new_value;
2116 self
2117 }
2118 /// 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.
2119 ///
2120 /// Sets the *app id* query property to the given value.
2121 pub fn app_id(mut self, new_value: &str) -> ApiQueueUpdateCall<'a, C> {
2122 self._app_id = Some(new_value.to_string());
2123 self
2124 }
2125 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2126 /// while executing the actual API request.
2127 ///
2128 /// ````text
2129 /// It should be used to handle progress information, and to implement a certain level of resilience.
2130 /// ````
2131 ///
2132 /// Sets the *delegate* property to the given value.
2133 pub fn delegate(
2134 mut self,
2135 new_value: &'a mut dyn common::Delegate,
2136 ) -> ApiQueueUpdateCall<'a, C> {
2137 self._delegate = Some(new_value);
2138 self
2139 }
2140
2141 /// Set any additional parameter of the query string used in the request.
2142 /// It should be used to set parameters which are not yet available through their own
2143 /// setters.
2144 ///
2145 /// Please note that this method must not be used to set any of the known parameters
2146 /// which have their own setter method. If done anyway, the request will fail.
2147 ///
2148 /// # Additional Parameters
2149 ///
2150 /// * *$.xgafv* (query-string) - V1 error format.
2151 /// * *access_token* (query-string) - OAuth access token.
2152 /// * *alt* (query-string) - Data format for response.
2153 /// * *callback* (query-string) - JSONP
2154 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2155 /// * *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.
2156 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2157 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2158 /// * *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.
2159 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2160 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2161 pub fn param<T>(mut self, name: T, value: T) -> ApiQueueUpdateCall<'a, C>
2162 where
2163 T: AsRef<str>,
2164 {
2165 self._additional_params
2166 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2167 self
2168 }
2169
2170 /// Identifies the authorization scope for the method you are building.
2171 ///
2172 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2173 /// [`Scope::CloudPlatform`].
2174 ///
2175 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2176 /// tokens for more than one scope.
2177 ///
2178 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2179 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2180 /// sufficient, a read-write scope will do as well.
2181 pub fn add_scope<St>(mut self, scope: St) -> ApiQueueUpdateCall<'a, C>
2182 where
2183 St: AsRef<str>,
2184 {
2185 self._scopes.insert(String::from(scope.as_ref()));
2186 self
2187 }
2188 /// Identifies the authorization scope(s) for the method you are building.
2189 ///
2190 /// See [`Self::add_scope()`] for details.
2191 pub fn add_scopes<I, St>(mut self, scopes: I) -> ApiQueueUpdateCall<'a, C>
2192 where
2193 I: IntoIterator<Item = St>,
2194 St: AsRef<str>,
2195 {
2196 self._scopes
2197 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2198 self
2199 }
2200
2201 /// Removes all scopes, and no default scope will be used either.
2202 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2203 /// for details).
2204 pub fn clear_scopes(mut self) -> ApiQueueUpdateCall<'a, C> {
2205 self._scopes.clear();
2206 self
2207 }
2208}
2209
2210/// 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.
2211///
2212/// A builder for the *locations.queues.tasks.acknowledge* method supported by a *project* resource.
2213/// It is not used directly, but through a [`ProjectMethods`] instance.
2214///
2215/// # Example
2216///
2217/// Instantiate a resource method builder
2218///
2219/// ```test_harness,no_run
2220/// # extern crate hyper;
2221/// # extern crate hyper_rustls;
2222/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
2223/// use cloudtasks2_beta2::api::AcknowledgeTaskRequest;
2224/// # async fn dox() {
2225/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2226///
2227/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2229/// # secret,
2230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2231/// # ).build().await.unwrap();
2232///
2233/// # let client = hyper_util::client::legacy::Client::builder(
2234/// # hyper_util::rt::TokioExecutor::new()
2235/// # )
2236/// # .build(
2237/// # hyper_rustls::HttpsConnectorBuilder::new()
2238/// # .with_native_roots()
2239/// # .unwrap()
2240/// # .https_or_http()
2241/// # .enable_http1()
2242/// # .build()
2243/// # );
2244/// # let mut hub = CloudTasks::new(client, auth);
2245/// // As the method needs a request, you would usually fill it with the desired information
2246/// // into the respective structure. Some of the parts shown here might not be applicable !
2247/// // Values shown here are possibly random and not representative !
2248/// let mut req = AcknowledgeTaskRequest::default();
2249///
2250/// // You can configure optional parameters by calling the respective setters at will, and
2251/// // execute the final call using `doit()`.
2252/// // Values shown here are possibly random and not representative !
2253/// let result = hub.projects().locations_queues_tasks_acknowledge(req, "name")
2254/// .doit().await;
2255/// # }
2256/// ```
2257pub struct ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2258where
2259 C: 'a,
2260{
2261 hub: &'a CloudTasks<C>,
2262 _request: AcknowledgeTaskRequest,
2263 _name: String,
2264 _delegate: Option<&'a mut dyn common::Delegate>,
2265 _additional_params: HashMap<String, String>,
2266 _scopes: BTreeSet<String>,
2267}
2268
2269impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskAcknowledgeCall<'a, C> {}
2270
2271impl<'a, C> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2272where
2273 C: common::Connector,
2274{
2275 /// Perform the operation you have build so far.
2276 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2277 use std::borrow::Cow;
2278 use std::io::{Read, Seek};
2279
2280 use common::{url::Params, ToParts};
2281 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2282
2283 let mut dd = common::DefaultDelegate;
2284 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2285 dlg.begin(common::MethodInfo {
2286 id: "cloudtasks.projects.locations.queues.tasks.acknowledge",
2287 http_method: hyper::Method::POST,
2288 });
2289
2290 for &field in ["alt", "name"].iter() {
2291 if self._additional_params.contains_key(field) {
2292 dlg.finished(false);
2293 return Err(common::Error::FieldClash(field));
2294 }
2295 }
2296
2297 let mut params = Params::with_capacity(4 + self._additional_params.len());
2298 params.push("name", self._name);
2299
2300 params.extend(self._additional_params.iter());
2301
2302 params.push("alt", "json");
2303 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:acknowledge";
2304 if self._scopes.is_empty() {
2305 self._scopes
2306 .insert(Scope::CloudPlatform.as_ref().to_string());
2307 }
2308
2309 #[allow(clippy::single_element_loop)]
2310 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2311 url = params.uri_replacement(url, param_name, find_this, true);
2312 }
2313 {
2314 let to_remove = ["name"];
2315 params.remove_params(&to_remove);
2316 }
2317
2318 let url = params.parse_with_url(&url);
2319
2320 let mut json_mime_type = mime::APPLICATION_JSON;
2321 let mut request_value_reader = {
2322 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2323 common::remove_json_null_values(&mut value);
2324 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2325 serde_json::to_writer(&mut dst, &value).unwrap();
2326 dst
2327 };
2328 let request_size = request_value_reader
2329 .seek(std::io::SeekFrom::End(0))
2330 .unwrap();
2331 request_value_reader
2332 .seek(std::io::SeekFrom::Start(0))
2333 .unwrap();
2334
2335 loop {
2336 let token = match self
2337 .hub
2338 .auth
2339 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2340 .await
2341 {
2342 Ok(token) => token,
2343 Err(e) => match dlg.token(e) {
2344 Ok(token) => token,
2345 Err(e) => {
2346 dlg.finished(false);
2347 return Err(common::Error::MissingToken(e));
2348 }
2349 },
2350 };
2351 request_value_reader
2352 .seek(std::io::SeekFrom::Start(0))
2353 .unwrap();
2354 let mut req_result = {
2355 let client = &self.hub.client;
2356 dlg.pre_request();
2357 let mut req_builder = hyper::Request::builder()
2358 .method(hyper::Method::POST)
2359 .uri(url.as_str())
2360 .header(USER_AGENT, self.hub._user_agent.clone());
2361
2362 if let Some(token) = token.as_ref() {
2363 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2364 }
2365
2366 let request = req_builder
2367 .header(CONTENT_TYPE, json_mime_type.to_string())
2368 .header(CONTENT_LENGTH, request_size as u64)
2369 .body(common::to_body(
2370 request_value_reader.get_ref().clone().into(),
2371 ));
2372
2373 client.request(request.unwrap()).await
2374 };
2375
2376 match req_result {
2377 Err(err) => {
2378 if let common::Retry::After(d) = dlg.http_error(&err) {
2379 sleep(d).await;
2380 continue;
2381 }
2382 dlg.finished(false);
2383 return Err(common::Error::HttpError(err));
2384 }
2385 Ok(res) => {
2386 let (mut parts, body) = res.into_parts();
2387 let mut body = common::Body::new(body);
2388 if !parts.status.is_success() {
2389 let bytes = common::to_bytes(body).await.unwrap_or_default();
2390 let error = serde_json::from_str(&common::to_string(&bytes));
2391 let response = common::to_response(parts, bytes.into());
2392
2393 if let common::Retry::After(d) =
2394 dlg.http_failure(&response, error.as_ref().ok())
2395 {
2396 sleep(d).await;
2397 continue;
2398 }
2399
2400 dlg.finished(false);
2401
2402 return Err(match error {
2403 Ok(value) => common::Error::BadRequest(value),
2404 _ => common::Error::Failure(response),
2405 });
2406 }
2407 let response = {
2408 let bytes = common::to_bytes(body).await.unwrap_or_default();
2409 let encoded = common::to_string(&bytes);
2410 match serde_json::from_str(&encoded) {
2411 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2412 Err(error) => {
2413 dlg.response_json_decode_error(&encoded, &error);
2414 return Err(common::Error::JsonDecodeError(
2415 encoded.to_string(),
2416 error,
2417 ));
2418 }
2419 }
2420 };
2421
2422 dlg.finished(true);
2423 return Ok(response);
2424 }
2425 }
2426 }
2427 }
2428
2429 ///
2430 /// Sets the *request* property to the given value.
2431 ///
2432 /// Even though the property as already been set when instantiating this call,
2433 /// we provide this method for API completeness.
2434 pub fn request(
2435 mut self,
2436 new_value: AcknowledgeTaskRequest,
2437 ) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2438 self._request = new_value;
2439 self
2440 }
2441 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2442 ///
2443 /// Sets the *name* path property to the given value.
2444 ///
2445 /// Even though the property as already been set when instantiating this call,
2446 /// we provide this method for API completeness.
2447 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2448 self._name = new_value.to_string();
2449 self
2450 }
2451 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2452 /// while executing the actual API request.
2453 ///
2454 /// ````text
2455 /// It should be used to handle progress information, and to implement a certain level of resilience.
2456 /// ````
2457 ///
2458 /// Sets the *delegate* property to the given value.
2459 pub fn delegate(
2460 mut self,
2461 new_value: &'a mut dyn common::Delegate,
2462 ) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2463 self._delegate = Some(new_value);
2464 self
2465 }
2466
2467 /// Set any additional parameter of the query string used in the request.
2468 /// It should be used to set parameters which are not yet available through their own
2469 /// setters.
2470 ///
2471 /// Please note that this method must not be used to set any of the known parameters
2472 /// which have their own setter method. If done anyway, the request will fail.
2473 ///
2474 /// # Additional Parameters
2475 ///
2476 /// * *$.xgafv* (query-string) - V1 error format.
2477 /// * *access_token* (query-string) - OAuth access token.
2478 /// * *alt* (query-string) - Data format for response.
2479 /// * *callback* (query-string) - JSONP
2480 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2481 /// * *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.
2482 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2483 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2484 /// * *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.
2485 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2486 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2487 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2488 where
2489 T: AsRef<str>,
2490 {
2491 self._additional_params
2492 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2493 self
2494 }
2495
2496 /// Identifies the authorization scope for the method you are building.
2497 ///
2498 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2499 /// [`Scope::CloudPlatform`].
2500 ///
2501 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2502 /// tokens for more than one scope.
2503 ///
2504 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2505 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2506 /// sufficient, a read-write scope will do as well.
2507 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2508 where
2509 St: AsRef<str>,
2510 {
2511 self._scopes.insert(String::from(scope.as_ref()));
2512 self
2513 }
2514 /// Identifies the authorization scope(s) for the method you are building.
2515 ///
2516 /// See [`Self::add_scope()`] for details.
2517 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C>
2518 where
2519 I: IntoIterator<Item = St>,
2520 St: AsRef<str>,
2521 {
2522 self._scopes
2523 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2524 self
2525 }
2526
2527 /// Removes all scopes, and no default scope will be used either.
2528 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2529 /// for details).
2530 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskAcknowledgeCall<'a, C> {
2531 self._scopes.clear();
2532 self
2533 }
2534}
2535
2536/// 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.
2537///
2538/// A builder for the *locations.queues.tasks.buffer* method supported by a *project* resource.
2539/// It is not used directly, but through a [`ProjectMethods`] instance.
2540///
2541/// # Example
2542///
2543/// Instantiate a resource method builder
2544///
2545/// ```test_harness,no_run
2546/// # extern crate hyper;
2547/// # extern crate hyper_rustls;
2548/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
2549/// use cloudtasks2_beta2::api::BufferTaskRequest;
2550/// # async fn dox() {
2551/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2552///
2553/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2554/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2555/// # secret,
2556/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2557/// # ).build().await.unwrap();
2558///
2559/// # let client = hyper_util::client::legacy::Client::builder(
2560/// # hyper_util::rt::TokioExecutor::new()
2561/// # )
2562/// # .build(
2563/// # hyper_rustls::HttpsConnectorBuilder::new()
2564/// # .with_native_roots()
2565/// # .unwrap()
2566/// # .https_or_http()
2567/// # .enable_http1()
2568/// # .build()
2569/// # );
2570/// # let mut hub = CloudTasks::new(client, auth);
2571/// // As the method needs a request, you would usually fill it with the desired information
2572/// // into the respective structure. Some of the parts shown here might not be applicable !
2573/// // Values shown here are possibly random and not representative !
2574/// let mut req = BufferTaskRequest::default();
2575///
2576/// // You can configure optional parameters by calling the respective setters at will, and
2577/// // execute the final call using `doit()`.
2578/// // Values shown here are possibly random and not representative !
2579/// let result = hub.projects().locations_queues_tasks_buffer(req, "queue", "taskId")
2580/// .doit().await;
2581/// # }
2582/// ```
2583pub struct ProjectLocationQueueTaskBufferCall<'a, C>
2584where
2585 C: 'a,
2586{
2587 hub: &'a CloudTasks<C>,
2588 _request: BufferTaskRequest,
2589 _queue: String,
2590 _task_id: String,
2591 _delegate: Option<&'a mut dyn common::Delegate>,
2592 _additional_params: HashMap<String, String>,
2593 _scopes: BTreeSet<String>,
2594}
2595
2596impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskBufferCall<'a, C> {}
2597
2598impl<'a, C> ProjectLocationQueueTaskBufferCall<'a, C>
2599where
2600 C: common::Connector,
2601{
2602 /// Perform the operation you have build so far.
2603 pub async fn doit(mut self) -> common::Result<(common::Response, BufferTaskResponse)> {
2604 use std::borrow::Cow;
2605 use std::io::{Read, Seek};
2606
2607 use common::{url::Params, ToParts};
2608 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2609
2610 let mut dd = common::DefaultDelegate;
2611 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2612 dlg.begin(common::MethodInfo {
2613 id: "cloudtasks.projects.locations.queues.tasks.buffer",
2614 http_method: hyper::Method::POST,
2615 });
2616
2617 for &field in ["alt", "queue", "taskId"].iter() {
2618 if self._additional_params.contains_key(field) {
2619 dlg.finished(false);
2620 return Err(common::Error::FieldClash(field));
2621 }
2622 }
2623
2624 let mut params = Params::with_capacity(5 + self._additional_params.len());
2625 params.push("queue", self._queue);
2626 params.push("taskId", self._task_id);
2627
2628 params.extend(self._additional_params.iter());
2629
2630 params.push("alt", "json");
2631 let mut url = self.hub._base_url.clone() + "v2beta2/{+queue}/tasks/{taskId}:buffer";
2632 if self._scopes.is_empty() {
2633 self._scopes
2634 .insert(Scope::CloudPlatform.as_ref().to_string());
2635 }
2636
2637 #[allow(clippy::single_element_loop)]
2638 for &(find_this, param_name) in [("{+queue}", "queue"), ("{taskId}", "taskId")].iter() {
2639 url = params.uri_replacement(url, param_name, find_this, true);
2640 }
2641 {
2642 let to_remove = ["taskId", "queue"];
2643 params.remove_params(&to_remove);
2644 }
2645
2646 let url = params.parse_with_url(&url);
2647
2648 let mut json_mime_type = mime::APPLICATION_JSON;
2649 let mut request_value_reader = {
2650 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2651 common::remove_json_null_values(&mut value);
2652 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2653 serde_json::to_writer(&mut dst, &value).unwrap();
2654 dst
2655 };
2656 let request_size = request_value_reader
2657 .seek(std::io::SeekFrom::End(0))
2658 .unwrap();
2659 request_value_reader
2660 .seek(std::io::SeekFrom::Start(0))
2661 .unwrap();
2662
2663 loop {
2664 let token = match self
2665 .hub
2666 .auth
2667 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2668 .await
2669 {
2670 Ok(token) => token,
2671 Err(e) => match dlg.token(e) {
2672 Ok(token) => token,
2673 Err(e) => {
2674 dlg.finished(false);
2675 return Err(common::Error::MissingToken(e));
2676 }
2677 },
2678 };
2679 request_value_reader
2680 .seek(std::io::SeekFrom::Start(0))
2681 .unwrap();
2682 let mut req_result = {
2683 let client = &self.hub.client;
2684 dlg.pre_request();
2685 let mut req_builder = hyper::Request::builder()
2686 .method(hyper::Method::POST)
2687 .uri(url.as_str())
2688 .header(USER_AGENT, self.hub._user_agent.clone());
2689
2690 if let Some(token) = token.as_ref() {
2691 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2692 }
2693
2694 let request = req_builder
2695 .header(CONTENT_TYPE, json_mime_type.to_string())
2696 .header(CONTENT_LENGTH, request_size as u64)
2697 .body(common::to_body(
2698 request_value_reader.get_ref().clone().into(),
2699 ));
2700
2701 client.request(request.unwrap()).await
2702 };
2703
2704 match req_result {
2705 Err(err) => {
2706 if let common::Retry::After(d) = dlg.http_error(&err) {
2707 sleep(d).await;
2708 continue;
2709 }
2710 dlg.finished(false);
2711 return Err(common::Error::HttpError(err));
2712 }
2713 Ok(res) => {
2714 let (mut parts, body) = res.into_parts();
2715 let mut body = common::Body::new(body);
2716 if !parts.status.is_success() {
2717 let bytes = common::to_bytes(body).await.unwrap_or_default();
2718 let error = serde_json::from_str(&common::to_string(&bytes));
2719 let response = common::to_response(parts, bytes.into());
2720
2721 if let common::Retry::After(d) =
2722 dlg.http_failure(&response, error.as_ref().ok())
2723 {
2724 sleep(d).await;
2725 continue;
2726 }
2727
2728 dlg.finished(false);
2729
2730 return Err(match error {
2731 Ok(value) => common::Error::BadRequest(value),
2732 _ => common::Error::Failure(response),
2733 });
2734 }
2735 let response = {
2736 let bytes = common::to_bytes(body).await.unwrap_or_default();
2737 let encoded = common::to_string(&bytes);
2738 match serde_json::from_str(&encoded) {
2739 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2740 Err(error) => {
2741 dlg.response_json_decode_error(&encoded, &error);
2742 return Err(common::Error::JsonDecodeError(
2743 encoded.to_string(),
2744 error,
2745 ));
2746 }
2747 }
2748 };
2749
2750 dlg.finished(true);
2751 return Ok(response);
2752 }
2753 }
2754 }
2755 }
2756
2757 ///
2758 /// Sets the *request* property to the given value.
2759 ///
2760 /// Even though the property as already been set when instantiating this call,
2761 /// we provide this method for API completeness.
2762 pub fn request(
2763 mut self,
2764 new_value: BufferTaskRequest,
2765 ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2766 self._request = new_value;
2767 self
2768 }
2769 /// Required. The parent queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
2770 ///
2771 /// Sets the *queue* path property to the given value.
2772 ///
2773 /// Even though the property as already been set when instantiating this call,
2774 /// we provide this method for API completeness.
2775 pub fn queue(mut self, new_value: &str) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2776 self._queue = new_value.to_string();
2777 self
2778 }
2779 /// Optional. Task ID for the task being created. If not provided, a random task ID is assigned to the task.
2780 ///
2781 /// Sets the *task id* path property to the given value.
2782 ///
2783 /// Even though the property as already been set when instantiating this call,
2784 /// we provide this method for API completeness.
2785 pub fn task_id(mut self, new_value: &str) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2786 self._task_id = new_value.to_string();
2787 self
2788 }
2789 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2790 /// while executing the actual API request.
2791 ///
2792 /// ````text
2793 /// It should be used to handle progress information, and to implement a certain level of resilience.
2794 /// ````
2795 ///
2796 /// Sets the *delegate* property to the given value.
2797 pub fn delegate(
2798 mut self,
2799 new_value: &'a mut dyn common::Delegate,
2800 ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2801 self._delegate = Some(new_value);
2802 self
2803 }
2804
2805 /// Set any additional parameter of the query string used in the request.
2806 /// It should be used to set parameters which are not yet available through their own
2807 /// setters.
2808 ///
2809 /// Please note that this method must not be used to set any of the known parameters
2810 /// which have their own setter method. If done anyway, the request will fail.
2811 ///
2812 /// # Additional Parameters
2813 ///
2814 /// * *$.xgafv* (query-string) - V1 error format.
2815 /// * *access_token* (query-string) - OAuth access token.
2816 /// * *alt* (query-string) - Data format for response.
2817 /// * *callback* (query-string) - JSONP
2818 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2819 /// * *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.
2820 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2821 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2822 /// * *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.
2823 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2824 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2825 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskBufferCall<'a, C>
2826 where
2827 T: AsRef<str>,
2828 {
2829 self._additional_params
2830 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2831 self
2832 }
2833
2834 /// Identifies the authorization scope for the method you are building.
2835 ///
2836 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2837 /// [`Scope::CloudPlatform`].
2838 ///
2839 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2840 /// tokens for more than one scope.
2841 ///
2842 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2843 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2844 /// sufficient, a read-write scope will do as well.
2845 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskBufferCall<'a, C>
2846 where
2847 St: AsRef<str>,
2848 {
2849 self._scopes.insert(String::from(scope.as_ref()));
2850 self
2851 }
2852 /// Identifies the authorization scope(s) for the method you are building.
2853 ///
2854 /// See [`Self::add_scope()`] for details.
2855 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskBufferCall<'a, C>
2856 where
2857 I: IntoIterator<Item = St>,
2858 St: AsRef<str>,
2859 {
2860 self._scopes
2861 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2862 self
2863 }
2864
2865 /// Removes all scopes, and no default scope will be used either.
2866 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2867 /// for details).
2868 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskBufferCall<'a, C> {
2869 self._scopes.clear();
2870 self
2871 }
2872}
2873
2874/// 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.
2875///
2876/// A builder for the *locations.queues.tasks.cancelLease* method supported by a *project* resource.
2877/// It is not used directly, but through a [`ProjectMethods`] instance.
2878///
2879/// # Example
2880///
2881/// Instantiate a resource method builder
2882///
2883/// ```test_harness,no_run
2884/// # extern crate hyper;
2885/// # extern crate hyper_rustls;
2886/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
2887/// use cloudtasks2_beta2::api::CancelLeaseRequest;
2888/// # async fn dox() {
2889/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2890///
2891/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2892/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2893/// # secret,
2894/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2895/// # ).build().await.unwrap();
2896///
2897/// # let client = hyper_util::client::legacy::Client::builder(
2898/// # hyper_util::rt::TokioExecutor::new()
2899/// # )
2900/// # .build(
2901/// # hyper_rustls::HttpsConnectorBuilder::new()
2902/// # .with_native_roots()
2903/// # .unwrap()
2904/// # .https_or_http()
2905/// # .enable_http1()
2906/// # .build()
2907/// # );
2908/// # let mut hub = CloudTasks::new(client, auth);
2909/// // As the method needs a request, you would usually fill it with the desired information
2910/// // into the respective structure. Some of the parts shown here might not be applicable !
2911/// // Values shown here are possibly random and not representative !
2912/// let mut req = CancelLeaseRequest::default();
2913///
2914/// // You can configure optional parameters by calling the respective setters at will, and
2915/// // execute the final call using `doit()`.
2916/// // Values shown here are possibly random and not representative !
2917/// let result = hub.projects().locations_queues_tasks_cancel_lease(req, "name")
2918/// .doit().await;
2919/// # }
2920/// ```
2921pub struct ProjectLocationQueueTaskCancelLeaseCall<'a, C>
2922where
2923 C: 'a,
2924{
2925 hub: &'a CloudTasks<C>,
2926 _request: CancelLeaseRequest,
2927 _name: String,
2928 _delegate: Option<&'a mut dyn common::Delegate>,
2929 _additional_params: HashMap<String, String>,
2930 _scopes: BTreeSet<String>,
2931}
2932
2933impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskCancelLeaseCall<'a, C> {}
2934
2935impl<'a, C> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
2936where
2937 C: common::Connector,
2938{
2939 /// Perform the operation you have build so far.
2940 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
2941 use std::borrow::Cow;
2942 use std::io::{Read, Seek};
2943
2944 use common::{url::Params, ToParts};
2945 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2946
2947 let mut dd = common::DefaultDelegate;
2948 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2949 dlg.begin(common::MethodInfo {
2950 id: "cloudtasks.projects.locations.queues.tasks.cancelLease",
2951 http_method: hyper::Method::POST,
2952 });
2953
2954 for &field in ["alt", "name"].iter() {
2955 if self._additional_params.contains_key(field) {
2956 dlg.finished(false);
2957 return Err(common::Error::FieldClash(field));
2958 }
2959 }
2960
2961 let mut params = Params::with_capacity(4 + self._additional_params.len());
2962 params.push("name", self._name);
2963
2964 params.extend(self._additional_params.iter());
2965
2966 params.push("alt", "json");
2967 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:cancelLease";
2968 if self._scopes.is_empty() {
2969 self._scopes
2970 .insert(Scope::CloudPlatform.as_ref().to_string());
2971 }
2972
2973 #[allow(clippy::single_element_loop)]
2974 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2975 url = params.uri_replacement(url, param_name, find_this, true);
2976 }
2977 {
2978 let to_remove = ["name"];
2979 params.remove_params(&to_remove);
2980 }
2981
2982 let url = params.parse_with_url(&url);
2983
2984 let mut json_mime_type = mime::APPLICATION_JSON;
2985 let mut request_value_reader = {
2986 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2987 common::remove_json_null_values(&mut value);
2988 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2989 serde_json::to_writer(&mut dst, &value).unwrap();
2990 dst
2991 };
2992 let request_size = request_value_reader
2993 .seek(std::io::SeekFrom::End(0))
2994 .unwrap();
2995 request_value_reader
2996 .seek(std::io::SeekFrom::Start(0))
2997 .unwrap();
2998
2999 loop {
3000 let token = match self
3001 .hub
3002 .auth
3003 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3004 .await
3005 {
3006 Ok(token) => token,
3007 Err(e) => match dlg.token(e) {
3008 Ok(token) => token,
3009 Err(e) => {
3010 dlg.finished(false);
3011 return Err(common::Error::MissingToken(e));
3012 }
3013 },
3014 };
3015 request_value_reader
3016 .seek(std::io::SeekFrom::Start(0))
3017 .unwrap();
3018 let mut req_result = {
3019 let client = &self.hub.client;
3020 dlg.pre_request();
3021 let mut req_builder = hyper::Request::builder()
3022 .method(hyper::Method::POST)
3023 .uri(url.as_str())
3024 .header(USER_AGENT, self.hub._user_agent.clone());
3025
3026 if let Some(token) = token.as_ref() {
3027 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3028 }
3029
3030 let request = req_builder
3031 .header(CONTENT_TYPE, json_mime_type.to_string())
3032 .header(CONTENT_LENGTH, request_size as u64)
3033 .body(common::to_body(
3034 request_value_reader.get_ref().clone().into(),
3035 ));
3036
3037 client.request(request.unwrap()).await
3038 };
3039
3040 match req_result {
3041 Err(err) => {
3042 if let common::Retry::After(d) = dlg.http_error(&err) {
3043 sleep(d).await;
3044 continue;
3045 }
3046 dlg.finished(false);
3047 return Err(common::Error::HttpError(err));
3048 }
3049 Ok(res) => {
3050 let (mut parts, body) = res.into_parts();
3051 let mut body = common::Body::new(body);
3052 if !parts.status.is_success() {
3053 let bytes = common::to_bytes(body).await.unwrap_or_default();
3054 let error = serde_json::from_str(&common::to_string(&bytes));
3055 let response = common::to_response(parts, bytes.into());
3056
3057 if let common::Retry::After(d) =
3058 dlg.http_failure(&response, error.as_ref().ok())
3059 {
3060 sleep(d).await;
3061 continue;
3062 }
3063
3064 dlg.finished(false);
3065
3066 return Err(match error {
3067 Ok(value) => common::Error::BadRequest(value),
3068 _ => common::Error::Failure(response),
3069 });
3070 }
3071 let response = {
3072 let bytes = common::to_bytes(body).await.unwrap_or_default();
3073 let encoded = common::to_string(&bytes);
3074 match serde_json::from_str(&encoded) {
3075 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3076 Err(error) => {
3077 dlg.response_json_decode_error(&encoded, &error);
3078 return Err(common::Error::JsonDecodeError(
3079 encoded.to_string(),
3080 error,
3081 ));
3082 }
3083 }
3084 };
3085
3086 dlg.finished(true);
3087 return Ok(response);
3088 }
3089 }
3090 }
3091 }
3092
3093 ///
3094 /// Sets the *request* property to the given value.
3095 ///
3096 /// Even though the property as already been set when instantiating this call,
3097 /// we provide this method for API completeness.
3098 pub fn request(
3099 mut self,
3100 new_value: CancelLeaseRequest,
3101 ) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3102 self._request = new_value;
3103 self
3104 }
3105 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
3106 ///
3107 /// Sets the *name* path property to the given value.
3108 ///
3109 /// Even though the property as already been set when instantiating this call,
3110 /// we provide this method for API completeness.
3111 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3112 self._name = new_value.to_string();
3113 self
3114 }
3115 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3116 /// while executing the actual API request.
3117 ///
3118 /// ````text
3119 /// It should be used to handle progress information, and to implement a certain level of resilience.
3120 /// ````
3121 ///
3122 /// Sets the *delegate* property to the given value.
3123 pub fn delegate(
3124 mut self,
3125 new_value: &'a mut dyn common::Delegate,
3126 ) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3127 self._delegate = Some(new_value);
3128 self
3129 }
3130
3131 /// Set any additional parameter of the query string used in the request.
3132 /// It should be used to set parameters which are not yet available through their own
3133 /// setters.
3134 ///
3135 /// Please note that this method must not be used to set any of the known parameters
3136 /// which have their own setter method. If done anyway, the request will fail.
3137 ///
3138 /// # Additional Parameters
3139 ///
3140 /// * *$.xgafv* (query-string) - V1 error format.
3141 /// * *access_token* (query-string) - OAuth access token.
3142 /// * *alt* (query-string) - Data format for response.
3143 /// * *callback* (query-string) - JSONP
3144 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3145 /// * *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.
3146 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3147 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3148 /// * *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.
3149 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3150 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3151 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3152 where
3153 T: AsRef<str>,
3154 {
3155 self._additional_params
3156 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3157 self
3158 }
3159
3160 /// Identifies the authorization scope for the method you are building.
3161 ///
3162 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3163 /// [`Scope::CloudPlatform`].
3164 ///
3165 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3166 /// tokens for more than one scope.
3167 ///
3168 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3169 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3170 /// sufficient, a read-write scope will do as well.
3171 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3172 where
3173 St: AsRef<str>,
3174 {
3175 self._scopes.insert(String::from(scope.as_ref()));
3176 self
3177 }
3178 /// Identifies the authorization scope(s) for the method you are building.
3179 ///
3180 /// See [`Self::add_scope()`] for details.
3181 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C>
3182 where
3183 I: IntoIterator<Item = St>,
3184 St: AsRef<str>,
3185 {
3186 self._scopes
3187 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3188 self
3189 }
3190
3191 /// Removes all scopes, and no default scope will be used either.
3192 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3193 /// for details).
3194 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskCancelLeaseCall<'a, C> {
3195 self._scopes.clear();
3196 self
3197 }
3198}
3199
3200/// 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.
3201///
3202/// A builder for the *locations.queues.tasks.create* method supported by a *project* resource.
3203/// It is not used directly, but through a [`ProjectMethods`] instance.
3204///
3205/// # Example
3206///
3207/// Instantiate a resource method builder
3208///
3209/// ```test_harness,no_run
3210/// # extern crate hyper;
3211/// # extern crate hyper_rustls;
3212/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
3213/// use cloudtasks2_beta2::api::CreateTaskRequest;
3214/// # async fn dox() {
3215/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3216///
3217/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3218/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3219/// # secret,
3220/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3221/// # ).build().await.unwrap();
3222///
3223/// # let client = hyper_util::client::legacy::Client::builder(
3224/// # hyper_util::rt::TokioExecutor::new()
3225/// # )
3226/// # .build(
3227/// # hyper_rustls::HttpsConnectorBuilder::new()
3228/// # .with_native_roots()
3229/// # .unwrap()
3230/// # .https_or_http()
3231/// # .enable_http1()
3232/// # .build()
3233/// # );
3234/// # let mut hub = CloudTasks::new(client, auth);
3235/// // As the method needs a request, you would usually fill it with the desired information
3236/// // into the respective structure. Some of the parts shown here might not be applicable !
3237/// // Values shown here are possibly random and not representative !
3238/// let mut req = CreateTaskRequest::default();
3239///
3240/// // You can configure optional parameters by calling the respective setters at will, and
3241/// // execute the final call using `doit()`.
3242/// // Values shown here are possibly random and not representative !
3243/// let result = hub.projects().locations_queues_tasks_create(req, "parent")
3244/// .doit().await;
3245/// # }
3246/// ```
3247pub struct ProjectLocationQueueTaskCreateCall<'a, C>
3248where
3249 C: 'a,
3250{
3251 hub: &'a CloudTasks<C>,
3252 _request: CreateTaskRequest,
3253 _parent: String,
3254 _delegate: Option<&'a mut dyn common::Delegate>,
3255 _additional_params: HashMap<String, String>,
3256 _scopes: BTreeSet<String>,
3257}
3258
3259impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskCreateCall<'a, C> {}
3260
3261impl<'a, C> ProjectLocationQueueTaskCreateCall<'a, C>
3262where
3263 C: common::Connector,
3264{
3265 /// Perform the operation you have build so far.
3266 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3267 use std::borrow::Cow;
3268 use std::io::{Read, Seek};
3269
3270 use common::{url::Params, ToParts};
3271 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3272
3273 let mut dd = common::DefaultDelegate;
3274 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3275 dlg.begin(common::MethodInfo {
3276 id: "cloudtasks.projects.locations.queues.tasks.create",
3277 http_method: hyper::Method::POST,
3278 });
3279
3280 for &field in ["alt", "parent"].iter() {
3281 if self._additional_params.contains_key(field) {
3282 dlg.finished(false);
3283 return Err(common::Error::FieldClash(field));
3284 }
3285 }
3286
3287 let mut params = Params::with_capacity(4 + self._additional_params.len());
3288 params.push("parent", self._parent);
3289
3290 params.extend(self._additional_params.iter());
3291
3292 params.push("alt", "json");
3293 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/tasks";
3294 if self._scopes.is_empty() {
3295 self._scopes
3296 .insert(Scope::CloudPlatform.as_ref().to_string());
3297 }
3298
3299 #[allow(clippy::single_element_loop)]
3300 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3301 url = params.uri_replacement(url, param_name, find_this, true);
3302 }
3303 {
3304 let to_remove = ["parent"];
3305 params.remove_params(&to_remove);
3306 }
3307
3308 let url = params.parse_with_url(&url);
3309
3310 let mut json_mime_type = mime::APPLICATION_JSON;
3311 let mut request_value_reader = {
3312 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3313 common::remove_json_null_values(&mut value);
3314 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3315 serde_json::to_writer(&mut dst, &value).unwrap();
3316 dst
3317 };
3318 let request_size = request_value_reader
3319 .seek(std::io::SeekFrom::End(0))
3320 .unwrap();
3321 request_value_reader
3322 .seek(std::io::SeekFrom::Start(0))
3323 .unwrap();
3324
3325 loop {
3326 let token = match self
3327 .hub
3328 .auth
3329 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3330 .await
3331 {
3332 Ok(token) => token,
3333 Err(e) => match dlg.token(e) {
3334 Ok(token) => token,
3335 Err(e) => {
3336 dlg.finished(false);
3337 return Err(common::Error::MissingToken(e));
3338 }
3339 },
3340 };
3341 request_value_reader
3342 .seek(std::io::SeekFrom::Start(0))
3343 .unwrap();
3344 let mut req_result = {
3345 let client = &self.hub.client;
3346 dlg.pre_request();
3347 let mut req_builder = hyper::Request::builder()
3348 .method(hyper::Method::POST)
3349 .uri(url.as_str())
3350 .header(USER_AGENT, self.hub._user_agent.clone());
3351
3352 if let Some(token) = token.as_ref() {
3353 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3354 }
3355
3356 let request = req_builder
3357 .header(CONTENT_TYPE, json_mime_type.to_string())
3358 .header(CONTENT_LENGTH, request_size as u64)
3359 .body(common::to_body(
3360 request_value_reader.get_ref().clone().into(),
3361 ));
3362
3363 client.request(request.unwrap()).await
3364 };
3365
3366 match req_result {
3367 Err(err) => {
3368 if let common::Retry::After(d) = dlg.http_error(&err) {
3369 sleep(d).await;
3370 continue;
3371 }
3372 dlg.finished(false);
3373 return Err(common::Error::HttpError(err));
3374 }
3375 Ok(res) => {
3376 let (mut parts, body) = res.into_parts();
3377 let mut body = common::Body::new(body);
3378 if !parts.status.is_success() {
3379 let bytes = common::to_bytes(body).await.unwrap_or_default();
3380 let error = serde_json::from_str(&common::to_string(&bytes));
3381 let response = common::to_response(parts, bytes.into());
3382
3383 if let common::Retry::After(d) =
3384 dlg.http_failure(&response, error.as_ref().ok())
3385 {
3386 sleep(d).await;
3387 continue;
3388 }
3389
3390 dlg.finished(false);
3391
3392 return Err(match error {
3393 Ok(value) => common::Error::BadRequest(value),
3394 _ => common::Error::Failure(response),
3395 });
3396 }
3397 let response = {
3398 let bytes = common::to_bytes(body).await.unwrap_or_default();
3399 let encoded = common::to_string(&bytes);
3400 match serde_json::from_str(&encoded) {
3401 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3402 Err(error) => {
3403 dlg.response_json_decode_error(&encoded, &error);
3404 return Err(common::Error::JsonDecodeError(
3405 encoded.to_string(),
3406 error,
3407 ));
3408 }
3409 }
3410 };
3411
3412 dlg.finished(true);
3413 return Ok(response);
3414 }
3415 }
3416 }
3417 }
3418
3419 ///
3420 /// Sets the *request* property to the given value.
3421 ///
3422 /// Even though the property as already been set when instantiating this call,
3423 /// we provide this method for API completeness.
3424 pub fn request(
3425 mut self,
3426 new_value: CreateTaskRequest,
3427 ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3428 self._request = new_value;
3429 self
3430 }
3431 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
3432 ///
3433 /// Sets the *parent* path property to the given value.
3434 ///
3435 /// Even though the property as already been set when instantiating this call,
3436 /// we provide this method for API completeness.
3437 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3438 self._parent = new_value.to_string();
3439 self
3440 }
3441 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3442 /// while executing the actual API request.
3443 ///
3444 /// ````text
3445 /// It should be used to handle progress information, and to implement a certain level of resilience.
3446 /// ````
3447 ///
3448 /// Sets the *delegate* property to the given value.
3449 pub fn delegate(
3450 mut self,
3451 new_value: &'a mut dyn common::Delegate,
3452 ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3453 self._delegate = Some(new_value);
3454 self
3455 }
3456
3457 /// Set any additional parameter of the query string used in the request.
3458 /// It should be used to set parameters which are not yet available through their own
3459 /// setters.
3460 ///
3461 /// Please note that this method must not be used to set any of the known parameters
3462 /// which have their own setter method. If done anyway, the request will fail.
3463 ///
3464 /// # Additional Parameters
3465 ///
3466 /// * *$.xgafv* (query-string) - V1 error format.
3467 /// * *access_token* (query-string) - OAuth access token.
3468 /// * *alt* (query-string) - Data format for response.
3469 /// * *callback* (query-string) - JSONP
3470 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3471 /// * *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.
3472 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3473 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3474 /// * *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.
3475 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3476 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3477 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskCreateCall<'a, C>
3478 where
3479 T: AsRef<str>,
3480 {
3481 self._additional_params
3482 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3483 self
3484 }
3485
3486 /// Identifies the authorization scope for the method you are building.
3487 ///
3488 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3489 /// [`Scope::CloudPlatform`].
3490 ///
3491 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3492 /// tokens for more than one scope.
3493 ///
3494 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3495 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3496 /// sufficient, a read-write scope will do as well.
3497 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskCreateCall<'a, C>
3498 where
3499 St: AsRef<str>,
3500 {
3501 self._scopes.insert(String::from(scope.as_ref()));
3502 self
3503 }
3504 /// Identifies the authorization scope(s) for the method you are building.
3505 ///
3506 /// See [`Self::add_scope()`] for details.
3507 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskCreateCall<'a, C>
3508 where
3509 I: IntoIterator<Item = St>,
3510 St: AsRef<str>,
3511 {
3512 self._scopes
3513 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3514 self
3515 }
3516
3517 /// Removes all scopes, and no default scope will be used either.
3518 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3519 /// for details).
3520 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskCreateCall<'a, C> {
3521 self._scopes.clear();
3522 self
3523 }
3524}
3525
3526/// 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.
3527///
3528/// A builder for the *locations.queues.tasks.delete* method supported by a *project* resource.
3529/// It is not used directly, but through a [`ProjectMethods`] instance.
3530///
3531/// # Example
3532///
3533/// Instantiate a resource method builder
3534///
3535/// ```test_harness,no_run
3536/// # extern crate hyper;
3537/// # extern crate hyper_rustls;
3538/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
3539/// # async fn dox() {
3540/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3541///
3542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3544/// # secret,
3545/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3546/// # ).build().await.unwrap();
3547///
3548/// # let client = hyper_util::client::legacy::Client::builder(
3549/// # hyper_util::rt::TokioExecutor::new()
3550/// # )
3551/// # .build(
3552/// # hyper_rustls::HttpsConnectorBuilder::new()
3553/// # .with_native_roots()
3554/// # .unwrap()
3555/// # .https_or_http()
3556/// # .enable_http1()
3557/// # .build()
3558/// # );
3559/// # let mut hub = CloudTasks::new(client, auth);
3560/// // You can configure optional parameters by calling the respective setters at will, and
3561/// // execute the final call using `doit()`.
3562/// // Values shown here are possibly random and not representative !
3563/// let result = hub.projects().locations_queues_tasks_delete("name")
3564/// .doit().await;
3565/// # }
3566/// ```
3567pub struct ProjectLocationQueueTaskDeleteCall<'a, C>
3568where
3569 C: 'a,
3570{
3571 hub: &'a CloudTasks<C>,
3572 _name: String,
3573 _delegate: Option<&'a mut dyn common::Delegate>,
3574 _additional_params: HashMap<String, String>,
3575 _scopes: BTreeSet<String>,
3576}
3577
3578impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskDeleteCall<'a, C> {}
3579
3580impl<'a, C> ProjectLocationQueueTaskDeleteCall<'a, C>
3581where
3582 C: common::Connector,
3583{
3584 /// Perform the operation you have build so far.
3585 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3586 use std::borrow::Cow;
3587 use std::io::{Read, Seek};
3588
3589 use common::{url::Params, ToParts};
3590 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3591
3592 let mut dd = common::DefaultDelegate;
3593 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3594 dlg.begin(common::MethodInfo {
3595 id: "cloudtasks.projects.locations.queues.tasks.delete",
3596 http_method: hyper::Method::DELETE,
3597 });
3598
3599 for &field in ["alt", "name"].iter() {
3600 if self._additional_params.contains_key(field) {
3601 dlg.finished(false);
3602 return Err(common::Error::FieldClash(field));
3603 }
3604 }
3605
3606 let mut params = Params::with_capacity(3 + self._additional_params.len());
3607 params.push("name", self._name);
3608
3609 params.extend(self._additional_params.iter());
3610
3611 params.push("alt", "json");
3612 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
3613 if self._scopes.is_empty() {
3614 self._scopes
3615 .insert(Scope::CloudPlatform.as_ref().to_string());
3616 }
3617
3618 #[allow(clippy::single_element_loop)]
3619 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3620 url = params.uri_replacement(url, param_name, find_this, true);
3621 }
3622 {
3623 let to_remove = ["name"];
3624 params.remove_params(&to_remove);
3625 }
3626
3627 let url = params.parse_with_url(&url);
3628
3629 loop {
3630 let token = match self
3631 .hub
3632 .auth
3633 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3634 .await
3635 {
3636 Ok(token) => token,
3637 Err(e) => match dlg.token(e) {
3638 Ok(token) => token,
3639 Err(e) => {
3640 dlg.finished(false);
3641 return Err(common::Error::MissingToken(e));
3642 }
3643 },
3644 };
3645 let mut req_result = {
3646 let client = &self.hub.client;
3647 dlg.pre_request();
3648 let mut req_builder = hyper::Request::builder()
3649 .method(hyper::Method::DELETE)
3650 .uri(url.as_str())
3651 .header(USER_AGENT, self.hub._user_agent.clone());
3652
3653 if let Some(token) = token.as_ref() {
3654 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3655 }
3656
3657 let request = req_builder
3658 .header(CONTENT_LENGTH, 0_u64)
3659 .body(common::to_body::<String>(None));
3660
3661 client.request(request.unwrap()).await
3662 };
3663
3664 match req_result {
3665 Err(err) => {
3666 if let common::Retry::After(d) = dlg.http_error(&err) {
3667 sleep(d).await;
3668 continue;
3669 }
3670 dlg.finished(false);
3671 return Err(common::Error::HttpError(err));
3672 }
3673 Ok(res) => {
3674 let (mut parts, body) = res.into_parts();
3675 let mut body = common::Body::new(body);
3676 if !parts.status.is_success() {
3677 let bytes = common::to_bytes(body).await.unwrap_or_default();
3678 let error = serde_json::from_str(&common::to_string(&bytes));
3679 let response = common::to_response(parts, bytes.into());
3680
3681 if let common::Retry::After(d) =
3682 dlg.http_failure(&response, error.as_ref().ok())
3683 {
3684 sleep(d).await;
3685 continue;
3686 }
3687
3688 dlg.finished(false);
3689
3690 return Err(match error {
3691 Ok(value) => common::Error::BadRequest(value),
3692 _ => common::Error::Failure(response),
3693 });
3694 }
3695 let response = {
3696 let bytes = common::to_bytes(body).await.unwrap_or_default();
3697 let encoded = common::to_string(&bytes);
3698 match serde_json::from_str(&encoded) {
3699 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3700 Err(error) => {
3701 dlg.response_json_decode_error(&encoded, &error);
3702 return Err(common::Error::JsonDecodeError(
3703 encoded.to_string(),
3704 error,
3705 ));
3706 }
3707 }
3708 };
3709
3710 dlg.finished(true);
3711 return Ok(response);
3712 }
3713 }
3714 }
3715 }
3716
3717 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
3718 ///
3719 /// Sets the *name* path property to the given value.
3720 ///
3721 /// Even though the property as already been set when instantiating this call,
3722 /// we provide this method for API completeness.
3723 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
3724 self._name = new_value.to_string();
3725 self
3726 }
3727 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3728 /// while executing the actual API request.
3729 ///
3730 /// ````text
3731 /// It should be used to handle progress information, and to implement a certain level of resilience.
3732 /// ````
3733 ///
3734 /// Sets the *delegate* property to the given value.
3735 pub fn delegate(
3736 mut self,
3737 new_value: &'a mut dyn common::Delegate,
3738 ) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
3739 self._delegate = Some(new_value);
3740 self
3741 }
3742
3743 /// Set any additional parameter of the query string used in the request.
3744 /// It should be used to set parameters which are not yet available through their own
3745 /// setters.
3746 ///
3747 /// Please note that this method must not be used to set any of the known parameters
3748 /// which have their own setter method. If done anyway, the request will fail.
3749 ///
3750 /// # Additional Parameters
3751 ///
3752 /// * *$.xgafv* (query-string) - V1 error format.
3753 /// * *access_token* (query-string) - OAuth access token.
3754 /// * *alt* (query-string) - Data format for response.
3755 /// * *callback* (query-string) - JSONP
3756 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3757 /// * *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.
3758 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3759 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3760 /// * *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.
3761 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3762 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3763 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskDeleteCall<'a, C>
3764 where
3765 T: AsRef<str>,
3766 {
3767 self._additional_params
3768 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3769 self
3770 }
3771
3772 /// Identifies the authorization scope for the method you are building.
3773 ///
3774 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3775 /// [`Scope::CloudPlatform`].
3776 ///
3777 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3778 /// tokens for more than one scope.
3779 ///
3780 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3781 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3782 /// sufficient, a read-write scope will do as well.
3783 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskDeleteCall<'a, C>
3784 where
3785 St: AsRef<str>,
3786 {
3787 self._scopes.insert(String::from(scope.as_ref()));
3788 self
3789 }
3790 /// Identifies the authorization scope(s) for the method you are building.
3791 ///
3792 /// See [`Self::add_scope()`] for details.
3793 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskDeleteCall<'a, C>
3794 where
3795 I: IntoIterator<Item = St>,
3796 St: AsRef<str>,
3797 {
3798 self._scopes
3799 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3800 self
3801 }
3802
3803 /// Removes all scopes, and no default scope will be used either.
3804 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3805 /// for details).
3806 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
3807 self._scopes.clear();
3808 self
3809 }
3810}
3811
3812/// Gets a task.
3813///
3814/// A builder for the *locations.queues.tasks.get* method supported by a *project* resource.
3815/// It is not used directly, but through a [`ProjectMethods`] instance.
3816///
3817/// # Example
3818///
3819/// Instantiate a resource method builder
3820///
3821/// ```test_harness,no_run
3822/// # extern crate hyper;
3823/// # extern crate hyper_rustls;
3824/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
3825/// # async fn dox() {
3826/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3827///
3828/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3829/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3830/// # secret,
3831/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3832/// # ).build().await.unwrap();
3833///
3834/// # let client = hyper_util::client::legacy::Client::builder(
3835/// # hyper_util::rt::TokioExecutor::new()
3836/// # )
3837/// # .build(
3838/// # hyper_rustls::HttpsConnectorBuilder::new()
3839/// # .with_native_roots()
3840/// # .unwrap()
3841/// # .https_or_http()
3842/// # .enable_http1()
3843/// # .build()
3844/// # );
3845/// # let mut hub = CloudTasks::new(client, auth);
3846/// // You can configure optional parameters by calling the respective setters at will, and
3847/// // execute the final call using `doit()`.
3848/// // Values shown here are possibly random and not representative !
3849/// let result = hub.projects().locations_queues_tasks_get("name")
3850/// .response_view("duo")
3851/// .doit().await;
3852/// # }
3853/// ```
3854pub struct ProjectLocationQueueTaskGetCall<'a, C>
3855where
3856 C: 'a,
3857{
3858 hub: &'a CloudTasks<C>,
3859 _name: String,
3860 _response_view: Option<String>,
3861 _delegate: Option<&'a mut dyn common::Delegate>,
3862 _additional_params: HashMap<String, String>,
3863 _scopes: BTreeSet<String>,
3864}
3865
3866impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskGetCall<'a, C> {}
3867
3868impl<'a, C> ProjectLocationQueueTaskGetCall<'a, C>
3869where
3870 C: common::Connector,
3871{
3872 /// Perform the operation you have build so far.
3873 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3874 use std::borrow::Cow;
3875 use std::io::{Read, Seek};
3876
3877 use common::{url::Params, ToParts};
3878 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3879
3880 let mut dd = common::DefaultDelegate;
3881 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3882 dlg.begin(common::MethodInfo {
3883 id: "cloudtasks.projects.locations.queues.tasks.get",
3884 http_method: hyper::Method::GET,
3885 });
3886
3887 for &field in ["alt", "name", "responseView"].iter() {
3888 if self._additional_params.contains_key(field) {
3889 dlg.finished(false);
3890 return Err(common::Error::FieldClash(field));
3891 }
3892 }
3893
3894 let mut params = Params::with_capacity(4 + self._additional_params.len());
3895 params.push("name", self._name);
3896 if let Some(value) = self._response_view.as_ref() {
3897 params.push("responseView", value);
3898 }
3899
3900 params.extend(self._additional_params.iter());
3901
3902 params.push("alt", "json");
3903 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
3904 if self._scopes.is_empty() {
3905 self._scopes
3906 .insert(Scope::CloudPlatform.as_ref().to_string());
3907 }
3908
3909 #[allow(clippy::single_element_loop)]
3910 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3911 url = params.uri_replacement(url, param_name, find_this, true);
3912 }
3913 {
3914 let to_remove = ["name"];
3915 params.remove_params(&to_remove);
3916 }
3917
3918 let url = params.parse_with_url(&url);
3919
3920 loop {
3921 let token = match self
3922 .hub
3923 .auth
3924 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3925 .await
3926 {
3927 Ok(token) => token,
3928 Err(e) => match dlg.token(e) {
3929 Ok(token) => token,
3930 Err(e) => {
3931 dlg.finished(false);
3932 return Err(common::Error::MissingToken(e));
3933 }
3934 },
3935 };
3936 let mut req_result = {
3937 let client = &self.hub.client;
3938 dlg.pre_request();
3939 let mut req_builder = hyper::Request::builder()
3940 .method(hyper::Method::GET)
3941 .uri(url.as_str())
3942 .header(USER_AGENT, self.hub._user_agent.clone());
3943
3944 if let Some(token) = token.as_ref() {
3945 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3946 }
3947
3948 let request = req_builder
3949 .header(CONTENT_LENGTH, 0_u64)
3950 .body(common::to_body::<String>(None));
3951
3952 client.request(request.unwrap()).await
3953 };
3954
3955 match req_result {
3956 Err(err) => {
3957 if let common::Retry::After(d) = dlg.http_error(&err) {
3958 sleep(d).await;
3959 continue;
3960 }
3961 dlg.finished(false);
3962 return Err(common::Error::HttpError(err));
3963 }
3964 Ok(res) => {
3965 let (mut parts, body) = res.into_parts();
3966 let mut body = common::Body::new(body);
3967 if !parts.status.is_success() {
3968 let bytes = common::to_bytes(body).await.unwrap_or_default();
3969 let error = serde_json::from_str(&common::to_string(&bytes));
3970 let response = common::to_response(parts, bytes.into());
3971
3972 if let common::Retry::After(d) =
3973 dlg.http_failure(&response, error.as_ref().ok())
3974 {
3975 sleep(d).await;
3976 continue;
3977 }
3978
3979 dlg.finished(false);
3980
3981 return Err(match error {
3982 Ok(value) => common::Error::BadRequest(value),
3983 _ => common::Error::Failure(response),
3984 });
3985 }
3986 let response = {
3987 let bytes = common::to_bytes(body).await.unwrap_or_default();
3988 let encoded = common::to_string(&bytes);
3989 match serde_json::from_str(&encoded) {
3990 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3991 Err(error) => {
3992 dlg.response_json_decode_error(&encoded, &error);
3993 return Err(common::Error::JsonDecodeError(
3994 encoded.to_string(),
3995 error,
3996 ));
3997 }
3998 }
3999 };
4000
4001 dlg.finished(true);
4002 return Ok(response);
4003 }
4004 }
4005 }
4006 }
4007
4008 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
4009 ///
4010 /// Sets the *name* path property to the given value.
4011 ///
4012 /// Even though the property as already been set when instantiating this call,
4013 /// we provide this method for API completeness.
4014 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
4015 self._name = new_value.to_string();
4016 self
4017 }
4018 /// 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.
4019 ///
4020 /// Sets the *response view* query property to the given value.
4021 pub fn response_view(mut self, new_value: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
4022 self._response_view = Some(new_value.to_string());
4023 self
4024 }
4025 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4026 /// while executing the actual API request.
4027 ///
4028 /// ````text
4029 /// It should be used to handle progress information, and to implement a certain level of resilience.
4030 /// ````
4031 ///
4032 /// Sets the *delegate* property to the given value.
4033 pub fn delegate(
4034 mut self,
4035 new_value: &'a mut dyn common::Delegate,
4036 ) -> ProjectLocationQueueTaskGetCall<'a, C> {
4037 self._delegate = Some(new_value);
4038 self
4039 }
4040
4041 /// Set any additional parameter of the query string used in the request.
4042 /// It should be used to set parameters which are not yet available through their own
4043 /// setters.
4044 ///
4045 /// Please note that this method must not be used to set any of the known parameters
4046 /// which have their own setter method. If done anyway, the request will fail.
4047 ///
4048 /// # Additional Parameters
4049 ///
4050 /// * *$.xgafv* (query-string) - V1 error format.
4051 /// * *access_token* (query-string) - OAuth access token.
4052 /// * *alt* (query-string) - Data format for response.
4053 /// * *callback* (query-string) - JSONP
4054 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4055 /// * *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.
4056 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4057 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4058 /// * *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.
4059 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4060 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4061 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskGetCall<'a, C>
4062 where
4063 T: AsRef<str>,
4064 {
4065 self._additional_params
4066 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4067 self
4068 }
4069
4070 /// Identifies the authorization scope for the method you are building.
4071 ///
4072 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4073 /// [`Scope::CloudPlatform`].
4074 ///
4075 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4076 /// tokens for more than one scope.
4077 ///
4078 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4079 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4080 /// sufficient, a read-write scope will do as well.
4081 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskGetCall<'a, C>
4082 where
4083 St: AsRef<str>,
4084 {
4085 self._scopes.insert(String::from(scope.as_ref()));
4086 self
4087 }
4088 /// Identifies the authorization scope(s) for the method you are building.
4089 ///
4090 /// See [`Self::add_scope()`] for details.
4091 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskGetCall<'a, C>
4092 where
4093 I: IntoIterator<Item = St>,
4094 St: AsRef<str>,
4095 {
4096 self._scopes
4097 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4098 self
4099 }
4100
4101 /// Removes all scopes, and no default scope will be used either.
4102 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4103 /// for details).
4104 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskGetCall<'a, C> {
4105 self._scopes.clear();
4106 self
4107 }
4108}
4109
4110/// 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.
4111///
4112/// A builder for the *locations.queues.tasks.lease* method supported by a *project* resource.
4113/// It is not used directly, but through a [`ProjectMethods`] instance.
4114///
4115/// # Example
4116///
4117/// Instantiate a resource method builder
4118///
4119/// ```test_harness,no_run
4120/// # extern crate hyper;
4121/// # extern crate hyper_rustls;
4122/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
4123/// use cloudtasks2_beta2::api::LeaseTasksRequest;
4124/// # async fn dox() {
4125/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4126///
4127/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4129/// # secret,
4130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4131/// # ).build().await.unwrap();
4132///
4133/// # let client = hyper_util::client::legacy::Client::builder(
4134/// # hyper_util::rt::TokioExecutor::new()
4135/// # )
4136/// # .build(
4137/// # hyper_rustls::HttpsConnectorBuilder::new()
4138/// # .with_native_roots()
4139/// # .unwrap()
4140/// # .https_or_http()
4141/// # .enable_http1()
4142/// # .build()
4143/// # );
4144/// # let mut hub = CloudTasks::new(client, auth);
4145/// // As the method needs a request, you would usually fill it with the desired information
4146/// // into the respective structure. Some of the parts shown here might not be applicable !
4147/// // Values shown here are possibly random and not representative !
4148/// let mut req = LeaseTasksRequest::default();
4149///
4150/// // You can configure optional parameters by calling the respective setters at will, and
4151/// // execute the final call using `doit()`.
4152/// // Values shown here are possibly random and not representative !
4153/// let result = hub.projects().locations_queues_tasks_lease(req, "parent")
4154/// .doit().await;
4155/// # }
4156/// ```
4157pub struct ProjectLocationQueueTaskLeaseCall<'a, C>
4158where
4159 C: 'a,
4160{
4161 hub: &'a CloudTasks<C>,
4162 _request: LeaseTasksRequest,
4163 _parent: String,
4164 _delegate: Option<&'a mut dyn common::Delegate>,
4165 _additional_params: HashMap<String, String>,
4166 _scopes: BTreeSet<String>,
4167}
4168
4169impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskLeaseCall<'a, C> {}
4170
4171impl<'a, C> ProjectLocationQueueTaskLeaseCall<'a, C>
4172where
4173 C: common::Connector,
4174{
4175 /// Perform the operation you have build so far.
4176 pub async fn doit(mut self) -> common::Result<(common::Response, LeaseTasksResponse)> {
4177 use std::borrow::Cow;
4178 use std::io::{Read, Seek};
4179
4180 use common::{url::Params, ToParts};
4181 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4182
4183 let mut dd = common::DefaultDelegate;
4184 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4185 dlg.begin(common::MethodInfo {
4186 id: "cloudtasks.projects.locations.queues.tasks.lease",
4187 http_method: hyper::Method::POST,
4188 });
4189
4190 for &field in ["alt", "parent"].iter() {
4191 if self._additional_params.contains_key(field) {
4192 dlg.finished(false);
4193 return Err(common::Error::FieldClash(field));
4194 }
4195 }
4196
4197 let mut params = Params::with_capacity(4 + self._additional_params.len());
4198 params.push("parent", self._parent);
4199
4200 params.extend(self._additional_params.iter());
4201
4202 params.push("alt", "json");
4203 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/tasks:lease";
4204 if self._scopes.is_empty() {
4205 self._scopes
4206 .insert(Scope::CloudPlatform.as_ref().to_string());
4207 }
4208
4209 #[allow(clippy::single_element_loop)]
4210 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4211 url = params.uri_replacement(url, param_name, find_this, true);
4212 }
4213 {
4214 let to_remove = ["parent"];
4215 params.remove_params(&to_remove);
4216 }
4217
4218 let url = params.parse_with_url(&url);
4219
4220 let mut json_mime_type = mime::APPLICATION_JSON;
4221 let mut request_value_reader = {
4222 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4223 common::remove_json_null_values(&mut value);
4224 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4225 serde_json::to_writer(&mut dst, &value).unwrap();
4226 dst
4227 };
4228 let request_size = request_value_reader
4229 .seek(std::io::SeekFrom::End(0))
4230 .unwrap();
4231 request_value_reader
4232 .seek(std::io::SeekFrom::Start(0))
4233 .unwrap();
4234
4235 loop {
4236 let token = match self
4237 .hub
4238 .auth
4239 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4240 .await
4241 {
4242 Ok(token) => token,
4243 Err(e) => match dlg.token(e) {
4244 Ok(token) => token,
4245 Err(e) => {
4246 dlg.finished(false);
4247 return Err(common::Error::MissingToken(e));
4248 }
4249 },
4250 };
4251 request_value_reader
4252 .seek(std::io::SeekFrom::Start(0))
4253 .unwrap();
4254 let mut req_result = {
4255 let client = &self.hub.client;
4256 dlg.pre_request();
4257 let mut req_builder = hyper::Request::builder()
4258 .method(hyper::Method::POST)
4259 .uri(url.as_str())
4260 .header(USER_AGENT, self.hub._user_agent.clone());
4261
4262 if let Some(token) = token.as_ref() {
4263 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4264 }
4265
4266 let request = req_builder
4267 .header(CONTENT_TYPE, json_mime_type.to_string())
4268 .header(CONTENT_LENGTH, request_size as u64)
4269 .body(common::to_body(
4270 request_value_reader.get_ref().clone().into(),
4271 ));
4272
4273 client.request(request.unwrap()).await
4274 };
4275
4276 match req_result {
4277 Err(err) => {
4278 if let common::Retry::After(d) = dlg.http_error(&err) {
4279 sleep(d).await;
4280 continue;
4281 }
4282 dlg.finished(false);
4283 return Err(common::Error::HttpError(err));
4284 }
4285 Ok(res) => {
4286 let (mut parts, body) = res.into_parts();
4287 let mut body = common::Body::new(body);
4288 if !parts.status.is_success() {
4289 let bytes = common::to_bytes(body).await.unwrap_or_default();
4290 let error = serde_json::from_str(&common::to_string(&bytes));
4291 let response = common::to_response(parts, bytes.into());
4292
4293 if let common::Retry::After(d) =
4294 dlg.http_failure(&response, error.as_ref().ok())
4295 {
4296 sleep(d).await;
4297 continue;
4298 }
4299
4300 dlg.finished(false);
4301
4302 return Err(match error {
4303 Ok(value) => common::Error::BadRequest(value),
4304 _ => common::Error::Failure(response),
4305 });
4306 }
4307 let response = {
4308 let bytes = common::to_bytes(body).await.unwrap_or_default();
4309 let encoded = common::to_string(&bytes);
4310 match serde_json::from_str(&encoded) {
4311 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4312 Err(error) => {
4313 dlg.response_json_decode_error(&encoded, &error);
4314 return Err(common::Error::JsonDecodeError(
4315 encoded.to_string(),
4316 error,
4317 ));
4318 }
4319 }
4320 };
4321
4322 dlg.finished(true);
4323 return Ok(response);
4324 }
4325 }
4326 }
4327 }
4328
4329 ///
4330 /// Sets the *request* property to the given value.
4331 ///
4332 /// Even though the property as already been set when instantiating this call,
4333 /// we provide this method for API completeness.
4334 pub fn request(
4335 mut self,
4336 new_value: LeaseTasksRequest,
4337 ) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4338 self._request = new_value;
4339 self
4340 }
4341 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
4342 ///
4343 /// Sets the *parent* path property to the given value.
4344 ///
4345 /// Even though the property as already been set when instantiating this call,
4346 /// we provide this method for API completeness.
4347 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4348 self._parent = new_value.to_string();
4349 self
4350 }
4351 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4352 /// while executing the actual API request.
4353 ///
4354 /// ````text
4355 /// It should be used to handle progress information, and to implement a certain level of resilience.
4356 /// ````
4357 ///
4358 /// Sets the *delegate* property to the given value.
4359 pub fn delegate(
4360 mut self,
4361 new_value: &'a mut dyn common::Delegate,
4362 ) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4363 self._delegate = Some(new_value);
4364 self
4365 }
4366
4367 /// Set any additional parameter of the query string used in the request.
4368 /// It should be used to set parameters which are not yet available through their own
4369 /// setters.
4370 ///
4371 /// Please note that this method must not be used to set any of the known parameters
4372 /// which have their own setter method. If done anyway, the request will fail.
4373 ///
4374 /// # Additional Parameters
4375 ///
4376 /// * *$.xgafv* (query-string) - V1 error format.
4377 /// * *access_token* (query-string) - OAuth access token.
4378 /// * *alt* (query-string) - Data format for response.
4379 /// * *callback* (query-string) - JSONP
4380 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4381 /// * *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.
4382 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4383 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4384 /// * *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.
4385 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4386 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4387 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskLeaseCall<'a, C>
4388 where
4389 T: AsRef<str>,
4390 {
4391 self._additional_params
4392 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4393 self
4394 }
4395
4396 /// Identifies the authorization scope for the method you are building.
4397 ///
4398 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4399 /// [`Scope::CloudPlatform`].
4400 ///
4401 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4402 /// tokens for more than one scope.
4403 ///
4404 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4405 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4406 /// sufficient, a read-write scope will do as well.
4407 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskLeaseCall<'a, C>
4408 where
4409 St: AsRef<str>,
4410 {
4411 self._scopes.insert(String::from(scope.as_ref()));
4412 self
4413 }
4414 /// Identifies the authorization scope(s) for the method you are building.
4415 ///
4416 /// See [`Self::add_scope()`] for details.
4417 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskLeaseCall<'a, C>
4418 where
4419 I: IntoIterator<Item = St>,
4420 St: AsRef<str>,
4421 {
4422 self._scopes
4423 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4424 self
4425 }
4426
4427 /// Removes all scopes, and no default scope will be used either.
4428 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4429 /// for details).
4430 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskLeaseCall<'a, C> {
4431 self._scopes.clear();
4432 self
4433 }
4434}
4435
4436/// 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.
4437///
4438/// A builder for the *locations.queues.tasks.list* method supported by a *project* resource.
4439/// It is not used directly, but through a [`ProjectMethods`] instance.
4440///
4441/// # Example
4442///
4443/// Instantiate a resource method builder
4444///
4445/// ```test_harness,no_run
4446/// # extern crate hyper;
4447/// # extern crate hyper_rustls;
4448/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
4449/// # async fn dox() {
4450/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4451///
4452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4453/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4454/// # secret,
4455/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4456/// # ).build().await.unwrap();
4457///
4458/// # let client = hyper_util::client::legacy::Client::builder(
4459/// # hyper_util::rt::TokioExecutor::new()
4460/// # )
4461/// # .build(
4462/// # hyper_rustls::HttpsConnectorBuilder::new()
4463/// # .with_native_roots()
4464/// # .unwrap()
4465/// # .https_or_http()
4466/// # .enable_http1()
4467/// # .build()
4468/// # );
4469/// # let mut hub = CloudTasks::new(client, auth);
4470/// // You can configure optional parameters by calling the respective setters at will, and
4471/// // execute the final call using `doit()`.
4472/// // Values shown here are possibly random and not representative !
4473/// let result = hub.projects().locations_queues_tasks_list("parent")
4474/// .response_view("Lorem")
4475/// .page_token("gubergren")
4476/// .page_size(-75)
4477/// .doit().await;
4478/// # }
4479/// ```
4480pub struct ProjectLocationQueueTaskListCall<'a, C>
4481where
4482 C: 'a,
4483{
4484 hub: &'a CloudTasks<C>,
4485 _parent: String,
4486 _response_view: Option<String>,
4487 _page_token: Option<String>,
4488 _page_size: Option<i32>,
4489 _delegate: Option<&'a mut dyn common::Delegate>,
4490 _additional_params: HashMap<String, String>,
4491 _scopes: BTreeSet<String>,
4492}
4493
4494impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskListCall<'a, C> {}
4495
4496impl<'a, C> ProjectLocationQueueTaskListCall<'a, C>
4497where
4498 C: common::Connector,
4499{
4500 /// Perform the operation you have build so far.
4501 pub async fn doit(mut self) -> common::Result<(common::Response, ListTasksResponse)> {
4502 use std::borrow::Cow;
4503 use std::io::{Read, Seek};
4504
4505 use common::{url::Params, ToParts};
4506 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4507
4508 let mut dd = common::DefaultDelegate;
4509 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4510 dlg.begin(common::MethodInfo {
4511 id: "cloudtasks.projects.locations.queues.tasks.list",
4512 http_method: hyper::Method::GET,
4513 });
4514
4515 for &field in ["alt", "parent", "responseView", "pageToken", "pageSize"].iter() {
4516 if self._additional_params.contains_key(field) {
4517 dlg.finished(false);
4518 return Err(common::Error::FieldClash(field));
4519 }
4520 }
4521
4522 let mut params = Params::with_capacity(6 + self._additional_params.len());
4523 params.push("parent", self._parent);
4524 if let Some(value) = self._response_view.as_ref() {
4525 params.push("responseView", value);
4526 }
4527 if let Some(value) = self._page_token.as_ref() {
4528 params.push("pageToken", value);
4529 }
4530 if let Some(value) = self._page_size.as_ref() {
4531 params.push("pageSize", value.to_string());
4532 }
4533
4534 params.extend(self._additional_params.iter());
4535
4536 params.push("alt", "json");
4537 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/tasks";
4538 if self._scopes.is_empty() {
4539 self._scopes
4540 .insert(Scope::CloudPlatform.as_ref().to_string());
4541 }
4542
4543 #[allow(clippy::single_element_loop)]
4544 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4545 url = params.uri_replacement(url, param_name, find_this, true);
4546 }
4547 {
4548 let to_remove = ["parent"];
4549 params.remove_params(&to_remove);
4550 }
4551
4552 let url = params.parse_with_url(&url);
4553
4554 loop {
4555 let token = match self
4556 .hub
4557 .auth
4558 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4559 .await
4560 {
4561 Ok(token) => token,
4562 Err(e) => match dlg.token(e) {
4563 Ok(token) => token,
4564 Err(e) => {
4565 dlg.finished(false);
4566 return Err(common::Error::MissingToken(e));
4567 }
4568 },
4569 };
4570 let mut req_result = {
4571 let client = &self.hub.client;
4572 dlg.pre_request();
4573 let mut req_builder = hyper::Request::builder()
4574 .method(hyper::Method::GET)
4575 .uri(url.as_str())
4576 .header(USER_AGENT, self.hub._user_agent.clone());
4577
4578 if let Some(token) = token.as_ref() {
4579 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4580 }
4581
4582 let request = req_builder
4583 .header(CONTENT_LENGTH, 0_u64)
4584 .body(common::to_body::<String>(None));
4585
4586 client.request(request.unwrap()).await
4587 };
4588
4589 match req_result {
4590 Err(err) => {
4591 if let common::Retry::After(d) = dlg.http_error(&err) {
4592 sleep(d).await;
4593 continue;
4594 }
4595 dlg.finished(false);
4596 return Err(common::Error::HttpError(err));
4597 }
4598 Ok(res) => {
4599 let (mut parts, body) = res.into_parts();
4600 let mut body = common::Body::new(body);
4601 if !parts.status.is_success() {
4602 let bytes = common::to_bytes(body).await.unwrap_or_default();
4603 let error = serde_json::from_str(&common::to_string(&bytes));
4604 let response = common::to_response(parts, bytes.into());
4605
4606 if let common::Retry::After(d) =
4607 dlg.http_failure(&response, error.as_ref().ok())
4608 {
4609 sleep(d).await;
4610 continue;
4611 }
4612
4613 dlg.finished(false);
4614
4615 return Err(match error {
4616 Ok(value) => common::Error::BadRequest(value),
4617 _ => common::Error::Failure(response),
4618 });
4619 }
4620 let response = {
4621 let bytes = common::to_bytes(body).await.unwrap_or_default();
4622 let encoded = common::to_string(&bytes);
4623 match serde_json::from_str(&encoded) {
4624 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4625 Err(error) => {
4626 dlg.response_json_decode_error(&encoded, &error);
4627 return Err(common::Error::JsonDecodeError(
4628 encoded.to_string(),
4629 error,
4630 ));
4631 }
4632 }
4633 };
4634
4635 dlg.finished(true);
4636 return Ok(response);
4637 }
4638 }
4639 }
4640 }
4641
4642 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
4643 ///
4644 /// Sets the *parent* path property to the given value.
4645 ///
4646 /// Even though the property as already been set when instantiating this call,
4647 /// we provide this method for API completeness.
4648 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
4649 self._parent = new_value.to_string();
4650 self
4651 }
4652 /// 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.
4653 ///
4654 /// Sets the *response view* query property to the given value.
4655 pub fn response_view(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
4656 self._response_view = Some(new_value.to_string());
4657 self
4658 }
4659 /// 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.
4660 ///
4661 /// Sets the *page token* query property to the given value.
4662 pub fn page_token(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
4663 self._page_token = Some(new_value.to_string());
4664 self
4665 }
4666 /// 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.
4667 ///
4668 /// Sets the *page size* query property to the given value.
4669 pub fn page_size(mut self, new_value: i32) -> ProjectLocationQueueTaskListCall<'a, C> {
4670 self._page_size = Some(new_value);
4671 self
4672 }
4673 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4674 /// while executing the actual API request.
4675 ///
4676 /// ````text
4677 /// It should be used to handle progress information, and to implement a certain level of resilience.
4678 /// ````
4679 ///
4680 /// Sets the *delegate* property to the given value.
4681 pub fn delegate(
4682 mut self,
4683 new_value: &'a mut dyn common::Delegate,
4684 ) -> ProjectLocationQueueTaskListCall<'a, C> {
4685 self._delegate = Some(new_value);
4686 self
4687 }
4688
4689 /// Set any additional parameter of the query string used in the request.
4690 /// It should be used to set parameters which are not yet available through their own
4691 /// setters.
4692 ///
4693 /// Please note that this method must not be used to set any of the known parameters
4694 /// which have their own setter method. If done anyway, the request will fail.
4695 ///
4696 /// # Additional Parameters
4697 ///
4698 /// * *$.xgafv* (query-string) - V1 error format.
4699 /// * *access_token* (query-string) - OAuth access token.
4700 /// * *alt* (query-string) - Data format for response.
4701 /// * *callback* (query-string) - JSONP
4702 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4703 /// * *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.
4704 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4705 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4706 /// * *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.
4707 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4708 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4709 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskListCall<'a, C>
4710 where
4711 T: AsRef<str>,
4712 {
4713 self._additional_params
4714 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4715 self
4716 }
4717
4718 /// Identifies the authorization scope for the method you are building.
4719 ///
4720 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4721 /// [`Scope::CloudPlatform`].
4722 ///
4723 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4724 /// tokens for more than one scope.
4725 ///
4726 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4727 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4728 /// sufficient, a read-write scope will do as well.
4729 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskListCall<'a, C>
4730 where
4731 St: AsRef<str>,
4732 {
4733 self._scopes.insert(String::from(scope.as_ref()));
4734 self
4735 }
4736 /// Identifies the authorization scope(s) for the method you are building.
4737 ///
4738 /// See [`Self::add_scope()`] for details.
4739 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskListCall<'a, C>
4740 where
4741 I: IntoIterator<Item = St>,
4742 St: AsRef<str>,
4743 {
4744 self._scopes
4745 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4746 self
4747 }
4748
4749 /// Removes all scopes, and no default scope will be used either.
4750 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4751 /// for details).
4752 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskListCall<'a, C> {
4753 self._scopes.clear();
4754 self
4755 }
4756}
4757
4758/// 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.
4759///
4760/// A builder for the *locations.queues.tasks.renewLease* method supported by a *project* resource.
4761/// It is not used directly, but through a [`ProjectMethods`] instance.
4762///
4763/// # Example
4764///
4765/// Instantiate a resource method builder
4766///
4767/// ```test_harness,no_run
4768/// # extern crate hyper;
4769/// # extern crate hyper_rustls;
4770/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
4771/// use cloudtasks2_beta2::api::RenewLeaseRequest;
4772/// # async fn dox() {
4773/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4774///
4775/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4776/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4777/// # secret,
4778/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4779/// # ).build().await.unwrap();
4780///
4781/// # let client = hyper_util::client::legacy::Client::builder(
4782/// # hyper_util::rt::TokioExecutor::new()
4783/// # )
4784/// # .build(
4785/// # hyper_rustls::HttpsConnectorBuilder::new()
4786/// # .with_native_roots()
4787/// # .unwrap()
4788/// # .https_or_http()
4789/// # .enable_http1()
4790/// # .build()
4791/// # );
4792/// # let mut hub = CloudTasks::new(client, auth);
4793/// // As the method needs a request, you would usually fill it with the desired information
4794/// // into the respective structure. Some of the parts shown here might not be applicable !
4795/// // Values shown here are possibly random and not representative !
4796/// let mut req = RenewLeaseRequest::default();
4797///
4798/// // You can configure optional parameters by calling the respective setters at will, and
4799/// // execute the final call using `doit()`.
4800/// // Values shown here are possibly random and not representative !
4801/// let result = hub.projects().locations_queues_tasks_renew_lease(req, "name")
4802/// .doit().await;
4803/// # }
4804/// ```
4805pub struct ProjectLocationQueueTaskRenewLeaseCall<'a, C>
4806where
4807 C: 'a,
4808{
4809 hub: &'a CloudTasks<C>,
4810 _request: RenewLeaseRequest,
4811 _name: String,
4812 _delegate: Option<&'a mut dyn common::Delegate>,
4813 _additional_params: HashMap<String, String>,
4814 _scopes: BTreeSet<String>,
4815}
4816
4817impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskRenewLeaseCall<'a, C> {}
4818
4819impl<'a, C> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
4820where
4821 C: common::Connector,
4822{
4823 /// Perform the operation you have build so far.
4824 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
4825 use std::borrow::Cow;
4826 use std::io::{Read, Seek};
4827
4828 use common::{url::Params, ToParts};
4829 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4830
4831 let mut dd = common::DefaultDelegate;
4832 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4833 dlg.begin(common::MethodInfo {
4834 id: "cloudtasks.projects.locations.queues.tasks.renewLease",
4835 http_method: hyper::Method::POST,
4836 });
4837
4838 for &field in ["alt", "name"].iter() {
4839 if self._additional_params.contains_key(field) {
4840 dlg.finished(false);
4841 return Err(common::Error::FieldClash(field));
4842 }
4843 }
4844
4845 let mut params = Params::with_capacity(4 + self._additional_params.len());
4846 params.push("name", self._name);
4847
4848 params.extend(self._additional_params.iter());
4849
4850 params.push("alt", "json");
4851 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:renewLease";
4852 if self._scopes.is_empty() {
4853 self._scopes
4854 .insert(Scope::CloudPlatform.as_ref().to_string());
4855 }
4856
4857 #[allow(clippy::single_element_loop)]
4858 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4859 url = params.uri_replacement(url, param_name, find_this, true);
4860 }
4861 {
4862 let to_remove = ["name"];
4863 params.remove_params(&to_remove);
4864 }
4865
4866 let url = params.parse_with_url(&url);
4867
4868 let mut json_mime_type = mime::APPLICATION_JSON;
4869 let mut request_value_reader = {
4870 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4871 common::remove_json_null_values(&mut value);
4872 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4873 serde_json::to_writer(&mut dst, &value).unwrap();
4874 dst
4875 };
4876 let request_size = request_value_reader
4877 .seek(std::io::SeekFrom::End(0))
4878 .unwrap();
4879 request_value_reader
4880 .seek(std::io::SeekFrom::Start(0))
4881 .unwrap();
4882
4883 loop {
4884 let token = match self
4885 .hub
4886 .auth
4887 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4888 .await
4889 {
4890 Ok(token) => token,
4891 Err(e) => match dlg.token(e) {
4892 Ok(token) => token,
4893 Err(e) => {
4894 dlg.finished(false);
4895 return Err(common::Error::MissingToken(e));
4896 }
4897 },
4898 };
4899 request_value_reader
4900 .seek(std::io::SeekFrom::Start(0))
4901 .unwrap();
4902 let mut req_result = {
4903 let client = &self.hub.client;
4904 dlg.pre_request();
4905 let mut req_builder = hyper::Request::builder()
4906 .method(hyper::Method::POST)
4907 .uri(url.as_str())
4908 .header(USER_AGENT, self.hub._user_agent.clone());
4909
4910 if let Some(token) = token.as_ref() {
4911 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4912 }
4913
4914 let request = req_builder
4915 .header(CONTENT_TYPE, json_mime_type.to_string())
4916 .header(CONTENT_LENGTH, request_size as u64)
4917 .body(common::to_body(
4918 request_value_reader.get_ref().clone().into(),
4919 ));
4920
4921 client.request(request.unwrap()).await
4922 };
4923
4924 match req_result {
4925 Err(err) => {
4926 if let common::Retry::After(d) = dlg.http_error(&err) {
4927 sleep(d).await;
4928 continue;
4929 }
4930 dlg.finished(false);
4931 return Err(common::Error::HttpError(err));
4932 }
4933 Ok(res) => {
4934 let (mut parts, body) = res.into_parts();
4935 let mut body = common::Body::new(body);
4936 if !parts.status.is_success() {
4937 let bytes = common::to_bytes(body).await.unwrap_or_default();
4938 let error = serde_json::from_str(&common::to_string(&bytes));
4939 let response = common::to_response(parts, bytes.into());
4940
4941 if let common::Retry::After(d) =
4942 dlg.http_failure(&response, error.as_ref().ok())
4943 {
4944 sleep(d).await;
4945 continue;
4946 }
4947
4948 dlg.finished(false);
4949
4950 return Err(match error {
4951 Ok(value) => common::Error::BadRequest(value),
4952 _ => common::Error::Failure(response),
4953 });
4954 }
4955 let response = {
4956 let bytes = common::to_bytes(body).await.unwrap_or_default();
4957 let encoded = common::to_string(&bytes);
4958 match serde_json::from_str(&encoded) {
4959 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4960 Err(error) => {
4961 dlg.response_json_decode_error(&encoded, &error);
4962 return Err(common::Error::JsonDecodeError(
4963 encoded.to_string(),
4964 error,
4965 ));
4966 }
4967 }
4968 };
4969
4970 dlg.finished(true);
4971 return Ok(response);
4972 }
4973 }
4974 }
4975 }
4976
4977 ///
4978 /// Sets the *request* property to the given value.
4979 ///
4980 /// Even though the property as already been set when instantiating this call,
4981 /// we provide this method for API completeness.
4982 pub fn request(
4983 mut self,
4984 new_value: RenewLeaseRequest,
4985 ) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
4986 self._request = new_value;
4987 self
4988 }
4989 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
4990 ///
4991 /// Sets the *name* path property to the given value.
4992 ///
4993 /// Even though the property as already been set when instantiating this call,
4994 /// we provide this method for API completeness.
4995 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
4996 self._name = new_value.to_string();
4997 self
4998 }
4999 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5000 /// while executing the actual API request.
5001 ///
5002 /// ````text
5003 /// It should be used to handle progress information, and to implement a certain level of resilience.
5004 /// ````
5005 ///
5006 /// Sets the *delegate* property to the given value.
5007 pub fn delegate(
5008 mut self,
5009 new_value: &'a mut dyn common::Delegate,
5010 ) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
5011 self._delegate = Some(new_value);
5012 self
5013 }
5014
5015 /// Set any additional parameter of the query string used in the request.
5016 /// It should be used to set parameters which are not yet available through their own
5017 /// setters.
5018 ///
5019 /// Please note that this method must not be used to set any of the known parameters
5020 /// which have their own setter method. If done anyway, the request will fail.
5021 ///
5022 /// # Additional Parameters
5023 ///
5024 /// * *$.xgafv* (query-string) - V1 error format.
5025 /// * *access_token* (query-string) - OAuth access token.
5026 /// * *alt* (query-string) - Data format for response.
5027 /// * *callback* (query-string) - JSONP
5028 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5029 /// * *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.
5030 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5031 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5032 /// * *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.
5033 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5034 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5035 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
5036 where
5037 T: AsRef<str>,
5038 {
5039 self._additional_params
5040 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5041 self
5042 }
5043
5044 /// Identifies the authorization scope for the method you are building.
5045 ///
5046 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5047 /// [`Scope::CloudPlatform`].
5048 ///
5049 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5050 /// tokens for more than one scope.
5051 ///
5052 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5053 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5054 /// sufficient, a read-write scope will do as well.
5055 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
5056 where
5057 St: AsRef<str>,
5058 {
5059 self._scopes.insert(String::from(scope.as_ref()));
5060 self
5061 }
5062 /// Identifies the authorization scope(s) for the method you are building.
5063 ///
5064 /// See [`Self::add_scope()`] for details.
5065 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C>
5066 where
5067 I: IntoIterator<Item = St>,
5068 St: AsRef<str>,
5069 {
5070 self._scopes
5071 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5072 self
5073 }
5074
5075 /// Removes all scopes, and no default scope will be used either.
5076 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5077 /// for details).
5078 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskRenewLeaseCall<'a, C> {
5079 self._scopes.clear();
5080 self
5081 }
5082}
5083
5084/// 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.
5085///
5086/// A builder for the *locations.queues.tasks.run* method supported by a *project* resource.
5087/// It is not used directly, but through a [`ProjectMethods`] instance.
5088///
5089/// # Example
5090///
5091/// Instantiate a resource method builder
5092///
5093/// ```test_harness,no_run
5094/// # extern crate hyper;
5095/// # extern crate hyper_rustls;
5096/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
5097/// use cloudtasks2_beta2::api::RunTaskRequest;
5098/// # async fn dox() {
5099/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5100///
5101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5102/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5103/// # secret,
5104/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5105/// # ).build().await.unwrap();
5106///
5107/// # let client = hyper_util::client::legacy::Client::builder(
5108/// # hyper_util::rt::TokioExecutor::new()
5109/// # )
5110/// # .build(
5111/// # hyper_rustls::HttpsConnectorBuilder::new()
5112/// # .with_native_roots()
5113/// # .unwrap()
5114/// # .https_or_http()
5115/// # .enable_http1()
5116/// # .build()
5117/// # );
5118/// # let mut hub = CloudTasks::new(client, auth);
5119/// // As the method needs a request, you would usually fill it with the desired information
5120/// // into the respective structure. Some of the parts shown here might not be applicable !
5121/// // Values shown here are possibly random and not representative !
5122/// let mut req = RunTaskRequest::default();
5123///
5124/// // You can configure optional parameters by calling the respective setters at will, and
5125/// // execute the final call using `doit()`.
5126/// // Values shown here are possibly random and not representative !
5127/// let result = hub.projects().locations_queues_tasks_run(req, "name")
5128/// .doit().await;
5129/// # }
5130/// ```
5131pub struct ProjectLocationQueueTaskRunCall<'a, C>
5132where
5133 C: 'a,
5134{
5135 hub: &'a CloudTasks<C>,
5136 _request: RunTaskRequest,
5137 _name: String,
5138 _delegate: Option<&'a mut dyn common::Delegate>,
5139 _additional_params: HashMap<String, String>,
5140 _scopes: BTreeSet<String>,
5141}
5142
5143impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskRunCall<'a, C> {}
5144
5145impl<'a, C> ProjectLocationQueueTaskRunCall<'a, C>
5146where
5147 C: common::Connector,
5148{
5149 /// Perform the operation you have build so far.
5150 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
5151 use std::borrow::Cow;
5152 use std::io::{Read, Seek};
5153
5154 use common::{url::Params, ToParts};
5155 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5156
5157 let mut dd = common::DefaultDelegate;
5158 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5159 dlg.begin(common::MethodInfo {
5160 id: "cloudtasks.projects.locations.queues.tasks.run",
5161 http_method: hyper::Method::POST,
5162 });
5163
5164 for &field in ["alt", "name"].iter() {
5165 if self._additional_params.contains_key(field) {
5166 dlg.finished(false);
5167 return Err(common::Error::FieldClash(field));
5168 }
5169 }
5170
5171 let mut params = Params::with_capacity(4 + self._additional_params.len());
5172 params.push("name", self._name);
5173
5174 params.extend(self._additional_params.iter());
5175
5176 params.push("alt", "json");
5177 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:run";
5178 if self._scopes.is_empty() {
5179 self._scopes
5180 .insert(Scope::CloudPlatform.as_ref().to_string());
5181 }
5182
5183 #[allow(clippy::single_element_loop)]
5184 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5185 url = params.uri_replacement(url, param_name, find_this, true);
5186 }
5187 {
5188 let to_remove = ["name"];
5189 params.remove_params(&to_remove);
5190 }
5191
5192 let url = params.parse_with_url(&url);
5193
5194 let mut json_mime_type = mime::APPLICATION_JSON;
5195 let mut request_value_reader = {
5196 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5197 common::remove_json_null_values(&mut value);
5198 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5199 serde_json::to_writer(&mut dst, &value).unwrap();
5200 dst
5201 };
5202 let request_size = request_value_reader
5203 .seek(std::io::SeekFrom::End(0))
5204 .unwrap();
5205 request_value_reader
5206 .seek(std::io::SeekFrom::Start(0))
5207 .unwrap();
5208
5209 loop {
5210 let token = match self
5211 .hub
5212 .auth
5213 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5214 .await
5215 {
5216 Ok(token) => token,
5217 Err(e) => match dlg.token(e) {
5218 Ok(token) => token,
5219 Err(e) => {
5220 dlg.finished(false);
5221 return Err(common::Error::MissingToken(e));
5222 }
5223 },
5224 };
5225 request_value_reader
5226 .seek(std::io::SeekFrom::Start(0))
5227 .unwrap();
5228 let mut req_result = {
5229 let client = &self.hub.client;
5230 dlg.pre_request();
5231 let mut req_builder = hyper::Request::builder()
5232 .method(hyper::Method::POST)
5233 .uri(url.as_str())
5234 .header(USER_AGENT, self.hub._user_agent.clone());
5235
5236 if let Some(token) = token.as_ref() {
5237 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5238 }
5239
5240 let request = req_builder
5241 .header(CONTENT_TYPE, json_mime_type.to_string())
5242 .header(CONTENT_LENGTH, request_size as u64)
5243 .body(common::to_body(
5244 request_value_reader.get_ref().clone().into(),
5245 ));
5246
5247 client.request(request.unwrap()).await
5248 };
5249
5250 match req_result {
5251 Err(err) => {
5252 if let common::Retry::After(d) = dlg.http_error(&err) {
5253 sleep(d).await;
5254 continue;
5255 }
5256 dlg.finished(false);
5257 return Err(common::Error::HttpError(err));
5258 }
5259 Ok(res) => {
5260 let (mut parts, body) = res.into_parts();
5261 let mut body = common::Body::new(body);
5262 if !parts.status.is_success() {
5263 let bytes = common::to_bytes(body).await.unwrap_or_default();
5264 let error = serde_json::from_str(&common::to_string(&bytes));
5265 let response = common::to_response(parts, bytes.into());
5266
5267 if let common::Retry::After(d) =
5268 dlg.http_failure(&response, error.as_ref().ok())
5269 {
5270 sleep(d).await;
5271 continue;
5272 }
5273
5274 dlg.finished(false);
5275
5276 return Err(match error {
5277 Ok(value) => common::Error::BadRequest(value),
5278 _ => common::Error::Failure(response),
5279 });
5280 }
5281 let response = {
5282 let bytes = common::to_bytes(body).await.unwrap_or_default();
5283 let encoded = common::to_string(&bytes);
5284 match serde_json::from_str(&encoded) {
5285 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5286 Err(error) => {
5287 dlg.response_json_decode_error(&encoded, &error);
5288 return Err(common::Error::JsonDecodeError(
5289 encoded.to_string(),
5290 error,
5291 ));
5292 }
5293 }
5294 };
5295
5296 dlg.finished(true);
5297 return Ok(response);
5298 }
5299 }
5300 }
5301 }
5302
5303 ///
5304 /// Sets the *request* property to the given value.
5305 ///
5306 /// Even though the property as already been set when instantiating this call,
5307 /// we provide this method for API completeness.
5308 pub fn request(mut self, new_value: RunTaskRequest) -> ProjectLocationQueueTaskRunCall<'a, C> {
5309 self._request = new_value;
5310 self
5311 }
5312 /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
5313 ///
5314 /// Sets the *name* path property to the given value.
5315 ///
5316 /// Even though the property as already been set when instantiating this call,
5317 /// we provide this method for API completeness.
5318 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskRunCall<'a, C> {
5319 self._name = new_value.to_string();
5320 self
5321 }
5322 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5323 /// while executing the actual API request.
5324 ///
5325 /// ````text
5326 /// It should be used to handle progress information, and to implement a certain level of resilience.
5327 /// ````
5328 ///
5329 /// Sets the *delegate* property to the given value.
5330 pub fn delegate(
5331 mut self,
5332 new_value: &'a mut dyn common::Delegate,
5333 ) -> ProjectLocationQueueTaskRunCall<'a, C> {
5334 self._delegate = Some(new_value);
5335 self
5336 }
5337
5338 /// Set any additional parameter of the query string used in the request.
5339 /// It should be used to set parameters which are not yet available through their own
5340 /// setters.
5341 ///
5342 /// Please note that this method must not be used to set any of the known parameters
5343 /// which have their own setter method. If done anyway, the request will fail.
5344 ///
5345 /// # Additional Parameters
5346 ///
5347 /// * *$.xgafv* (query-string) - V1 error format.
5348 /// * *access_token* (query-string) - OAuth access token.
5349 /// * *alt* (query-string) - Data format for response.
5350 /// * *callback* (query-string) - JSONP
5351 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5352 /// * *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.
5353 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5354 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5355 /// * *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.
5356 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5357 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5358 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskRunCall<'a, C>
5359 where
5360 T: AsRef<str>,
5361 {
5362 self._additional_params
5363 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5364 self
5365 }
5366
5367 /// Identifies the authorization scope for the method you are building.
5368 ///
5369 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5370 /// [`Scope::CloudPlatform`].
5371 ///
5372 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5373 /// tokens for more than one scope.
5374 ///
5375 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5376 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5377 /// sufficient, a read-write scope will do as well.
5378 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskRunCall<'a, C>
5379 where
5380 St: AsRef<str>,
5381 {
5382 self._scopes.insert(String::from(scope.as_ref()));
5383 self
5384 }
5385 /// Identifies the authorization scope(s) for the method you are building.
5386 ///
5387 /// See [`Self::add_scope()`] for details.
5388 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskRunCall<'a, C>
5389 where
5390 I: IntoIterator<Item = St>,
5391 St: AsRef<str>,
5392 {
5393 self._scopes
5394 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5395 self
5396 }
5397
5398 /// Removes all scopes, and no default scope will be used either.
5399 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5400 /// for details).
5401 pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskRunCall<'a, C> {
5402 self._scopes.clear();
5403 self
5404 }
5405}
5406
5407/// 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.
5408///
5409/// A builder for the *locations.queues.create* method supported by a *project* resource.
5410/// It is not used directly, but through a [`ProjectMethods`] instance.
5411///
5412/// # Example
5413///
5414/// Instantiate a resource method builder
5415///
5416/// ```test_harness,no_run
5417/// # extern crate hyper;
5418/// # extern crate hyper_rustls;
5419/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
5420/// use cloudtasks2_beta2::api::Queue;
5421/// # async fn dox() {
5422/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5423///
5424/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5425/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5426/// # secret,
5427/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5428/// # ).build().await.unwrap();
5429///
5430/// # let client = hyper_util::client::legacy::Client::builder(
5431/// # hyper_util::rt::TokioExecutor::new()
5432/// # )
5433/// # .build(
5434/// # hyper_rustls::HttpsConnectorBuilder::new()
5435/// # .with_native_roots()
5436/// # .unwrap()
5437/// # .https_or_http()
5438/// # .enable_http1()
5439/// # .build()
5440/// # );
5441/// # let mut hub = CloudTasks::new(client, auth);
5442/// // As the method needs a request, you would usually fill it with the desired information
5443/// // into the respective structure. Some of the parts shown here might not be applicable !
5444/// // Values shown here are possibly random and not representative !
5445/// let mut req = Queue::default();
5446///
5447/// // You can configure optional parameters by calling the respective setters at will, and
5448/// // execute the final call using `doit()`.
5449/// // Values shown here are possibly random and not representative !
5450/// let result = hub.projects().locations_queues_create(req, "parent")
5451/// .doit().await;
5452/// # }
5453/// ```
5454pub struct ProjectLocationQueueCreateCall<'a, C>
5455where
5456 C: 'a,
5457{
5458 hub: &'a CloudTasks<C>,
5459 _request: Queue,
5460 _parent: String,
5461 _delegate: Option<&'a mut dyn common::Delegate>,
5462 _additional_params: HashMap<String, String>,
5463 _scopes: BTreeSet<String>,
5464}
5465
5466impl<'a, C> common::CallBuilder for ProjectLocationQueueCreateCall<'a, C> {}
5467
5468impl<'a, C> ProjectLocationQueueCreateCall<'a, C>
5469where
5470 C: common::Connector,
5471{
5472 /// Perform the operation you have build so far.
5473 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
5474 use std::borrow::Cow;
5475 use std::io::{Read, Seek};
5476
5477 use common::{url::Params, ToParts};
5478 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5479
5480 let mut dd = common::DefaultDelegate;
5481 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5482 dlg.begin(common::MethodInfo {
5483 id: "cloudtasks.projects.locations.queues.create",
5484 http_method: hyper::Method::POST,
5485 });
5486
5487 for &field in ["alt", "parent"].iter() {
5488 if self._additional_params.contains_key(field) {
5489 dlg.finished(false);
5490 return Err(common::Error::FieldClash(field));
5491 }
5492 }
5493
5494 let mut params = Params::with_capacity(4 + self._additional_params.len());
5495 params.push("parent", self._parent);
5496
5497 params.extend(self._additional_params.iter());
5498
5499 params.push("alt", "json");
5500 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/queues";
5501 if self._scopes.is_empty() {
5502 self._scopes
5503 .insert(Scope::CloudPlatform.as_ref().to_string());
5504 }
5505
5506 #[allow(clippy::single_element_loop)]
5507 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5508 url = params.uri_replacement(url, param_name, find_this, true);
5509 }
5510 {
5511 let to_remove = ["parent"];
5512 params.remove_params(&to_remove);
5513 }
5514
5515 let url = params.parse_with_url(&url);
5516
5517 let mut json_mime_type = mime::APPLICATION_JSON;
5518 let mut request_value_reader = {
5519 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5520 common::remove_json_null_values(&mut value);
5521 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5522 serde_json::to_writer(&mut dst, &value).unwrap();
5523 dst
5524 };
5525 let request_size = request_value_reader
5526 .seek(std::io::SeekFrom::End(0))
5527 .unwrap();
5528 request_value_reader
5529 .seek(std::io::SeekFrom::Start(0))
5530 .unwrap();
5531
5532 loop {
5533 let token = match self
5534 .hub
5535 .auth
5536 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5537 .await
5538 {
5539 Ok(token) => token,
5540 Err(e) => match dlg.token(e) {
5541 Ok(token) => token,
5542 Err(e) => {
5543 dlg.finished(false);
5544 return Err(common::Error::MissingToken(e));
5545 }
5546 },
5547 };
5548 request_value_reader
5549 .seek(std::io::SeekFrom::Start(0))
5550 .unwrap();
5551 let mut req_result = {
5552 let client = &self.hub.client;
5553 dlg.pre_request();
5554 let mut req_builder = hyper::Request::builder()
5555 .method(hyper::Method::POST)
5556 .uri(url.as_str())
5557 .header(USER_AGENT, self.hub._user_agent.clone());
5558
5559 if let Some(token) = token.as_ref() {
5560 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5561 }
5562
5563 let request = req_builder
5564 .header(CONTENT_TYPE, json_mime_type.to_string())
5565 .header(CONTENT_LENGTH, request_size as u64)
5566 .body(common::to_body(
5567 request_value_reader.get_ref().clone().into(),
5568 ));
5569
5570 client.request(request.unwrap()).await
5571 };
5572
5573 match req_result {
5574 Err(err) => {
5575 if let common::Retry::After(d) = dlg.http_error(&err) {
5576 sleep(d).await;
5577 continue;
5578 }
5579 dlg.finished(false);
5580 return Err(common::Error::HttpError(err));
5581 }
5582 Ok(res) => {
5583 let (mut parts, body) = res.into_parts();
5584 let mut body = common::Body::new(body);
5585 if !parts.status.is_success() {
5586 let bytes = common::to_bytes(body).await.unwrap_or_default();
5587 let error = serde_json::from_str(&common::to_string(&bytes));
5588 let response = common::to_response(parts, bytes.into());
5589
5590 if let common::Retry::After(d) =
5591 dlg.http_failure(&response, error.as_ref().ok())
5592 {
5593 sleep(d).await;
5594 continue;
5595 }
5596
5597 dlg.finished(false);
5598
5599 return Err(match error {
5600 Ok(value) => common::Error::BadRequest(value),
5601 _ => common::Error::Failure(response),
5602 });
5603 }
5604 let response = {
5605 let bytes = common::to_bytes(body).await.unwrap_or_default();
5606 let encoded = common::to_string(&bytes);
5607 match serde_json::from_str(&encoded) {
5608 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5609 Err(error) => {
5610 dlg.response_json_decode_error(&encoded, &error);
5611 return Err(common::Error::JsonDecodeError(
5612 encoded.to_string(),
5613 error,
5614 ));
5615 }
5616 }
5617 };
5618
5619 dlg.finished(true);
5620 return Ok(response);
5621 }
5622 }
5623 }
5624 }
5625
5626 ///
5627 /// Sets the *request* property to the given value.
5628 ///
5629 /// Even though the property as already been set when instantiating this call,
5630 /// we provide this method for API completeness.
5631 pub fn request(mut self, new_value: Queue) -> ProjectLocationQueueCreateCall<'a, C> {
5632 self._request = new_value;
5633 self
5634 }
5635 /// 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.
5636 ///
5637 /// Sets the *parent* path property to the given value.
5638 ///
5639 /// Even though the property as already been set when instantiating this call,
5640 /// we provide this method for API completeness.
5641 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueCreateCall<'a, C> {
5642 self._parent = new_value.to_string();
5643 self
5644 }
5645 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5646 /// while executing the actual API request.
5647 ///
5648 /// ````text
5649 /// It should be used to handle progress information, and to implement a certain level of resilience.
5650 /// ````
5651 ///
5652 /// Sets the *delegate* property to the given value.
5653 pub fn delegate(
5654 mut self,
5655 new_value: &'a mut dyn common::Delegate,
5656 ) -> ProjectLocationQueueCreateCall<'a, C> {
5657 self._delegate = Some(new_value);
5658 self
5659 }
5660
5661 /// Set any additional parameter of the query string used in the request.
5662 /// It should be used to set parameters which are not yet available through their own
5663 /// setters.
5664 ///
5665 /// Please note that this method must not be used to set any of the known parameters
5666 /// which have their own setter method. If done anyway, the request will fail.
5667 ///
5668 /// # Additional Parameters
5669 ///
5670 /// * *$.xgafv* (query-string) - V1 error format.
5671 /// * *access_token* (query-string) - OAuth access token.
5672 /// * *alt* (query-string) - Data format for response.
5673 /// * *callback* (query-string) - JSONP
5674 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5675 /// * *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.
5676 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5677 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5678 /// * *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.
5679 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5680 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5681 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueCreateCall<'a, C>
5682 where
5683 T: AsRef<str>,
5684 {
5685 self._additional_params
5686 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5687 self
5688 }
5689
5690 /// Identifies the authorization scope for the method you are building.
5691 ///
5692 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5693 /// [`Scope::CloudPlatform`].
5694 ///
5695 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5696 /// tokens for more than one scope.
5697 ///
5698 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5699 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5700 /// sufficient, a read-write scope will do as well.
5701 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueCreateCall<'a, C>
5702 where
5703 St: AsRef<str>,
5704 {
5705 self._scopes.insert(String::from(scope.as_ref()));
5706 self
5707 }
5708 /// Identifies the authorization scope(s) for the method you are building.
5709 ///
5710 /// See [`Self::add_scope()`] for details.
5711 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueCreateCall<'a, C>
5712 where
5713 I: IntoIterator<Item = St>,
5714 St: AsRef<str>,
5715 {
5716 self._scopes
5717 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5718 self
5719 }
5720
5721 /// Removes all scopes, and no default scope will be used either.
5722 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5723 /// for details).
5724 pub fn clear_scopes(mut self) -> ProjectLocationQueueCreateCall<'a, C> {
5725 self._scopes.clear();
5726 self
5727 }
5728}
5729
5730/// 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.
5731///
5732/// A builder for the *locations.queues.delete* method supported by a *project* resource.
5733/// It is not used directly, but through a [`ProjectMethods`] instance.
5734///
5735/// # Example
5736///
5737/// Instantiate a resource method builder
5738///
5739/// ```test_harness,no_run
5740/// # extern crate hyper;
5741/// # extern crate hyper_rustls;
5742/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
5743/// # async fn dox() {
5744/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5745///
5746/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5747/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5748/// # secret,
5749/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5750/// # ).build().await.unwrap();
5751///
5752/// # let client = hyper_util::client::legacy::Client::builder(
5753/// # hyper_util::rt::TokioExecutor::new()
5754/// # )
5755/// # .build(
5756/// # hyper_rustls::HttpsConnectorBuilder::new()
5757/// # .with_native_roots()
5758/// # .unwrap()
5759/// # .https_or_http()
5760/// # .enable_http1()
5761/// # .build()
5762/// # );
5763/// # let mut hub = CloudTasks::new(client, auth);
5764/// // You can configure optional parameters by calling the respective setters at will, and
5765/// // execute the final call using `doit()`.
5766/// // Values shown here are possibly random and not representative !
5767/// let result = hub.projects().locations_queues_delete("name")
5768/// .doit().await;
5769/// # }
5770/// ```
5771pub struct ProjectLocationQueueDeleteCall<'a, C>
5772where
5773 C: 'a,
5774{
5775 hub: &'a CloudTasks<C>,
5776 _name: String,
5777 _delegate: Option<&'a mut dyn common::Delegate>,
5778 _additional_params: HashMap<String, String>,
5779 _scopes: BTreeSet<String>,
5780}
5781
5782impl<'a, C> common::CallBuilder for ProjectLocationQueueDeleteCall<'a, C> {}
5783
5784impl<'a, C> ProjectLocationQueueDeleteCall<'a, C>
5785where
5786 C: common::Connector,
5787{
5788 /// Perform the operation you have build so far.
5789 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5790 use std::borrow::Cow;
5791 use std::io::{Read, Seek};
5792
5793 use common::{url::Params, ToParts};
5794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5795
5796 let mut dd = common::DefaultDelegate;
5797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5798 dlg.begin(common::MethodInfo {
5799 id: "cloudtasks.projects.locations.queues.delete",
5800 http_method: hyper::Method::DELETE,
5801 });
5802
5803 for &field in ["alt", "name"].iter() {
5804 if self._additional_params.contains_key(field) {
5805 dlg.finished(false);
5806 return Err(common::Error::FieldClash(field));
5807 }
5808 }
5809
5810 let mut params = Params::with_capacity(3 + self._additional_params.len());
5811 params.push("name", self._name);
5812
5813 params.extend(self._additional_params.iter());
5814
5815 params.push("alt", "json");
5816 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
5817 if self._scopes.is_empty() {
5818 self._scopes
5819 .insert(Scope::CloudPlatform.as_ref().to_string());
5820 }
5821
5822 #[allow(clippy::single_element_loop)]
5823 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5824 url = params.uri_replacement(url, param_name, find_this, true);
5825 }
5826 {
5827 let to_remove = ["name"];
5828 params.remove_params(&to_remove);
5829 }
5830
5831 let url = params.parse_with_url(&url);
5832
5833 loop {
5834 let token = match self
5835 .hub
5836 .auth
5837 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5838 .await
5839 {
5840 Ok(token) => token,
5841 Err(e) => match dlg.token(e) {
5842 Ok(token) => token,
5843 Err(e) => {
5844 dlg.finished(false);
5845 return Err(common::Error::MissingToken(e));
5846 }
5847 },
5848 };
5849 let mut req_result = {
5850 let client = &self.hub.client;
5851 dlg.pre_request();
5852 let mut req_builder = hyper::Request::builder()
5853 .method(hyper::Method::DELETE)
5854 .uri(url.as_str())
5855 .header(USER_AGENT, self.hub._user_agent.clone());
5856
5857 if let Some(token) = token.as_ref() {
5858 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5859 }
5860
5861 let request = req_builder
5862 .header(CONTENT_LENGTH, 0_u64)
5863 .body(common::to_body::<String>(None));
5864
5865 client.request(request.unwrap()).await
5866 };
5867
5868 match req_result {
5869 Err(err) => {
5870 if let common::Retry::After(d) = dlg.http_error(&err) {
5871 sleep(d).await;
5872 continue;
5873 }
5874 dlg.finished(false);
5875 return Err(common::Error::HttpError(err));
5876 }
5877 Ok(res) => {
5878 let (mut parts, body) = res.into_parts();
5879 let mut body = common::Body::new(body);
5880 if !parts.status.is_success() {
5881 let bytes = common::to_bytes(body).await.unwrap_or_default();
5882 let error = serde_json::from_str(&common::to_string(&bytes));
5883 let response = common::to_response(parts, bytes.into());
5884
5885 if let common::Retry::After(d) =
5886 dlg.http_failure(&response, error.as_ref().ok())
5887 {
5888 sleep(d).await;
5889 continue;
5890 }
5891
5892 dlg.finished(false);
5893
5894 return Err(match error {
5895 Ok(value) => common::Error::BadRequest(value),
5896 _ => common::Error::Failure(response),
5897 });
5898 }
5899 let response = {
5900 let bytes = common::to_bytes(body).await.unwrap_or_default();
5901 let encoded = common::to_string(&bytes);
5902 match serde_json::from_str(&encoded) {
5903 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5904 Err(error) => {
5905 dlg.response_json_decode_error(&encoded, &error);
5906 return Err(common::Error::JsonDecodeError(
5907 encoded.to_string(),
5908 error,
5909 ));
5910 }
5911 }
5912 };
5913
5914 dlg.finished(true);
5915 return Ok(response);
5916 }
5917 }
5918 }
5919 }
5920
5921 /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
5922 ///
5923 /// Sets the *name* path property to the given value.
5924 ///
5925 /// Even though the property as already been set when instantiating this call,
5926 /// we provide this method for API completeness.
5927 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueDeleteCall<'a, C> {
5928 self._name = new_value.to_string();
5929 self
5930 }
5931 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5932 /// while executing the actual API request.
5933 ///
5934 /// ````text
5935 /// It should be used to handle progress information, and to implement a certain level of resilience.
5936 /// ````
5937 ///
5938 /// Sets the *delegate* property to the given value.
5939 pub fn delegate(
5940 mut self,
5941 new_value: &'a mut dyn common::Delegate,
5942 ) -> ProjectLocationQueueDeleteCall<'a, C> {
5943 self._delegate = Some(new_value);
5944 self
5945 }
5946
5947 /// Set any additional parameter of the query string used in the request.
5948 /// It should be used to set parameters which are not yet available through their own
5949 /// setters.
5950 ///
5951 /// Please note that this method must not be used to set any of the known parameters
5952 /// which have their own setter method. If done anyway, the request will fail.
5953 ///
5954 /// # Additional Parameters
5955 ///
5956 /// * *$.xgafv* (query-string) - V1 error format.
5957 /// * *access_token* (query-string) - OAuth access token.
5958 /// * *alt* (query-string) - Data format for response.
5959 /// * *callback* (query-string) - JSONP
5960 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5961 /// * *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.
5962 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5963 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5964 /// * *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.
5965 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5966 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5967 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueDeleteCall<'a, C>
5968 where
5969 T: AsRef<str>,
5970 {
5971 self._additional_params
5972 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5973 self
5974 }
5975
5976 /// Identifies the authorization scope for the method you are building.
5977 ///
5978 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5979 /// [`Scope::CloudPlatform`].
5980 ///
5981 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5982 /// tokens for more than one scope.
5983 ///
5984 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5985 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5986 /// sufficient, a read-write scope will do as well.
5987 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueDeleteCall<'a, C>
5988 where
5989 St: AsRef<str>,
5990 {
5991 self._scopes.insert(String::from(scope.as_ref()));
5992 self
5993 }
5994 /// Identifies the authorization scope(s) for the method you are building.
5995 ///
5996 /// See [`Self::add_scope()`] for details.
5997 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueDeleteCall<'a, C>
5998 where
5999 I: IntoIterator<Item = St>,
6000 St: AsRef<str>,
6001 {
6002 self._scopes
6003 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6004 self
6005 }
6006
6007 /// Removes all scopes, and no default scope will be used either.
6008 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6009 /// for details).
6010 pub fn clear_scopes(mut self) -> ProjectLocationQueueDeleteCall<'a, C> {
6011 self._scopes.clear();
6012 self
6013 }
6014}
6015
6016/// Gets a queue.
6017///
6018/// A builder for the *locations.queues.get* method supported by a *project* resource.
6019/// It is not used directly, but through a [`ProjectMethods`] instance.
6020///
6021/// # Example
6022///
6023/// Instantiate a resource method builder
6024///
6025/// ```test_harness,no_run
6026/// # extern crate hyper;
6027/// # extern crate hyper_rustls;
6028/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6029/// # async fn dox() {
6030/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6031///
6032/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6033/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6034/// # secret,
6035/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6036/// # ).build().await.unwrap();
6037///
6038/// # let client = hyper_util::client::legacy::Client::builder(
6039/// # hyper_util::rt::TokioExecutor::new()
6040/// # )
6041/// # .build(
6042/// # hyper_rustls::HttpsConnectorBuilder::new()
6043/// # .with_native_roots()
6044/// # .unwrap()
6045/// # .https_or_http()
6046/// # .enable_http1()
6047/// # .build()
6048/// # );
6049/// # let mut hub = CloudTasks::new(client, auth);
6050/// // You can configure optional parameters by calling the respective setters at will, and
6051/// // execute the final call using `doit()`.
6052/// // Values shown here are possibly random and not representative !
6053/// let result = hub.projects().locations_queues_get("name")
6054/// .read_mask(FieldMask::new::<&str>(&[]))
6055/// .doit().await;
6056/// # }
6057/// ```
6058pub struct ProjectLocationQueueGetCall<'a, C>
6059where
6060 C: 'a,
6061{
6062 hub: &'a CloudTasks<C>,
6063 _name: String,
6064 _read_mask: Option<common::FieldMask>,
6065 _delegate: Option<&'a mut dyn common::Delegate>,
6066 _additional_params: HashMap<String, String>,
6067 _scopes: BTreeSet<String>,
6068}
6069
6070impl<'a, C> common::CallBuilder for ProjectLocationQueueGetCall<'a, C> {}
6071
6072impl<'a, C> ProjectLocationQueueGetCall<'a, C>
6073where
6074 C: common::Connector,
6075{
6076 /// Perform the operation you have build so far.
6077 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
6078 use std::borrow::Cow;
6079 use std::io::{Read, Seek};
6080
6081 use common::{url::Params, ToParts};
6082 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6083
6084 let mut dd = common::DefaultDelegate;
6085 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6086 dlg.begin(common::MethodInfo {
6087 id: "cloudtasks.projects.locations.queues.get",
6088 http_method: hyper::Method::GET,
6089 });
6090
6091 for &field in ["alt", "name", "readMask"].iter() {
6092 if self._additional_params.contains_key(field) {
6093 dlg.finished(false);
6094 return Err(common::Error::FieldClash(field));
6095 }
6096 }
6097
6098 let mut params = Params::with_capacity(4 + self._additional_params.len());
6099 params.push("name", self._name);
6100 if let Some(value) = self._read_mask.as_ref() {
6101 params.push("readMask", value.to_string());
6102 }
6103
6104 params.extend(self._additional_params.iter());
6105
6106 params.push("alt", "json");
6107 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
6108 if self._scopes.is_empty() {
6109 self._scopes
6110 .insert(Scope::CloudPlatform.as_ref().to_string());
6111 }
6112
6113 #[allow(clippy::single_element_loop)]
6114 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6115 url = params.uri_replacement(url, param_name, find_this, true);
6116 }
6117 {
6118 let to_remove = ["name"];
6119 params.remove_params(&to_remove);
6120 }
6121
6122 let url = params.parse_with_url(&url);
6123
6124 loop {
6125 let token = match self
6126 .hub
6127 .auth
6128 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6129 .await
6130 {
6131 Ok(token) => token,
6132 Err(e) => match dlg.token(e) {
6133 Ok(token) => token,
6134 Err(e) => {
6135 dlg.finished(false);
6136 return Err(common::Error::MissingToken(e));
6137 }
6138 },
6139 };
6140 let mut req_result = {
6141 let client = &self.hub.client;
6142 dlg.pre_request();
6143 let mut req_builder = hyper::Request::builder()
6144 .method(hyper::Method::GET)
6145 .uri(url.as_str())
6146 .header(USER_AGENT, self.hub._user_agent.clone());
6147
6148 if let Some(token) = token.as_ref() {
6149 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6150 }
6151
6152 let request = req_builder
6153 .header(CONTENT_LENGTH, 0_u64)
6154 .body(common::to_body::<String>(None));
6155
6156 client.request(request.unwrap()).await
6157 };
6158
6159 match req_result {
6160 Err(err) => {
6161 if let common::Retry::After(d) = dlg.http_error(&err) {
6162 sleep(d).await;
6163 continue;
6164 }
6165 dlg.finished(false);
6166 return Err(common::Error::HttpError(err));
6167 }
6168 Ok(res) => {
6169 let (mut parts, body) = res.into_parts();
6170 let mut body = common::Body::new(body);
6171 if !parts.status.is_success() {
6172 let bytes = common::to_bytes(body).await.unwrap_or_default();
6173 let error = serde_json::from_str(&common::to_string(&bytes));
6174 let response = common::to_response(parts, bytes.into());
6175
6176 if let common::Retry::After(d) =
6177 dlg.http_failure(&response, error.as_ref().ok())
6178 {
6179 sleep(d).await;
6180 continue;
6181 }
6182
6183 dlg.finished(false);
6184
6185 return Err(match error {
6186 Ok(value) => common::Error::BadRequest(value),
6187 _ => common::Error::Failure(response),
6188 });
6189 }
6190 let response = {
6191 let bytes = common::to_bytes(body).await.unwrap_or_default();
6192 let encoded = common::to_string(&bytes);
6193 match serde_json::from_str(&encoded) {
6194 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6195 Err(error) => {
6196 dlg.response_json_decode_error(&encoded, &error);
6197 return Err(common::Error::JsonDecodeError(
6198 encoded.to_string(),
6199 error,
6200 ));
6201 }
6202 }
6203 };
6204
6205 dlg.finished(true);
6206 return Ok(response);
6207 }
6208 }
6209 }
6210 }
6211
6212 /// Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
6213 ///
6214 /// Sets the *name* path property to the given value.
6215 ///
6216 /// Even though the property as already been set when instantiating this call,
6217 /// we provide this method for API completeness.
6218 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueGetCall<'a, C> {
6219 self._name = new_value.to_string();
6220 self
6221 }
6222 /// 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.
6223 ///
6224 /// Sets the *read mask* query property to the given value.
6225 pub fn read_mask(mut self, new_value: common::FieldMask) -> ProjectLocationQueueGetCall<'a, C> {
6226 self._read_mask = Some(new_value);
6227 self
6228 }
6229 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6230 /// while executing the actual API request.
6231 ///
6232 /// ````text
6233 /// It should be used to handle progress information, and to implement a certain level of resilience.
6234 /// ````
6235 ///
6236 /// Sets the *delegate* property to the given value.
6237 pub fn delegate(
6238 mut self,
6239 new_value: &'a mut dyn common::Delegate,
6240 ) -> ProjectLocationQueueGetCall<'a, C> {
6241 self._delegate = Some(new_value);
6242 self
6243 }
6244
6245 /// Set any additional parameter of the query string used in the request.
6246 /// It should be used to set parameters which are not yet available through their own
6247 /// setters.
6248 ///
6249 /// Please note that this method must not be used to set any of the known parameters
6250 /// which have their own setter method. If done anyway, the request will fail.
6251 ///
6252 /// # Additional Parameters
6253 ///
6254 /// * *$.xgafv* (query-string) - V1 error format.
6255 /// * *access_token* (query-string) - OAuth access token.
6256 /// * *alt* (query-string) - Data format for response.
6257 /// * *callback* (query-string) - JSONP
6258 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6259 /// * *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.
6260 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6261 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6262 /// * *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.
6263 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6264 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6265 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueGetCall<'a, C>
6266 where
6267 T: AsRef<str>,
6268 {
6269 self._additional_params
6270 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6271 self
6272 }
6273
6274 /// Identifies the authorization scope for the method you are building.
6275 ///
6276 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6277 /// [`Scope::CloudPlatform`].
6278 ///
6279 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6280 /// tokens for more than one scope.
6281 ///
6282 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6283 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6284 /// sufficient, a read-write scope will do as well.
6285 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueGetCall<'a, C>
6286 where
6287 St: AsRef<str>,
6288 {
6289 self._scopes.insert(String::from(scope.as_ref()));
6290 self
6291 }
6292 /// Identifies the authorization scope(s) for the method you are building.
6293 ///
6294 /// See [`Self::add_scope()`] for details.
6295 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueGetCall<'a, C>
6296 where
6297 I: IntoIterator<Item = St>,
6298 St: AsRef<str>,
6299 {
6300 self._scopes
6301 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6302 self
6303 }
6304
6305 /// Removes all scopes, and no default scope will be used either.
6306 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6307 /// for details).
6308 pub fn clear_scopes(mut self) -> ProjectLocationQueueGetCall<'a, C> {
6309 self._scopes.clear();
6310 self
6311 }
6312}
6313
6314/// 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`
6315///
6316/// A builder for the *locations.queues.getIamPolicy* method supported by a *project* resource.
6317/// It is not used directly, but through a [`ProjectMethods`] instance.
6318///
6319/// # Example
6320///
6321/// Instantiate a resource method builder
6322///
6323/// ```test_harness,no_run
6324/// # extern crate hyper;
6325/// # extern crate hyper_rustls;
6326/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6327/// use cloudtasks2_beta2::api::GetIamPolicyRequest;
6328/// # async fn dox() {
6329/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6330///
6331/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6332/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6333/// # secret,
6334/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6335/// # ).build().await.unwrap();
6336///
6337/// # let client = hyper_util::client::legacy::Client::builder(
6338/// # hyper_util::rt::TokioExecutor::new()
6339/// # )
6340/// # .build(
6341/// # hyper_rustls::HttpsConnectorBuilder::new()
6342/// # .with_native_roots()
6343/// # .unwrap()
6344/// # .https_or_http()
6345/// # .enable_http1()
6346/// # .build()
6347/// # );
6348/// # let mut hub = CloudTasks::new(client, auth);
6349/// // As the method needs a request, you would usually fill it with the desired information
6350/// // into the respective structure. Some of the parts shown here might not be applicable !
6351/// // Values shown here are possibly random and not representative !
6352/// let mut req = GetIamPolicyRequest::default();
6353///
6354/// // You can configure optional parameters by calling the respective setters at will, and
6355/// // execute the final call using `doit()`.
6356/// // Values shown here are possibly random and not representative !
6357/// let result = hub.projects().locations_queues_get_iam_policy(req, "resource")
6358/// .doit().await;
6359/// # }
6360/// ```
6361pub struct ProjectLocationQueueGetIamPolicyCall<'a, C>
6362where
6363 C: 'a,
6364{
6365 hub: &'a CloudTasks<C>,
6366 _request: GetIamPolicyRequest,
6367 _resource: String,
6368 _delegate: Option<&'a mut dyn common::Delegate>,
6369 _additional_params: HashMap<String, String>,
6370 _scopes: BTreeSet<String>,
6371}
6372
6373impl<'a, C> common::CallBuilder for ProjectLocationQueueGetIamPolicyCall<'a, C> {}
6374
6375impl<'a, C> ProjectLocationQueueGetIamPolicyCall<'a, C>
6376where
6377 C: common::Connector,
6378{
6379 /// Perform the operation you have build so far.
6380 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6381 use std::borrow::Cow;
6382 use std::io::{Read, Seek};
6383
6384 use common::{url::Params, ToParts};
6385 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6386
6387 let mut dd = common::DefaultDelegate;
6388 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6389 dlg.begin(common::MethodInfo {
6390 id: "cloudtasks.projects.locations.queues.getIamPolicy",
6391 http_method: hyper::Method::POST,
6392 });
6393
6394 for &field in ["alt", "resource"].iter() {
6395 if self._additional_params.contains_key(field) {
6396 dlg.finished(false);
6397 return Err(common::Error::FieldClash(field));
6398 }
6399 }
6400
6401 let mut params = Params::with_capacity(4 + self._additional_params.len());
6402 params.push("resource", self._resource);
6403
6404 params.extend(self._additional_params.iter());
6405
6406 params.push("alt", "json");
6407 let mut url = self.hub._base_url.clone() + "v2beta2/{+resource}:getIamPolicy";
6408 if self._scopes.is_empty() {
6409 self._scopes
6410 .insert(Scope::CloudPlatform.as_ref().to_string());
6411 }
6412
6413 #[allow(clippy::single_element_loop)]
6414 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6415 url = params.uri_replacement(url, param_name, find_this, true);
6416 }
6417 {
6418 let to_remove = ["resource"];
6419 params.remove_params(&to_remove);
6420 }
6421
6422 let url = params.parse_with_url(&url);
6423
6424 let mut json_mime_type = mime::APPLICATION_JSON;
6425 let mut request_value_reader = {
6426 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6427 common::remove_json_null_values(&mut value);
6428 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6429 serde_json::to_writer(&mut dst, &value).unwrap();
6430 dst
6431 };
6432 let request_size = request_value_reader
6433 .seek(std::io::SeekFrom::End(0))
6434 .unwrap();
6435 request_value_reader
6436 .seek(std::io::SeekFrom::Start(0))
6437 .unwrap();
6438
6439 loop {
6440 let token = match self
6441 .hub
6442 .auth
6443 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6444 .await
6445 {
6446 Ok(token) => token,
6447 Err(e) => match dlg.token(e) {
6448 Ok(token) => token,
6449 Err(e) => {
6450 dlg.finished(false);
6451 return Err(common::Error::MissingToken(e));
6452 }
6453 },
6454 };
6455 request_value_reader
6456 .seek(std::io::SeekFrom::Start(0))
6457 .unwrap();
6458 let mut req_result = {
6459 let client = &self.hub.client;
6460 dlg.pre_request();
6461 let mut req_builder = hyper::Request::builder()
6462 .method(hyper::Method::POST)
6463 .uri(url.as_str())
6464 .header(USER_AGENT, self.hub._user_agent.clone());
6465
6466 if let Some(token) = token.as_ref() {
6467 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6468 }
6469
6470 let request = req_builder
6471 .header(CONTENT_TYPE, json_mime_type.to_string())
6472 .header(CONTENT_LENGTH, request_size as u64)
6473 .body(common::to_body(
6474 request_value_reader.get_ref().clone().into(),
6475 ));
6476
6477 client.request(request.unwrap()).await
6478 };
6479
6480 match req_result {
6481 Err(err) => {
6482 if let common::Retry::After(d) = dlg.http_error(&err) {
6483 sleep(d).await;
6484 continue;
6485 }
6486 dlg.finished(false);
6487 return Err(common::Error::HttpError(err));
6488 }
6489 Ok(res) => {
6490 let (mut parts, body) = res.into_parts();
6491 let mut body = common::Body::new(body);
6492 if !parts.status.is_success() {
6493 let bytes = common::to_bytes(body).await.unwrap_or_default();
6494 let error = serde_json::from_str(&common::to_string(&bytes));
6495 let response = common::to_response(parts, bytes.into());
6496
6497 if let common::Retry::After(d) =
6498 dlg.http_failure(&response, error.as_ref().ok())
6499 {
6500 sleep(d).await;
6501 continue;
6502 }
6503
6504 dlg.finished(false);
6505
6506 return Err(match error {
6507 Ok(value) => common::Error::BadRequest(value),
6508 _ => common::Error::Failure(response),
6509 });
6510 }
6511 let response = {
6512 let bytes = common::to_bytes(body).await.unwrap_or_default();
6513 let encoded = common::to_string(&bytes);
6514 match serde_json::from_str(&encoded) {
6515 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6516 Err(error) => {
6517 dlg.response_json_decode_error(&encoded, &error);
6518 return Err(common::Error::JsonDecodeError(
6519 encoded.to_string(),
6520 error,
6521 ));
6522 }
6523 }
6524 };
6525
6526 dlg.finished(true);
6527 return Ok(response);
6528 }
6529 }
6530 }
6531 }
6532
6533 ///
6534 /// Sets the *request* property to the given value.
6535 ///
6536 /// Even though the property as already been set when instantiating this call,
6537 /// we provide this method for API completeness.
6538 pub fn request(
6539 mut self,
6540 new_value: GetIamPolicyRequest,
6541 ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6542 self._request = new_value;
6543 self
6544 }
6545 /// 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.
6546 ///
6547 /// Sets the *resource* path property to the given value.
6548 ///
6549 /// Even though the property as already been set when instantiating this call,
6550 /// we provide this method for API completeness.
6551 pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6552 self._resource = new_value.to_string();
6553 self
6554 }
6555 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6556 /// while executing the actual API request.
6557 ///
6558 /// ````text
6559 /// It should be used to handle progress information, and to implement a certain level of resilience.
6560 /// ````
6561 ///
6562 /// Sets the *delegate* property to the given value.
6563 pub fn delegate(
6564 mut self,
6565 new_value: &'a mut dyn common::Delegate,
6566 ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6567 self._delegate = Some(new_value);
6568 self
6569 }
6570
6571 /// Set any additional parameter of the query string used in the request.
6572 /// It should be used to set parameters which are not yet available through their own
6573 /// setters.
6574 ///
6575 /// Please note that this method must not be used to set any of the known parameters
6576 /// which have their own setter method. If done anyway, the request will fail.
6577 ///
6578 /// # Additional Parameters
6579 ///
6580 /// * *$.xgafv* (query-string) - V1 error format.
6581 /// * *access_token* (query-string) - OAuth access token.
6582 /// * *alt* (query-string) - Data format for response.
6583 /// * *callback* (query-string) - JSONP
6584 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6585 /// * *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.
6586 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6587 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6588 /// * *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.
6589 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6590 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6591 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
6592 where
6593 T: AsRef<str>,
6594 {
6595 self._additional_params
6596 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6597 self
6598 }
6599
6600 /// Identifies the authorization scope for the method you are building.
6601 ///
6602 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6603 /// [`Scope::CloudPlatform`].
6604 ///
6605 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6606 /// tokens for more than one scope.
6607 ///
6608 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6609 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6610 /// sufficient, a read-write scope will do as well.
6611 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
6612 where
6613 St: AsRef<str>,
6614 {
6615 self._scopes.insert(String::from(scope.as_ref()));
6616 self
6617 }
6618 /// Identifies the authorization scope(s) for the method you are building.
6619 ///
6620 /// See [`Self::add_scope()`] for details.
6621 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
6622 where
6623 I: IntoIterator<Item = St>,
6624 St: AsRef<str>,
6625 {
6626 self._scopes
6627 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6628 self
6629 }
6630
6631 /// Removes all scopes, and no default scope will be used either.
6632 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6633 /// for details).
6634 pub fn clear_scopes(mut self) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
6635 self._scopes.clear();
6636 self
6637 }
6638}
6639
6640/// Lists queues. Queues are returned in lexicographical order.
6641///
6642/// A builder for the *locations.queues.list* method supported by a *project* resource.
6643/// It is not used directly, but through a [`ProjectMethods`] instance.
6644///
6645/// # Example
6646///
6647/// Instantiate a resource method builder
6648///
6649/// ```test_harness,no_run
6650/// # extern crate hyper;
6651/// # extern crate hyper_rustls;
6652/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6653/// # async fn dox() {
6654/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6655///
6656/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6657/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6658/// # secret,
6659/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6660/// # ).build().await.unwrap();
6661///
6662/// # let client = hyper_util::client::legacy::Client::builder(
6663/// # hyper_util::rt::TokioExecutor::new()
6664/// # )
6665/// # .build(
6666/// # hyper_rustls::HttpsConnectorBuilder::new()
6667/// # .with_native_roots()
6668/// # .unwrap()
6669/// # .https_or_http()
6670/// # .enable_http1()
6671/// # .build()
6672/// # );
6673/// # let mut hub = CloudTasks::new(client, auth);
6674/// // You can configure optional parameters by calling the respective setters at will, and
6675/// // execute the final call using `doit()`.
6676/// // Values shown here are possibly random and not representative !
6677/// let result = hub.projects().locations_queues_list("parent")
6678/// .read_mask(FieldMask::new::<&str>(&[]))
6679/// .page_token("sed")
6680/// .page_size(-37)
6681/// .filter("gubergren")
6682/// .doit().await;
6683/// # }
6684/// ```
6685pub struct ProjectLocationQueueListCall<'a, C>
6686where
6687 C: 'a,
6688{
6689 hub: &'a CloudTasks<C>,
6690 _parent: String,
6691 _read_mask: Option<common::FieldMask>,
6692 _page_token: Option<String>,
6693 _page_size: Option<i32>,
6694 _filter: Option<String>,
6695 _delegate: Option<&'a mut dyn common::Delegate>,
6696 _additional_params: HashMap<String, String>,
6697 _scopes: BTreeSet<String>,
6698}
6699
6700impl<'a, C> common::CallBuilder for ProjectLocationQueueListCall<'a, C> {}
6701
6702impl<'a, C> ProjectLocationQueueListCall<'a, C>
6703where
6704 C: common::Connector,
6705{
6706 /// Perform the operation you have build so far.
6707 pub async fn doit(mut self) -> common::Result<(common::Response, ListQueuesResponse)> {
6708 use std::borrow::Cow;
6709 use std::io::{Read, Seek};
6710
6711 use common::{url::Params, ToParts};
6712 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6713
6714 let mut dd = common::DefaultDelegate;
6715 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6716 dlg.begin(common::MethodInfo {
6717 id: "cloudtasks.projects.locations.queues.list",
6718 http_method: hyper::Method::GET,
6719 });
6720
6721 for &field in [
6722 "alt",
6723 "parent",
6724 "readMask",
6725 "pageToken",
6726 "pageSize",
6727 "filter",
6728 ]
6729 .iter()
6730 {
6731 if self._additional_params.contains_key(field) {
6732 dlg.finished(false);
6733 return Err(common::Error::FieldClash(field));
6734 }
6735 }
6736
6737 let mut params = Params::with_capacity(7 + self._additional_params.len());
6738 params.push("parent", self._parent);
6739 if let Some(value) = self._read_mask.as_ref() {
6740 params.push("readMask", value.to_string());
6741 }
6742 if let Some(value) = self._page_token.as_ref() {
6743 params.push("pageToken", value);
6744 }
6745 if let Some(value) = self._page_size.as_ref() {
6746 params.push("pageSize", value.to_string());
6747 }
6748 if let Some(value) = self._filter.as_ref() {
6749 params.push("filter", value);
6750 }
6751
6752 params.extend(self._additional_params.iter());
6753
6754 params.push("alt", "json");
6755 let mut url = self.hub._base_url.clone() + "v2beta2/{+parent}/queues";
6756 if self._scopes.is_empty() {
6757 self._scopes
6758 .insert(Scope::CloudPlatform.as_ref().to_string());
6759 }
6760
6761 #[allow(clippy::single_element_loop)]
6762 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6763 url = params.uri_replacement(url, param_name, find_this, true);
6764 }
6765 {
6766 let to_remove = ["parent"];
6767 params.remove_params(&to_remove);
6768 }
6769
6770 let url = params.parse_with_url(&url);
6771
6772 loop {
6773 let token = match self
6774 .hub
6775 .auth
6776 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6777 .await
6778 {
6779 Ok(token) => token,
6780 Err(e) => match dlg.token(e) {
6781 Ok(token) => token,
6782 Err(e) => {
6783 dlg.finished(false);
6784 return Err(common::Error::MissingToken(e));
6785 }
6786 },
6787 };
6788 let mut req_result = {
6789 let client = &self.hub.client;
6790 dlg.pre_request();
6791 let mut req_builder = hyper::Request::builder()
6792 .method(hyper::Method::GET)
6793 .uri(url.as_str())
6794 .header(USER_AGENT, self.hub._user_agent.clone());
6795
6796 if let Some(token) = token.as_ref() {
6797 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6798 }
6799
6800 let request = req_builder
6801 .header(CONTENT_LENGTH, 0_u64)
6802 .body(common::to_body::<String>(None));
6803
6804 client.request(request.unwrap()).await
6805 };
6806
6807 match req_result {
6808 Err(err) => {
6809 if let common::Retry::After(d) = dlg.http_error(&err) {
6810 sleep(d).await;
6811 continue;
6812 }
6813 dlg.finished(false);
6814 return Err(common::Error::HttpError(err));
6815 }
6816 Ok(res) => {
6817 let (mut parts, body) = res.into_parts();
6818 let mut body = common::Body::new(body);
6819 if !parts.status.is_success() {
6820 let bytes = common::to_bytes(body).await.unwrap_or_default();
6821 let error = serde_json::from_str(&common::to_string(&bytes));
6822 let response = common::to_response(parts, bytes.into());
6823
6824 if let common::Retry::After(d) =
6825 dlg.http_failure(&response, error.as_ref().ok())
6826 {
6827 sleep(d).await;
6828 continue;
6829 }
6830
6831 dlg.finished(false);
6832
6833 return Err(match error {
6834 Ok(value) => common::Error::BadRequest(value),
6835 _ => common::Error::Failure(response),
6836 });
6837 }
6838 let response = {
6839 let bytes = common::to_bytes(body).await.unwrap_or_default();
6840 let encoded = common::to_string(&bytes);
6841 match serde_json::from_str(&encoded) {
6842 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6843 Err(error) => {
6844 dlg.response_json_decode_error(&encoded, &error);
6845 return Err(common::Error::JsonDecodeError(
6846 encoded.to_string(),
6847 error,
6848 ));
6849 }
6850 }
6851 };
6852
6853 dlg.finished(true);
6854 return Ok(response);
6855 }
6856 }
6857 }
6858 }
6859
6860 /// Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`
6861 ///
6862 /// Sets the *parent* path property to the given value.
6863 ///
6864 /// Even though the property as already been set when instantiating this call,
6865 /// we provide this method for API completeness.
6866 pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
6867 self._parent = new_value.to_string();
6868 self
6869 }
6870 /// 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.
6871 ///
6872 /// Sets the *read mask* query property to the given value.
6873 pub fn read_mask(
6874 mut self,
6875 new_value: common::FieldMask,
6876 ) -> ProjectLocationQueueListCall<'a, C> {
6877 self._read_mask = Some(new_value);
6878 self
6879 }
6880 /// 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.
6881 ///
6882 /// Sets the *page token* query property to the given value.
6883 pub fn page_token(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
6884 self._page_token = Some(new_value.to_string());
6885 self
6886 }
6887 /// 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.
6888 ///
6889 /// Sets the *page size* query property to the given value.
6890 pub fn page_size(mut self, new_value: i32) -> ProjectLocationQueueListCall<'a, C> {
6891 self._page_size = Some(new_value);
6892 self
6893 }
6894 /// `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.
6895 ///
6896 /// Sets the *filter* query property to the given value.
6897 pub fn filter(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
6898 self._filter = Some(new_value.to_string());
6899 self
6900 }
6901 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6902 /// while executing the actual API request.
6903 ///
6904 /// ````text
6905 /// It should be used to handle progress information, and to implement a certain level of resilience.
6906 /// ````
6907 ///
6908 /// Sets the *delegate* property to the given value.
6909 pub fn delegate(
6910 mut self,
6911 new_value: &'a mut dyn common::Delegate,
6912 ) -> ProjectLocationQueueListCall<'a, C> {
6913 self._delegate = Some(new_value);
6914 self
6915 }
6916
6917 /// Set any additional parameter of the query string used in the request.
6918 /// It should be used to set parameters which are not yet available through their own
6919 /// setters.
6920 ///
6921 /// Please note that this method must not be used to set any of the known parameters
6922 /// which have their own setter method. If done anyway, the request will fail.
6923 ///
6924 /// # Additional Parameters
6925 ///
6926 /// * *$.xgafv* (query-string) - V1 error format.
6927 /// * *access_token* (query-string) - OAuth access token.
6928 /// * *alt* (query-string) - Data format for response.
6929 /// * *callback* (query-string) - JSONP
6930 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6931 /// * *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.
6932 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6933 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6934 /// * *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.
6935 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6936 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6937 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueListCall<'a, C>
6938 where
6939 T: AsRef<str>,
6940 {
6941 self._additional_params
6942 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6943 self
6944 }
6945
6946 /// Identifies the authorization scope for the method you are building.
6947 ///
6948 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6949 /// [`Scope::CloudPlatform`].
6950 ///
6951 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6952 /// tokens for more than one scope.
6953 ///
6954 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6955 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6956 /// sufficient, a read-write scope will do as well.
6957 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueListCall<'a, C>
6958 where
6959 St: AsRef<str>,
6960 {
6961 self._scopes.insert(String::from(scope.as_ref()));
6962 self
6963 }
6964 /// Identifies the authorization scope(s) for the method you are building.
6965 ///
6966 /// See [`Self::add_scope()`] for details.
6967 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueListCall<'a, C>
6968 where
6969 I: IntoIterator<Item = St>,
6970 St: AsRef<str>,
6971 {
6972 self._scopes
6973 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6974 self
6975 }
6976
6977 /// Removes all scopes, and no default scope will be used either.
6978 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6979 /// for details).
6980 pub fn clear_scopes(mut self) -> ProjectLocationQueueListCall<'a, C> {
6981 self._scopes.clear();
6982 self
6983 }
6984}
6985
6986/// 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.
6987///
6988/// A builder for the *locations.queues.patch* method supported by a *project* resource.
6989/// It is not used directly, but through a [`ProjectMethods`] instance.
6990///
6991/// # Example
6992///
6993/// Instantiate a resource method builder
6994///
6995/// ```test_harness,no_run
6996/// # extern crate hyper;
6997/// # extern crate hyper_rustls;
6998/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
6999/// use cloudtasks2_beta2::api::Queue;
7000/// # async fn dox() {
7001/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7002///
7003/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7004/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7005/// # secret,
7006/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7007/// # ).build().await.unwrap();
7008///
7009/// # let client = hyper_util::client::legacy::Client::builder(
7010/// # hyper_util::rt::TokioExecutor::new()
7011/// # )
7012/// # .build(
7013/// # hyper_rustls::HttpsConnectorBuilder::new()
7014/// # .with_native_roots()
7015/// # .unwrap()
7016/// # .https_or_http()
7017/// # .enable_http1()
7018/// # .build()
7019/// # );
7020/// # let mut hub = CloudTasks::new(client, auth);
7021/// // As the method needs a request, you would usually fill it with the desired information
7022/// // into the respective structure. Some of the parts shown here might not be applicable !
7023/// // Values shown here are possibly random and not representative !
7024/// let mut req = Queue::default();
7025///
7026/// // You can configure optional parameters by calling the respective setters at will, and
7027/// // execute the final call using `doit()`.
7028/// // Values shown here are possibly random and not representative !
7029/// let result = hub.projects().locations_queues_patch(req, "name")
7030/// .update_mask(FieldMask::new::<&str>(&[]))
7031/// .doit().await;
7032/// # }
7033/// ```
7034pub struct ProjectLocationQueuePatchCall<'a, C>
7035where
7036 C: 'a,
7037{
7038 hub: &'a CloudTasks<C>,
7039 _request: Queue,
7040 _name: String,
7041 _update_mask: Option<common::FieldMask>,
7042 _delegate: Option<&'a mut dyn common::Delegate>,
7043 _additional_params: HashMap<String, String>,
7044 _scopes: BTreeSet<String>,
7045}
7046
7047impl<'a, C> common::CallBuilder for ProjectLocationQueuePatchCall<'a, C> {}
7048
7049impl<'a, C> ProjectLocationQueuePatchCall<'a, C>
7050where
7051 C: common::Connector,
7052{
7053 /// Perform the operation you have build so far.
7054 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
7055 use std::borrow::Cow;
7056 use std::io::{Read, Seek};
7057
7058 use common::{url::Params, ToParts};
7059 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7060
7061 let mut dd = common::DefaultDelegate;
7062 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7063 dlg.begin(common::MethodInfo {
7064 id: "cloudtasks.projects.locations.queues.patch",
7065 http_method: hyper::Method::PATCH,
7066 });
7067
7068 for &field in ["alt", "name", "updateMask"].iter() {
7069 if self._additional_params.contains_key(field) {
7070 dlg.finished(false);
7071 return Err(common::Error::FieldClash(field));
7072 }
7073 }
7074
7075 let mut params = Params::with_capacity(5 + self._additional_params.len());
7076 params.push("name", self._name);
7077 if let Some(value) = self._update_mask.as_ref() {
7078 params.push("updateMask", value.to_string());
7079 }
7080
7081 params.extend(self._additional_params.iter());
7082
7083 params.push("alt", "json");
7084 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
7085 if self._scopes.is_empty() {
7086 self._scopes
7087 .insert(Scope::CloudPlatform.as_ref().to_string());
7088 }
7089
7090 #[allow(clippy::single_element_loop)]
7091 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7092 url = params.uri_replacement(url, param_name, find_this, true);
7093 }
7094 {
7095 let to_remove = ["name"];
7096 params.remove_params(&to_remove);
7097 }
7098
7099 let url = params.parse_with_url(&url);
7100
7101 let mut json_mime_type = mime::APPLICATION_JSON;
7102 let mut request_value_reader = {
7103 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7104 common::remove_json_null_values(&mut value);
7105 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7106 serde_json::to_writer(&mut dst, &value).unwrap();
7107 dst
7108 };
7109 let request_size = request_value_reader
7110 .seek(std::io::SeekFrom::End(0))
7111 .unwrap();
7112 request_value_reader
7113 .seek(std::io::SeekFrom::Start(0))
7114 .unwrap();
7115
7116 loop {
7117 let token = match self
7118 .hub
7119 .auth
7120 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7121 .await
7122 {
7123 Ok(token) => token,
7124 Err(e) => match dlg.token(e) {
7125 Ok(token) => token,
7126 Err(e) => {
7127 dlg.finished(false);
7128 return Err(common::Error::MissingToken(e));
7129 }
7130 },
7131 };
7132 request_value_reader
7133 .seek(std::io::SeekFrom::Start(0))
7134 .unwrap();
7135 let mut req_result = {
7136 let client = &self.hub.client;
7137 dlg.pre_request();
7138 let mut req_builder = hyper::Request::builder()
7139 .method(hyper::Method::PATCH)
7140 .uri(url.as_str())
7141 .header(USER_AGENT, self.hub._user_agent.clone());
7142
7143 if let Some(token) = token.as_ref() {
7144 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7145 }
7146
7147 let request = req_builder
7148 .header(CONTENT_TYPE, json_mime_type.to_string())
7149 .header(CONTENT_LENGTH, request_size as u64)
7150 .body(common::to_body(
7151 request_value_reader.get_ref().clone().into(),
7152 ));
7153
7154 client.request(request.unwrap()).await
7155 };
7156
7157 match req_result {
7158 Err(err) => {
7159 if let common::Retry::After(d) = dlg.http_error(&err) {
7160 sleep(d).await;
7161 continue;
7162 }
7163 dlg.finished(false);
7164 return Err(common::Error::HttpError(err));
7165 }
7166 Ok(res) => {
7167 let (mut parts, body) = res.into_parts();
7168 let mut body = common::Body::new(body);
7169 if !parts.status.is_success() {
7170 let bytes = common::to_bytes(body).await.unwrap_or_default();
7171 let error = serde_json::from_str(&common::to_string(&bytes));
7172 let response = common::to_response(parts, bytes.into());
7173
7174 if let common::Retry::After(d) =
7175 dlg.http_failure(&response, error.as_ref().ok())
7176 {
7177 sleep(d).await;
7178 continue;
7179 }
7180
7181 dlg.finished(false);
7182
7183 return Err(match error {
7184 Ok(value) => common::Error::BadRequest(value),
7185 _ => common::Error::Failure(response),
7186 });
7187 }
7188 let response = {
7189 let bytes = common::to_bytes(body).await.unwrap_or_default();
7190 let encoded = common::to_string(&bytes);
7191 match serde_json::from_str(&encoded) {
7192 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7193 Err(error) => {
7194 dlg.response_json_decode_error(&encoded, &error);
7195 return Err(common::Error::JsonDecodeError(
7196 encoded.to_string(),
7197 error,
7198 ));
7199 }
7200 }
7201 };
7202
7203 dlg.finished(true);
7204 return Ok(response);
7205 }
7206 }
7207 }
7208 }
7209
7210 ///
7211 /// Sets the *request* property to the given value.
7212 ///
7213 /// Even though the property as already been set when instantiating this call,
7214 /// we provide this method for API completeness.
7215 pub fn request(mut self, new_value: Queue) -> ProjectLocationQueuePatchCall<'a, C> {
7216 self._request = new_value;
7217 self
7218 }
7219 /// 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.
7220 ///
7221 /// Sets the *name* path property to the given value.
7222 ///
7223 /// Even though the property as already been set when instantiating this call,
7224 /// we provide this method for API completeness.
7225 pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePatchCall<'a, C> {
7226 self._name = new_value.to_string();
7227 self
7228 }
7229 /// A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated.
7230 ///
7231 /// Sets the *update mask* query property to the given value.
7232 pub fn update_mask(
7233 mut self,
7234 new_value: common::FieldMask,
7235 ) -> ProjectLocationQueuePatchCall<'a, C> {
7236 self._update_mask = Some(new_value);
7237 self
7238 }
7239 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7240 /// while executing the actual API request.
7241 ///
7242 /// ````text
7243 /// It should be used to handle progress information, and to implement a certain level of resilience.
7244 /// ````
7245 ///
7246 /// Sets the *delegate* property to the given value.
7247 pub fn delegate(
7248 mut self,
7249 new_value: &'a mut dyn common::Delegate,
7250 ) -> ProjectLocationQueuePatchCall<'a, C> {
7251 self._delegate = Some(new_value);
7252 self
7253 }
7254
7255 /// Set any additional parameter of the query string used in the request.
7256 /// It should be used to set parameters which are not yet available through their own
7257 /// setters.
7258 ///
7259 /// Please note that this method must not be used to set any of the known parameters
7260 /// which have their own setter method. If done anyway, the request will fail.
7261 ///
7262 /// # Additional Parameters
7263 ///
7264 /// * *$.xgafv* (query-string) - V1 error format.
7265 /// * *access_token* (query-string) - OAuth access token.
7266 /// * *alt* (query-string) - Data format for response.
7267 /// * *callback* (query-string) - JSONP
7268 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7269 /// * *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.
7270 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7271 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7272 /// * *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.
7273 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7274 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7275 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePatchCall<'a, C>
7276 where
7277 T: AsRef<str>,
7278 {
7279 self._additional_params
7280 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7281 self
7282 }
7283
7284 /// Identifies the authorization scope for the method you are building.
7285 ///
7286 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7287 /// [`Scope::CloudPlatform`].
7288 ///
7289 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7290 /// tokens for more than one scope.
7291 ///
7292 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7293 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7294 /// sufficient, a read-write scope will do as well.
7295 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePatchCall<'a, C>
7296 where
7297 St: AsRef<str>,
7298 {
7299 self._scopes.insert(String::from(scope.as_ref()));
7300 self
7301 }
7302 /// Identifies the authorization scope(s) for the method you are building.
7303 ///
7304 /// See [`Self::add_scope()`] for details.
7305 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePatchCall<'a, C>
7306 where
7307 I: IntoIterator<Item = St>,
7308 St: AsRef<str>,
7309 {
7310 self._scopes
7311 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7312 self
7313 }
7314
7315 /// Removes all scopes, and no default scope will be used either.
7316 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7317 /// for details).
7318 pub fn clear_scopes(mut self) -> ProjectLocationQueuePatchCall<'a, C> {
7319 self._scopes.clear();
7320 self
7321 }
7322}
7323
7324/// 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.
7325///
7326/// A builder for the *locations.queues.pause* method supported by a *project* resource.
7327/// It is not used directly, but through a [`ProjectMethods`] instance.
7328///
7329/// # Example
7330///
7331/// Instantiate a resource method builder
7332///
7333/// ```test_harness,no_run
7334/// # extern crate hyper;
7335/// # extern crate hyper_rustls;
7336/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
7337/// use cloudtasks2_beta2::api::PauseQueueRequest;
7338/// # async fn dox() {
7339/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7340///
7341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7343/// # secret,
7344/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7345/// # ).build().await.unwrap();
7346///
7347/// # let client = hyper_util::client::legacy::Client::builder(
7348/// # hyper_util::rt::TokioExecutor::new()
7349/// # )
7350/// # .build(
7351/// # hyper_rustls::HttpsConnectorBuilder::new()
7352/// # .with_native_roots()
7353/// # .unwrap()
7354/// # .https_or_http()
7355/// # .enable_http1()
7356/// # .build()
7357/// # );
7358/// # let mut hub = CloudTasks::new(client, auth);
7359/// // As the method needs a request, you would usually fill it with the desired information
7360/// // into the respective structure. Some of the parts shown here might not be applicable !
7361/// // Values shown here are possibly random and not representative !
7362/// let mut req = PauseQueueRequest::default();
7363///
7364/// // You can configure optional parameters by calling the respective setters at will, and
7365/// // execute the final call using `doit()`.
7366/// // Values shown here are possibly random and not representative !
7367/// let result = hub.projects().locations_queues_pause(req, "name")
7368/// .doit().await;
7369/// # }
7370/// ```
7371pub struct ProjectLocationQueuePauseCall<'a, C>
7372where
7373 C: 'a,
7374{
7375 hub: &'a CloudTasks<C>,
7376 _request: PauseQueueRequest,
7377 _name: String,
7378 _delegate: Option<&'a mut dyn common::Delegate>,
7379 _additional_params: HashMap<String, String>,
7380 _scopes: BTreeSet<String>,
7381}
7382
7383impl<'a, C> common::CallBuilder for ProjectLocationQueuePauseCall<'a, C> {}
7384
7385impl<'a, C> ProjectLocationQueuePauseCall<'a, C>
7386where
7387 C: common::Connector,
7388{
7389 /// Perform the operation you have build so far.
7390 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
7391 use std::borrow::Cow;
7392 use std::io::{Read, Seek};
7393
7394 use common::{url::Params, ToParts};
7395 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7396
7397 let mut dd = common::DefaultDelegate;
7398 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7399 dlg.begin(common::MethodInfo {
7400 id: "cloudtasks.projects.locations.queues.pause",
7401 http_method: hyper::Method::POST,
7402 });
7403
7404 for &field in ["alt", "name"].iter() {
7405 if self._additional_params.contains_key(field) {
7406 dlg.finished(false);
7407 return Err(common::Error::FieldClash(field));
7408 }
7409 }
7410
7411 let mut params = Params::with_capacity(4 + self._additional_params.len());
7412 params.push("name", self._name);
7413
7414 params.extend(self._additional_params.iter());
7415
7416 params.push("alt", "json");
7417 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:pause";
7418 if self._scopes.is_empty() {
7419 self._scopes
7420 .insert(Scope::CloudPlatform.as_ref().to_string());
7421 }
7422
7423 #[allow(clippy::single_element_loop)]
7424 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7425 url = params.uri_replacement(url, param_name, find_this, true);
7426 }
7427 {
7428 let to_remove = ["name"];
7429 params.remove_params(&to_remove);
7430 }
7431
7432 let url = params.parse_with_url(&url);
7433
7434 let mut json_mime_type = mime::APPLICATION_JSON;
7435 let mut request_value_reader = {
7436 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7437 common::remove_json_null_values(&mut value);
7438 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7439 serde_json::to_writer(&mut dst, &value).unwrap();
7440 dst
7441 };
7442 let request_size = request_value_reader
7443 .seek(std::io::SeekFrom::End(0))
7444 .unwrap();
7445 request_value_reader
7446 .seek(std::io::SeekFrom::Start(0))
7447 .unwrap();
7448
7449 loop {
7450 let token = match self
7451 .hub
7452 .auth
7453 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7454 .await
7455 {
7456 Ok(token) => token,
7457 Err(e) => match dlg.token(e) {
7458 Ok(token) => token,
7459 Err(e) => {
7460 dlg.finished(false);
7461 return Err(common::Error::MissingToken(e));
7462 }
7463 },
7464 };
7465 request_value_reader
7466 .seek(std::io::SeekFrom::Start(0))
7467 .unwrap();
7468 let mut req_result = {
7469 let client = &self.hub.client;
7470 dlg.pre_request();
7471 let mut req_builder = hyper::Request::builder()
7472 .method(hyper::Method::POST)
7473 .uri(url.as_str())
7474 .header(USER_AGENT, self.hub._user_agent.clone());
7475
7476 if let Some(token) = token.as_ref() {
7477 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7478 }
7479
7480 let request = req_builder
7481 .header(CONTENT_TYPE, json_mime_type.to_string())
7482 .header(CONTENT_LENGTH, request_size as u64)
7483 .body(common::to_body(
7484 request_value_reader.get_ref().clone().into(),
7485 ));
7486
7487 client.request(request.unwrap()).await
7488 };
7489
7490 match req_result {
7491 Err(err) => {
7492 if let common::Retry::After(d) = dlg.http_error(&err) {
7493 sleep(d).await;
7494 continue;
7495 }
7496 dlg.finished(false);
7497 return Err(common::Error::HttpError(err));
7498 }
7499 Ok(res) => {
7500 let (mut parts, body) = res.into_parts();
7501 let mut body = common::Body::new(body);
7502 if !parts.status.is_success() {
7503 let bytes = common::to_bytes(body).await.unwrap_or_default();
7504 let error = serde_json::from_str(&common::to_string(&bytes));
7505 let response = common::to_response(parts, bytes.into());
7506
7507 if let common::Retry::After(d) =
7508 dlg.http_failure(&response, error.as_ref().ok())
7509 {
7510 sleep(d).await;
7511 continue;
7512 }
7513
7514 dlg.finished(false);
7515
7516 return Err(match error {
7517 Ok(value) => common::Error::BadRequest(value),
7518 _ => common::Error::Failure(response),
7519 });
7520 }
7521 let response = {
7522 let bytes = common::to_bytes(body).await.unwrap_or_default();
7523 let encoded = common::to_string(&bytes);
7524 match serde_json::from_str(&encoded) {
7525 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7526 Err(error) => {
7527 dlg.response_json_decode_error(&encoded, &error);
7528 return Err(common::Error::JsonDecodeError(
7529 encoded.to_string(),
7530 error,
7531 ));
7532 }
7533 }
7534 };
7535
7536 dlg.finished(true);
7537 return Ok(response);
7538 }
7539 }
7540 }
7541 }
7542
7543 ///
7544 /// Sets the *request* property to the given value.
7545 ///
7546 /// Even though the property as already been set when instantiating this call,
7547 /// we provide this method for API completeness.
7548 pub fn request(mut self, new_value: PauseQueueRequest) -> ProjectLocationQueuePauseCall<'a, C> {
7549 self._request = new_value;
7550 self
7551 }
7552 /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
7553 ///
7554 /// Sets the *name* path property to the given value.
7555 ///
7556 /// Even though the property as already been set when instantiating this call,
7557 /// we provide this method for API completeness.
7558 pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePauseCall<'a, C> {
7559 self._name = new_value.to_string();
7560 self
7561 }
7562 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7563 /// while executing the actual API request.
7564 ///
7565 /// ````text
7566 /// It should be used to handle progress information, and to implement a certain level of resilience.
7567 /// ````
7568 ///
7569 /// Sets the *delegate* property to the given value.
7570 pub fn delegate(
7571 mut self,
7572 new_value: &'a mut dyn common::Delegate,
7573 ) -> ProjectLocationQueuePauseCall<'a, C> {
7574 self._delegate = Some(new_value);
7575 self
7576 }
7577
7578 /// Set any additional parameter of the query string used in the request.
7579 /// It should be used to set parameters which are not yet available through their own
7580 /// setters.
7581 ///
7582 /// Please note that this method must not be used to set any of the known parameters
7583 /// which have their own setter method. If done anyway, the request will fail.
7584 ///
7585 /// # Additional Parameters
7586 ///
7587 /// * *$.xgafv* (query-string) - V1 error format.
7588 /// * *access_token* (query-string) - OAuth access token.
7589 /// * *alt* (query-string) - Data format for response.
7590 /// * *callback* (query-string) - JSONP
7591 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7592 /// * *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.
7593 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7594 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7595 /// * *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.
7596 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7597 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7598 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePauseCall<'a, C>
7599 where
7600 T: AsRef<str>,
7601 {
7602 self._additional_params
7603 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7604 self
7605 }
7606
7607 /// Identifies the authorization scope for the method you are building.
7608 ///
7609 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7610 /// [`Scope::CloudPlatform`].
7611 ///
7612 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7613 /// tokens for more than one scope.
7614 ///
7615 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7616 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7617 /// sufficient, a read-write scope will do as well.
7618 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePauseCall<'a, C>
7619 where
7620 St: AsRef<str>,
7621 {
7622 self._scopes.insert(String::from(scope.as_ref()));
7623 self
7624 }
7625 /// Identifies the authorization scope(s) for the method you are building.
7626 ///
7627 /// See [`Self::add_scope()`] for details.
7628 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePauseCall<'a, C>
7629 where
7630 I: IntoIterator<Item = St>,
7631 St: AsRef<str>,
7632 {
7633 self._scopes
7634 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7635 self
7636 }
7637
7638 /// Removes all scopes, and no default scope will be used either.
7639 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7640 /// for details).
7641 pub fn clear_scopes(mut self) -> ProjectLocationQueuePauseCall<'a, C> {
7642 self._scopes.clear();
7643 self
7644 }
7645}
7646
7647/// 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.
7648///
7649/// A builder for the *locations.queues.purge* method supported by a *project* resource.
7650/// It is not used directly, but through a [`ProjectMethods`] instance.
7651///
7652/// # Example
7653///
7654/// Instantiate a resource method builder
7655///
7656/// ```test_harness,no_run
7657/// # extern crate hyper;
7658/// # extern crate hyper_rustls;
7659/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
7660/// use cloudtasks2_beta2::api::PurgeQueueRequest;
7661/// # async fn dox() {
7662/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7663///
7664/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7665/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7666/// # secret,
7667/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7668/// # ).build().await.unwrap();
7669///
7670/// # let client = hyper_util::client::legacy::Client::builder(
7671/// # hyper_util::rt::TokioExecutor::new()
7672/// # )
7673/// # .build(
7674/// # hyper_rustls::HttpsConnectorBuilder::new()
7675/// # .with_native_roots()
7676/// # .unwrap()
7677/// # .https_or_http()
7678/// # .enable_http1()
7679/// # .build()
7680/// # );
7681/// # let mut hub = CloudTasks::new(client, auth);
7682/// // As the method needs a request, you would usually fill it with the desired information
7683/// // into the respective structure. Some of the parts shown here might not be applicable !
7684/// // Values shown here are possibly random and not representative !
7685/// let mut req = PurgeQueueRequest::default();
7686///
7687/// // You can configure optional parameters by calling the respective setters at will, and
7688/// // execute the final call using `doit()`.
7689/// // Values shown here are possibly random and not representative !
7690/// let result = hub.projects().locations_queues_purge(req, "name")
7691/// .doit().await;
7692/// # }
7693/// ```
7694pub struct ProjectLocationQueuePurgeCall<'a, C>
7695where
7696 C: 'a,
7697{
7698 hub: &'a CloudTasks<C>,
7699 _request: PurgeQueueRequest,
7700 _name: String,
7701 _delegate: Option<&'a mut dyn common::Delegate>,
7702 _additional_params: HashMap<String, String>,
7703 _scopes: BTreeSet<String>,
7704}
7705
7706impl<'a, C> common::CallBuilder for ProjectLocationQueuePurgeCall<'a, C> {}
7707
7708impl<'a, C> ProjectLocationQueuePurgeCall<'a, C>
7709where
7710 C: common::Connector,
7711{
7712 /// Perform the operation you have build so far.
7713 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
7714 use std::borrow::Cow;
7715 use std::io::{Read, Seek};
7716
7717 use common::{url::Params, ToParts};
7718 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7719
7720 let mut dd = common::DefaultDelegate;
7721 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7722 dlg.begin(common::MethodInfo {
7723 id: "cloudtasks.projects.locations.queues.purge",
7724 http_method: hyper::Method::POST,
7725 });
7726
7727 for &field in ["alt", "name"].iter() {
7728 if self._additional_params.contains_key(field) {
7729 dlg.finished(false);
7730 return Err(common::Error::FieldClash(field));
7731 }
7732 }
7733
7734 let mut params = Params::with_capacity(4 + self._additional_params.len());
7735 params.push("name", self._name);
7736
7737 params.extend(self._additional_params.iter());
7738
7739 params.push("alt", "json");
7740 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:purge";
7741 if self._scopes.is_empty() {
7742 self._scopes
7743 .insert(Scope::CloudPlatform.as_ref().to_string());
7744 }
7745
7746 #[allow(clippy::single_element_loop)]
7747 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7748 url = params.uri_replacement(url, param_name, find_this, true);
7749 }
7750 {
7751 let to_remove = ["name"];
7752 params.remove_params(&to_remove);
7753 }
7754
7755 let url = params.parse_with_url(&url);
7756
7757 let mut json_mime_type = mime::APPLICATION_JSON;
7758 let mut request_value_reader = {
7759 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7760 common::remove_json_null_values(&mut value);
7761 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7762 serde_json::to_writer(&mut dst, &value).unwrap();
7763 dst
7764 };
7765 let request_size = request_value_reader
7766 .seek(std::io::SeekFrom::End(0))
7767 .unwrap();
7768 request_value_reader
7769 .seek(std::io::SeekFrom::Start(0))
7770 .unwrap();
7771
7772 loop {
7773 let token = match self
7774 .hub
7775 .auth
7776 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7777 .await
7778 {
7779 Ok(token) => token,
7780 Err(e) => match dlg.token(e) {
7781 Ok(token) => token,
7782 Err(e) => {
7783 dlg.finished(false);
7784 return Err(common::Error::MissingToken(e));
7785 }
7786 },
7787 };
7788 request_value_reader
7789 .seek(std::io::SeekFrom::Start(0))
7790 .unwrap();
7791 let mut req_result = {
7792 let client = &self.hub.client;
7793 dlg.pre_request();
7794 let mut req_builder = hyper::Request::builder()
7795 .method(hyper::Method::POST)
7796 .uri(url.as_str())
7797 .header(USER_AGENT, self.hub._user_agent.clone());
7798
7799 if let Some(token) = token.as_ref() {
7800 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7801 }
7802
7803 let request = req_builder
7804 .header(CONTENT_TYPE, json_mime_type.to_string())
7805 .header(CONTENT_LENGTH, request_size as u64)
7806 .body(common::to_body(
7807 request_value_reader.get_ref().clone().into(),
7808 ));
7809
7810 client.request(request.unwrap()).await
7811 };
7812
7813 match req_result {
7814 Err(err) => {
7815 if let common::Retry::After(d) = dlg.http_error(&err) {
7816 sleep(d).await;
7817 continue;
7818 }
7819 dlg.finished(false);
7820 return Err(common::Error::HttpError(err));
7821 }
7822 Ok(res) => {
7823 let (mut parts, body) = res.into_parts();
7824 let mut body = common::Body::new(body);
7825 if !parts.status.is_success() {
7826 let bytes = common::to_bytes(body).await.unwrap_or_default();
7827 let error = serde_json::from_str(&common::to_string(&bytes));
7828 let response = common::to_response(parts, bytes.into());
7829
7830 if let common::Retry::After(d) =
7831 dlg.http_failure(&response, error.as_ref().ok())
7832 {
7833 sleep(d).await;
7834 continue;
7835 }
7836
7837 dlg.finished(false);
7838
7839 return Err(match error {
7840 Ok(value) => common::Error::BadRequest(value),
7841 _ => common::Error::Failure(response),
7842 });
7843 }
7844 let response = {
7845 let bytes = common::to_bytes(body).await.unwrap_or_default();
7846 let encoded = common::to_string(&bytes);
7847 match serde_json::from_str(&encoded) {
7848 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7849 Err(error) => {
7850 dlg.response_json_decode_error(&encoded, &error);
7851 return Err(common::Error::JsonDecodeError(
7852 encoded.to_string(),
7853 error,
7854 ));
7855 }
7856 }
7857 };
7858
7859 dlg.finished(true);
7860 return Ok(response);
7861 }
7862 }
7863 }
7864 }
7865
7866 ///
7867 /// Sets the *request* property to the given value.
7868 ///
7869 /// Even though the property as already been set when instantiating this call,
7870 /// we provide this method for API completeness.
7871 pub fn request(mut self, new_value: PurgeQueueRequest) -> ProjectLocationQueuePurgeCall<'a, C> {
7872 self._request = new_value;
7873 self
7874 }
7875 /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
7876 ///
7877 /// Sets the *name* path property to the given value.
7878 ///
7879 /// Even though the property as already been set when instantiating this call,
7880 /// we provide this method for API completeness.
7881 pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePurgeCall<'a, C> {
7882 self._name = new_value.to_string();
7883 self
7884 }
7885 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7886 /// while executing the actual API request.
7887 ///
7888 /// ````text
7889 /// It should be used to handle progress information, and to implement a certain level of resilience.
7890 /// ````
7891 ///
7892 /// Sets the *delegate* property to the given value.
7893 pub fn delegate(
7894 mut self,
7895 new_value: &'a mut dyn common::Delegate,
7896 ) -> ProjectLocationQueuePurgeCall<'a, C> {
7897 self._delegate = Some(new_value);
7898 self
7899 }
7900
7901 /// Set any additional parameter of the query string used in the request.
7902 /// It should be used to set parameters which are not yet available through their own
7903 /// setters.
7904 ///
7905 /// Please note that this method must not be used to set any of the known parameters
7906 /// which have their own setter method. If done anyway, the request will fail.
7907 ///
7908 /// # Additional Parameters
7909 ///
7910 /// * *$.xgafv* (query-string) - V1 error format.
7911 /// * *access_token* (query-string) - OAuth access token.
7912 /// * *alt* (query-string) - Data format for response.
7913 /// * *callback* (query-string) - JSONP
7914 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7915 /// * *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.
7916 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7917 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7918 /// * *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.
7919 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7920 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7921 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePurgeCall<'a, C>
7922 where
7923 T: AsRef<str>,
7924 {
7925 self._additional_params
7926 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7927 self
7928 }
7929
7930 /// Identifies the authorization scope for the method you are building.
7931 ///
7932 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7933 /// [`Scope::CloudPlatform`].
7934 ///
7935 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7936 /// tokens for more than one scope.
7937 ///
7938 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7939 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7940 /// sufficient, a read-write scope will do as well.
7941 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePurgeCall<'a, C>
7942 where
7943 St: AsRef<str>,
7944 {
7945 self._scopes.insert(String::from(scope.as_ref()));
7946 self
7947 }
7948 /// Identifies the authorization scope(s) for the method you are building.
7949 ///
7950 /// See [`Self::add_scope()`] for details.
7951 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePurgeCall<'a, C>
7952 where
7953 I: IntoIterator<Item = St>,
7954 St: AsRef<str>,
7955 {
7956 self._scopes
7957 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7958 self
7959 }
7960
7961 /// Removes all scopes, and no default scope will be used either.
7962 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7963 /// for details).
7964 pub fn clear_scopes(mut self) -> ProjectLocationQueuePurgeCall<'a, C> {
7965 self._scopes.clear();
7966 self
7967 }
7968}
7969
7970/// 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).
7971///
7972/// A builder for the *locations.queues.resume* method supported by a *project* resource.
7973/// It is not used directly, but through a [`ProjectMethods`] instance.
7974///
7975/// # Example
7976///
7977/// Instantiate a resource method builder
7978///
7979/// ```test_harness,no_run
7980/// # extern crate hyper;
7981/// # extern crate hyper_rustls;
7982/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
7983/// use cloudtasks2_beta2::api::ResumeQueueRequest;
7984/// # async fn dox() {
7985/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7986///
7987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7988/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7989/// # secret,
7990/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7991/// # ).build().await.unwrap();
7992///
7993/// # let client = hyper_util::client::legacy::Client::builder(
7994/// # hyper_util::rt::TokioExecutor::new()
7995/// # )
7996/// # .build(
7997/// # hyper_rustls::HttpsConnectorBuilder::new()
7998/// # .with_native_roots()
7999/// # .unwrap()
8000/// # .https_or_http()
8001/// # .enable_http1()
8002/// # .build()
8003/// # );
8004/// # let mut hub = CloudTasks::new(client, auth);
8005/// // As the method needs a request, you would usually fill it with the desired information
8006/// // into the respective structure. Some of the parts shown here might not be applicable !
8007/// // Values shown here are possibly random and not representative !
8008/// let mut req = ResumeQueueRequest::default();
8009///
8010/// // You can configure optional parameters by calling the respective setters at will, and
8011/// // execute the final call using `doit()`.
8012/// // Values shown here are possibly random and not representative !
8013/// let result = hub.projects().locations_queues_resume(req, "name")
8014/// .doit().await;
8015/// # }
8016/// ```
8017pub struct ProjectLocationQueueResumeCall<'a, C>
8018where
8019 C: 'a,
8020{
8021 hub: &'a CloudTasks<C>,
8022 _request: ResumeQueueRequest,
8023 _name: String,
8024 _delegate: Option<&'a mut dyn common::Delegate>,
8025 _additional_params: HashMap<String, String>,
8026 _scopes: BTreeSet<String>,
8027}
8028
8029impl<'a, C> common::CallBuilder for ProjectLocationQueueResumeCall<'a, C> {}
8030
8031impl<'a, C> ProjectLocationQueueResumeCall<'a, C>
8032where
8033 C: common::Connector,
8034{
8035 /// Perform the operation you have build so far.
8036 pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
8037 use std::borrow::Cow;
8038 use std::io::{Read, Seek};
8039
8040 use common::{url::Params, ToParts};
8041 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8042
8043 let mut dd = common::DefaultDelegate;
8044 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8045 dlg.begin(common::MethodInfo {
8046 id: "cloudtasks.projects.locations.queues.resume",
8047 http_method: hyper::Method::POST,
8048 });
8049
8050 for &field in ["alt", "name"].iter() {
8051 if self._additional_params.contains_key(field) {
8052 dlg.finished(false);
8053 return Err(common::Error::FieldClash(field));
8054 }
8055 }
8056
8057 let mut params = Params::with_capacity(4 + self._additional_params.len());
8058 params.push("name", self._name);
8059
8060 params.extend(self._additional_params.iter());
8061
8062 params.push("alt", "json");
8063 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}:resume";
8064 if self._scopes.is_empty() {
8065 self._scopes
8066 .insert(Scope::CloudPlatform.as_ref().to_string());
8067 }
8068
8069 #[allow(clippy::single_element_loop)]
8070 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8071 url = params.uri_replacement(url, param_name, find_this, true);
8072 }
8073 {
8074 let to_remove = ["name"];
8075 params.remove_params(&to_remove);
8076 }
8077
8078 let url = params.parse_with_url(&url);
8079
8080 let mut json_mime_type = mime::APPLICATION_JSON;
8081 let mut request_value_reader = {
8082 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8083 common::remove_json_null_values(&mut value);
8084 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8085 serde_json::to_writer(&mut dst, &value).unwrap();
8086 dst
8087 };
8088 let request_size = request_value_reader
8089 .seek(std::io::SeekFrom::End(0))
8090 .unwrap();
8091 request_value_reader
8092 .seek(std::io::SeekFrom::Start(0))
8093 .unwrap();
8094
8095 loop {
8096 let token = match self
8097 .hub
8098 .auth
8099 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8100 .await
8101 {
8102 Ok(token) => token,
8103 Err(e) => match dlg.token(e) {
8104 Ok(token) => token,
8105 Err(e) => {
8106 dlg.finished(false);
8107 return Err(common::Error::MissingToken(e));
8108 }
8109 },
8110 };
8111 request_value_reader
8112 .seek(std::io::SeekFrom::Start(0))
8113 .unwrap();
8114 let mut req_result = {
8115 let client = &self.hub.client;
8116 dlg.pre_request();
8117 let mut req_builder = hyper::Request::builder()
8118 .method(hyper::Method::POST)
8119 .uri(url.as_str())
8120 .header(USER_AGENT, self.hub._user_agent.clone());
8121
8122 if let Some(token) = token.as_ref() {
8123 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8124 }
8125
8126 let request = req_builder
8127 .header(CONTENT_TYPE, json_mime_type.to_string())
8128 .header(CONTENT_LENGTH, request_size as u64)
8129 .body(common::to_body(
8130 request_value_reader.get_ref().clone().into(),
8131 ));
8132
8133 client.request(request.unwrap()).await
8134 };
8135
8136 match req_result {
8137 Err(err) => {
8138 if let common::Retry::After(d) = dlg.http_error(&err) {
8139 sleep(d).await;
8140 continue;
8141 }
8142 dlg.finished(false);
8143 return Err(common::Error::HttpError(err));
8144 }
8145 Ok(res) => {
8146 let (mut parts, body) = res.into_parts();
8147 let mut body = common::Body::new(body);
8148 if !parts.status.is_success() {
8149 let bytes = common::to_bytes(body).await.unwrap_or_default();
8150 let error = serde_json::from_str(&common::to_string(&bytes));
8151 let response = common::to_response(parts, bytes.into());
8152
8153 if let common::Retry::After(d) =
8154 dlg.http_failure(&response, error.as_ref().ok())
8155 {
8156 sleep(d).await;
8157 continue;
8158 }
8159
8160 dlg.finished(false);
8161
8162 return Err(match error {
8163 Ok(value) => common::Error::BadRequest(value),
8164 _ => common::Error::Failure(response),
8165 });
8166 }
8167 let response = {
8168 let bytes = common::to_bytes(body).await.unwrap_or_default();
8169 let encoded = common::to_string(&bytes);
8170 match serde_json::from_str(&encoded) {
8171 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8172 Err(error) => {
8173 dlg.response_json_decode_error(&encoded, &error);
8174 return Err(common::Error::JsonDecodeError(
8175 encoded.to_string(),
8176 error,
8177 ));
8178 }
8179 }
8180 };
8181
8182 dlg.finished(true);
8183 return Ok(response);
8184 }
8185 }
8186 }
8187 }
8188
8189 ///
8190 /// Sets the *request* property to the given value.
8191 ///
8192 /// Even though the property as already been set when instantiating this call,
8193 /// we provide this method for API completeness.
8194 pub fn request(
8195 mut self,
8196 new_value: ResumeQueueRequest,
8197 ) -> ProjectLocationQueueResumeCall<'a, C> {
8198 self._request = new_value;
8199 self
8200 }
8201 /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
8202 ///
8203 /// Sets the *name* path property to the given value.
8204 ///
8205 /// Even though the property as already been set when instantiating this call,
8206 /// we provide this method for API completeness.
8207 pub fn name(mut self, new_value: &str) -> ProjectLocationQueueResumeCall<'a, C> {
8208 self._name = new_value.to_string();
8209 self
8210 }
8211 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8212 /// while executing the actual API request.
8213 ///
8214 /// ````text
8215 /// It should be used to handle progress information, and to implement a certain level of resilience.
8216 /// ````
8217 ///
8218 /// Sets the *delegate* property to the given value.
8219 pub fn delegate(
8220 mut self,
8221 new_value: &'a mut dyn common::Delegate,
8222 ) -> ProjectLocationQueueResumeCall<'a, C> {
8223 self._delegate = Some(new_value);
8224 self
8225 }
8226
8227 /// Set any additional parameter of the query string used in the request.
8228 /// It should be used to set parameters which are not yet available through their own
8229 /// setters.
8230 ///
8231 /// Please note that this method must not be used to set any of the known parameters
8232 /// which have their own setter method. If done anyway, the request will fail.
8233 ///
8234 /// # Additional Parameters
8235 ///
8236 /// * *$.xgafv* (query-string) - V1 error format.
8237 /// * *access_token* (query-string) - OAuth access token.
8238 /// * *alt* (query-string) - Data format for response.
8239 /// * *callback* (query-string) - JSONP
8240 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8241 /// * *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.
8242 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8243 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8244 /// * *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.
8245 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8246 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8247 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueResumeCall<'a, C>
8248 where
8249 T: AsRef<str>,
8250 {
8251 self._additional_params
8252 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8253 self
8254 }
8255
8256 /// Identifies the authorization scope for the method you are building.
8257 ///
8258 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8259 /// [`Scope::CloudPlatform`].
8260 ///
8261 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8262 /// tokens for more than one scope.
8263 ///
8264 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8265 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8266 /// sufficient, a read-write scope will do as well.
8267 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueResumeCall<'a, C>
8268 where
8269 St: AsRef<str>,
8270 {
8271 self._scopes.insert(String::from(scope.as_ref()));
8272 self
8273 }
8274 /// Identifies the authorization scope(s) for the method you are building.
8275 ///
8276 /// See [`Self::add_scope()`] for details.
8277 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueResumeCall<'a, C>
8278 where
8279 I: IntoIterator<Item = St>,
8280 St: AsRef<str>,
8281 {
8282 self._scopes
8283 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8284 self
8285 }
8286
8287 /// Removes all scopes, and no default scope will be used either.
8288 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8289 /// for details).
8290 pub fn clear_scopes(mut self) -> ProjectLocationQueueResumeCall<'a, C> {
8291 self._scopes.clear();
8292 self
8293 }
8294}
8295
8296/// 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`
8297///
8298/// A builder for the *locations.queues.setIamPolicy* method supported by a *project* resource.
8299/// It is not used directly, but through a [`ProjectMethods`] instance.
8300///
8301/// # Example
8302///
8303/// Instantiate a resource method builder
8304///
8305/// ```test_harness,no_run
8306/// # extern crate hyper;
8307/// # extern crate hyper_rustls;
8308/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
8309/// use cloudtasks2_beta2::api::SetIamPolicyRequest;
8310/// # async fn dox() {
8311/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8312///
8313/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8314/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8315/// # secret,
8316/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8317/// # ).build().await.unwrap();
8318///
8319/// # let client = hyper_util::client::legacy::Client::builder(
8320/// # hyper_util::rt::TokioExecutor::new()
8321/// # )
8322/// # .build(
8323/// # hyper_rustls::HttpsConnectorBuilder::new()
8324/// # .with_native_roots()
8325/// # .unwrap()
8326/// # .https_or_http()
8327/// # .enable_http1()
8328/// # .build()
8329/// # );
8330/// # let mut hub = CloudTasks::new(client, auth);
8331/// // As the method needs a request, you would usually fill it with the desired information
8332/// // into the respective structure. Some of the parts shown here might not be applicable !
8333/// // Values shown here are possibly random and not representative !
8334/// let mut req = SetIamPolicyRequest::default();
8335///
8336/// // You can configure optional parameters by calling the respective setters at will, and
8337/// // execute the final call using `doit()`.
8338/// // Values shown here are possibly random and not representative !
8339/// let result = hub.projects().locations_queues_set_iam_policy(req, "resource")
8340/// .doit().await;
8341/// # }
8342/// ```
8343pub struct ProjectLocationQueueSetIamPolicyCall<'a, C>
8344where
8345 C: 'a,
8346{
8347 hub: &'a CloudTasks<C>,
8348 _request: SetIamPolicyRequest,
8349 _resource: String,
8350 _delegate: Option<&'a mut dyn common::Delegate>,
8351 _additional_params: HashMap<String, String>,
8352 _scopes: BTreeSet<String>,
8353}
8354
8355impl<'a, C> common::CallBuilder for ProjectLocationQueueSetIamPolicyCall<'a, C> {}
8356
8357impl<'a, C> ProjectLocationQueueSetIamPolicyCall<'a, C>
8358where
8359 C: common::Connector,
8360{
8361 /// Perform the operation you have build so far.
8362 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8363 use std::borrow::Cow;
8364 use std::io::{Read, Seek};
8365
8366 use common::{url::Params, ToParts};
8367 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8368
8369 let mut dd = common::DefaultDelegate;
8370 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8371 dlg.begin(common::MethodInfo {
8372 id: "cloudtasks.projects.locations.queues.setIamPolicy",
8373 http_method: hyper::Method::POST,
8374 });
8375
8376 for &field in ["alt", "resource"].iter() {
8377 if self._additional_params.contains_key(field) {
8378 dlg.finished(false);
8379 return Err(common::Error::FieldClash(field));
8380 }
8381 }
8382
8383 let mut params = Params::with_capacity(4 + self._additional_params.len());
8384 params.push("resource", self._resource);
8385
8386 params.extend(self._additional_params.iter());
8387
8388 params.push("alt", "json");
8389 let mut url = self.hub._base_url.clone() + "v2beta2/{+resource}:setIamPolicy";
8390 if self._scopes.is_empty() {
8391 self._scopes
8392 .insert(Scope::CloudPlatform.as_ref().to_string());
8393 }
8394
8395 #[allow(clippy::single_element_loop)]
8396 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8397 url = params.uri_replacement(url, param_name, find_this, true);
8398 }
8399 {
8400 let to_remove = ["resource"];
8401 params.remove_params(&to_remove);
8402 }
8403
8404 let url = params.parse_with_url(&url);
8405
8406 let mut json_mime_type = mime::APPLICATION_JSON;
8407 let mut request_value_reader = {
8408 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8409 common::remove_json_null_values(&mut value);
8410 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8411 serde_json::to_writer(&mut dst, &value).unwrap();
8412 dst
8413 };
8414 let request_size = request_value_reader
8415 .seek(std::io::SeekFrom::End(0))
8416 .unwrap();
8417 request_value_reader
8418 .seek(std::io::SeekFrom::Start(0))
8419 .unwrap();
8420
8421 loop {
8422 let token = match self
8423 .hub
8424 .auth
8425 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8426 .await
8427 {
8428 Ok(token) => token,
8429 Err(e) => match dlg.token(e) {
8430 Ok(token) => token,
8431 Err(e) => {
8432 dlg.finished(false);
8433 return Err(common::Error::MissingToken(e));
8434 }
8435 },
8436 };
8437 request_value_reader
8438 .seek(std::io::SeekFrom::Start(0))
8439 .unwrap();
8440 let mut req_result = {
8441 let client = &self.hub.client;
8442 dlg.pre_request();
8443 let mut req_builder = hyper::Request::builder()
8444 .method(hyper::Method::POST)
8445 .uri(url.as_str())
8446 .header(USER_AGENT, self.hub._user_agent.clone());
8447
8448 if let Some(token) = token.as_ref() {
8449 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8450 }
8451
8452 let request = req_builder
8453 .header(CONTENT_TYPE, json_mime_type.to_string())
8454 .header(CONTENT_LENGTH, request_size as u64)
8455 .body(common::to_body(
8456 request_value_reader.get_ref().clone().into(),
8457 ));
8458
8459 client.request(request.unwrap()).await
8460 };
8461
8462 match req_result {
8463 Err(err) => {
8464 if let common::Retry::After(d) = dlg.http_error(&err) {
8465 sleep(d).await;
8466 continue;
8467 }
8468 dlg.finished(false);
8469 return Err(common::Error::HttpError(err));
8470 }
8471 Ok(res) => {
8472 let (mut parts, body) = res.into_parts();
8473 let mut body = common::Body::new(body);
8474 if !parts.status.is_success() {
8475 let bytes = common::to_bytes(body).await.unwrap_or_default();
8476 let error = serde_json::from_str(&common::to_string(&bytes));
8477 let response = common::to_response(parts, bytes.into());
8478
8479 if let common::Retry::After(d) =
8480 dlg.http_failure(&response, error.as_ref().ok())
8481 {
8482 sleep(d).await;
8483 continue;
8484 }
8485
8486 dlg.finished(false);
8487
8488 return Err(match error {
8489 Ok(value) => common::Error::BadRequest(value),
8490 _ => common::Error::Failure(response),
8491 });
8492 }
8493 let response = {
8494 let bytes = common::to_bytes(body).await.unwrap_or_default();
8495 let encoded = common::to_string(&bytes);
8496 match serde_json::from_str(&encoded) {
8497 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8498 Err(error) => {
8499 dlg.response_json_decode_error(&encoded, &error);
8500 return Err(common::Error::JsonDecodeError(
8501 encoded.to_string(),
8502 error,
8503 ));
8504 }
8505 }
8506 };
8507
8508 dlg.finished(true);
8509 return Ok(response);
8510 }
8511 }
8512 }
8513 }
8514
8515 ///
8516 /// Sets the *request* property to the given value.
8517 ///
8518 /// Even though the property as already been set when instantiating this call,
8519 /// we provide this method for API completeness.
8520 pub fn request(
8521 mut self,
8522 new_value: SetIamPolicyRequest,
8523 ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8524 self._request = new_value;
8525 self
8526 }
8527 /// 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.
8528 ///
8529 /// Sets the *resource* path property to the given value.
8530 ///
8531 /// Even though the property as already been set when instantiating this call,
8532 /// we provide this method for API completeness.
8533 pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8534 self._resource = new_value.to_string();
8535 self
8536 }
8537 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8538 /// while executing the actual API request.
8539 ///
8540 /// ````text
8541 /// It should be used to handle progress information, and to implement a certain level of resilience.
8542 /// ````
8543 ///
8544 /// Sets the *delegate* property to the given value.
8545 pub fn delegate(
8546 mut self,
8547 new_value: &'a mut dyn common::Delegate,
8548 ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8549 self._delegate = Some(new_value);
8550 self
8551 }
8552
8553 /// Set any additional parameter of the query string used in the request.
8554 /// It should be used to set parameters which are not yet available through their own
8555 /// setters.
8556 ///
8557 /// Please note that this method must not be used to set any of the known parameters
8558 /// which have their own setter method. If done anyway, the request will fail.
8559 ///
8560 /// # Additional Parameters
8561 ///
8562 /// * *$.xgafv* (query-string) - V1 error format.
8563 /// * *access_token* (query-string) - OAuth access token.
8564 /// * *alt* (query-string) - Data format for response.
8565 /// * *callback* (query-string) - JSONP
8566 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8567 /// * *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.
8568 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8569 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8570 /// * *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.
8571 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8572 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8573 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
8574 where
8575 T: AsRef<str>,
8576 {
8577 self._additional_params
8578 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8579 self
8580 }
8581
8582 /// Identifies the authorization scope for the method you are building.
8583 ///
8584 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8585 /// [`Scope::CloudPlatform`].
8586 ///
8587 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8588 /// tokens for more than one scope.
8589 ///
8590 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8591 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8592 /// sufficient, a read-write scope will do as well.
8593 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
8594 where
8595 St: AsRef<str>,
8596 {
8597 self._scopes.insert(String::from(scope.as_ref()));
8598 self
8599 }
8600 /// Identifies the authorization scope(s) for the method you are building.
8601 ///
8602 /// See [`Self::add_scope()`] for details.
8603 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
8604 where
8605 I: IntoIterator<Item = St>,
8606 St: AsRef<str>,
8607 {
8608 self._scopes
8609 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8610 self
8611 }
8612
8613 /// Removes all scopes, and no default scope will be used either.
8614 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8615 /// for details).
8616 pub fn clear_scopes(mut self) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
8617 self._scopes.clear();
8618 self
8619 }
8620}
8621
8622/// 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.
8623///
8624/// A builder for the *locations.queues.testIamPermissions* method supported by a *project* resource.
8625/// It is not used directly, but through a [`ProjectMethods`] instance.
8626///
8627/// # Example
8628///
8629/// Instantiate a resource method builder
8630///
8631/// ```test_harness,no_run
8632/// # extern crate hyper;
8633/// # extern crate hyper_rustls;
8634/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
8635/// use cloudtasks2_beta2::api::TestIamPermissionsRequest;
8636/// # async fn dox() {
8637/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8638///
8639/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8641/// # secret,
8642/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8643/// # ).build().await.unwrap();
8644///
8645/// # let client = hyper_util::client::legacy::Client::builder(
8646/// # hyper_util::rt::TokioExecutor::new()
8647/// # )
8648/// # .build(
8649/// # hyper_rustls::HttpsConnectorBuilder::new()
8650/// # .with_native_roots()
8651/// # .unwrap()
8652/// # .https_or_http()
8653/// # .enable_http1()
8654/// # .build()
8655/// # );
8656/// # let mut hub = CloudTasks::new(client, auth);
8657/// // As the method needs a request, you would usually fill it with the desired information
8658/// // into the respective structure. Some of the parts shown here might not be applicable !
8659/// // Values shown here are possibly random and not representative !
8660/// let mut req = TestIamPermissionsRequest::default();
8661///
8662/// // You can configure optional parameters by calling the respective setters at will, and
8663/// // execute the final call using `doit()`.
8664/// // Values shown here are possibly random and not representative !
8665/// let result = hub.projects().locations_queues_test_iam_permissions(req, "resource")
8666/// .doit().await;
8667/// # }
8668/// ```
8669pub struct ProjectLocationQueueTestIamPermissionCall<'a, C>
8670where
8671 C: 'a,
8672{
8673 hub: &'a CloudTasks<C>,
8674 _request: TestIamPermissionsRequest,
8675 _resource: String,
8676 _delegate: Option<&'a mut dyn common::Delegate>,
8677 _additional_params: HashMap<String, String>,
8678 _scopes: BTreeSet<String>,
8679}
8680
8681impl<'a, C> common::CallBuilder for ProjectLocationQueueTestIamPermissionCall<'a, C> {}
8682
8683impl<'a, C> ProjectLocationQueueTestIamPermissionCall<'a, C>
8684where
8685 C: common::Connector,
8686{
8687 /// Perform the operation you have build so far.
8688 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8689 use std::borrow::Cow;
8690 use std::io::{Read, Seek};
8691
8692 use common::{url::Params, ToParts};
8693 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8694
8695 let mut dd = common::DefaultDelegate;
8696 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8697 dlg.begin(common::MethodInfo {
8698 id: "cloudtasks.projects.locations.queues.testIamPermissions",
8699 http_method: hyper::Method::POST,
8700 });
8701
8702 for &field in ["alt", "resource"].iter() {
8703 if self._additional_params.contains_key(field) {
8704 dlg.finished(false);
8705 return Err(common::Error::FieldClash(field));
8706 }
8707 }
8708
8709 let mut params = Params::with_capacity(4 + self._additional_params.len());
8710 params.push("resource", self._resource);
8711
8712 params.extend(self._additional_params.iter());
8713
8714 params.push("alt", "json");
8715 let mut url = self.hub._base_url.clone() + "v2beta2/{+resource}:testIamPermissions";
8716 if self._scopes.is_empty() {
8717 self._scopes
8718 .insert(Scope::CloudPlatform.as_ref().to_string());
8719 }
8720
8721 #[allow(clippy::single_element_loop)]
8722 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8723 url = params.uri_replacement(url, param_name, find_this, true);
8724 }
8725 {
8726 let to_remove = ["resource"];
8727 params.remove_params(&to_remove);
8728 }
8729
8730 let url = params.parse_with_url(&url);
8731
8732 let mut json_mime_type = mime::APPLICATION_JSON;
8733 let mut request_value_reader = {
8734 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8735 common::remove_json_null_values(&mut value);
8736 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8737 serde_json::to_writer(&mut dst, &value).unwrap();
8738 dst
8739 };
8740 let request_size = request_value_reader
8741 .seek(std::io::SeekFrom::End(0))
8742 .unwrap();
8743 request_value_reader
8744 .seek(std::io::SeekFrom::Start(0))
8745 .unwrap();
8746
8747 loop {
8748 let token = match self
8749 .hub
8750 .auth
8751 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8752 .await
8753 {
8754 Ok(token) => token,
8755 Err(e) => match dlg.token(e) {
8756 Ok(token) => token,
8757 Err(e) => {
8758 dlg.finished(false);
8759 return Err(common::Error::MissingToken(e));
8760 }
8761 },
8762 };
8763 request_value_reader
8764 .seek(std::io::SeekFrom::Start(0))
8765 .unwrap();
8766 let mut req_result = {
8767 let client = &self.hub.client;
8768 dlg.pre_request();
8769 let mut req_builder = hyper::Request::builder()
8770 .method(hyper::Method::POST)
8771 .uri(url.as_str())
8772 .header(USER_AGENT, self.hub._user_agent.clone());
8773
8774 if let Some(token) = token.as_ref() {
8775 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8776 }
8777
8778 let request = req_builder
8779 .header(CONTENT_TYPE, json_mime_type.to_string())
8780 .header(CONTENT_LENGTH, request_size as u64)
8781 .body(common::to_body(
8782 request_value_reader.get_ref().clone().into(),
8783 ));
8784
8785 client.request(request.unwrap()).await
8786 };
8787
8788 match req_result {
8789 Err(err) => {
8790 if let common::Retry::After(d) = dlg.http_error(&err) {
8791 sleep(d).await;
8792 continue;
8793 }
8794 dlg.finished(false);
8795 return Err(common::Error::HttpError(err));
8796 }
8797 Ok(res) => {
8798 let (mut parts, body) = res.into_parts();
8799 let mut body = common::Body::new(body);
8800 if !parts.status.is_success() {
8801 let bytes = common::to_bytes(body).await.unwrap_or_default();
8802 let error = serde_json::from_str(&common::to_string(&bytes));
8803 let response = common::to_response(parts, bytes.into());
8804
8805 if let common::Retry::After(d) =
8806 dlg.http_failure(&response, error.as_ref().ok())
8807 {
8808 sleep(d).await;
8809 continue;
8810 }
8811
8812 dlg.finished(false);
8813
8814 return Err(match error {
8815 Ok(value) => common::Error::BadRequest(value),
8816 _ => common::Error::Failure(response),
8817 });
8818 }
8819 let response = {
8820 let bytes = common::to_bytes(body).await.unwrap_or_default();
8821 let encoded = common::to_string(&bytes);
8822 match serde_json::from_str(&encoded) {
8823 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8824 Err(error) => {
8825 dlg.response_json_decode_error(&encoded, &error);
8826 return Err(common::Error::JsonDecodeError(
8827 encoded.to_string(),
8828 error,
8829 ));
8830 }
8831 }
8832 };
8833
8834 dlg.finished(true);
8835 return Ok(response);
8836 }
8837 }
8838 }
8839 }
8840
8841 ///
8842 /// Sets the *request* property to the given value.
8843 ///
8844 /// Even though the property as already been set when instantiating this call,
8845 /// we provide this method for API completeness.
8846 pub fn request(
8847 mut self,
8848 new_value: TestIamPermissionsRequest,
8849 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
8850 self._request = new_value;
8851 self
8852 }
8853 /// 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.
8854 ///
8855 /// Sets the *resource* path property to the given value.
8856 ///
8857 /// Even though the property as already been set when instantiating this call,
8858 /// we provide this method for API completeness.
8859 pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
8860 self._resource = new_value.to_string();
8861 self
8862 }
8863 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8864 /// while executing the actual API request.
8865 ///
8866 /// ````text
8867 /// It should be used to handle progress information, and to implement a certain level of resilience.
8868 /// ````
8869 ///
8870 /// Sets the *delegate* property to the given value.
8871 pub fn delegate(
8872 mut self,
8873 new_value: &'a mut dyn common::Delegate,
8874 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
8875 self._delegate = Some(new_value);
8876 self
8877 }
8878
8879 /// Set any additional parameter of the query string used in the request.
8880 /// It should be used to set parameters which are not yet available through their own
8881 /// setters.
8882 ///
8883 /// Please note that this method must not be used to set any of the known parameters
8884 /// which have their own setter method. If done anyway, the request will fail.
8885 ///
8886 /// # Additional Parameters
8887 ///
8888 /// * *$.xgafv* (query-string) - V1 error format.
8889 /// * *access_token* (query-string) - OAuth access token.
8890 /// * *alt* (query-string) - Data format for response.
8891 /// * *callback* (query-string) - JSONP
8892 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8893 /// * *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.
8894 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8895 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8896 /// * *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.
8897 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8898 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8899 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
8900 where
8901 T: AsRef<str>,
8902 {
8903 self._additional_params
8904 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8905 self
8906 }
8907
8908 /// Identifies the authorization scope for the method you are building.
8909 ///
8910 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8911 /// [`Scope::CloudPlatform`].
8912 ///
8913 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8914 /// tokens for more than one scope.
8915 ///
8916 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8917 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8918 /// sufficient, a read-write scope will do as well.
8919 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
8920 where
8921 St: AsRef<str>,
8922 {
8923 self._scopes.insert(String::from(scope.as_ref()));
8924 self
8925 }
8926 /// Identifies the authorization scope(s) for the method you are building.
8927 ///
8928 /// See [`Self::add_scope()`] for details.
8929 pub fn add_scopes<I, St>(
8930 mut self,
8931 scopes: I,
8932 ) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
8933 where
8934 I: IntoIterator<Item = St>,
8935 St: AsRef<str>,
8936 {
8937 self._scopes
8938 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8939 self
8940 }
8941
8942 /// Removes all scopes, and no default scope will be used either.
8943 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8944 /// for details).
8945 pub fn clear_scopes(mut self) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
8946 self._scopes.clear();
8947 self
8948 }
8949}
8950
8951/// Gets information about a location.
8952///
8953/// A builder for the *locations.get* method supported by a *project* resource.
8954/// It is not used directly, but through a [`ProjectMethods`] instance.
8955///
8956/// # Example
8957///
8958/// Instantiate a resource method builder
8959///
8960/// ```test_harness,no_run
8961/// # extern crate hyper;
8962/// # extern crate hyper_rustls;
8963/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
8964/// # async fn dox() {
8965/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8966///
8967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8969/// # secret,
8970/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8971/// # ).build().await.unwrap();
8972///
8973/// # let client = hyper_util::client::legacy::Client::builder(
8974/// # hyper_util::rt::TokioExecutor::new()
8975/// # )
8976/// # .build(
8977/// # hyper_rustls::HttpsConnectorBuilder::new()
8978/// # .with_native_roots()
8979/// # .unwrap()
8980/// # .https_or_http()
8981/// # .enable_http1()
8982/// # .build()
8983/// # );
8984/// # let mut hub = CloudTasks::new(client, auth);
8985/// // You can configure optional parameters by calling the respective setters at will, and
8986/// // execute the final call using `doit()`.
8987/// // Values shown here are possibly random and not representative !
8988/// let result = hub.projects().locations_get("name")
8989/// .doit().await;
8990/// # }
8991/// ```
8992pub struct ProjectLocationGetCall<'a, C>
8993where
8994 C: 'a,
8995{
8996 hub: &'a CloudTasks<C>,
8997 _name: String,
8998 _delegate: Option<&'a mut dyn common::Delegate>,
8999 _additional_params: HashMap<String, String>,
9000 _scopes: BTreeSet<String>,
9001}
9002
9003impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
9004
9005impl<'a, C> ProjectLocationGetCall<'a, C>
9006where
9007 C: common::Connector,
9008{
9009 /// Perform the operation you have build so far.
9010 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
9011 use std::borrow::Cow;
9012 use std::io::{Read, Seek};
9013
9014 use common::{url::Params, ToParts};
9015 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9016
9017 let mut dd = common::DefaultDelegate;
9018 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9019 dlg.begin(common::MethodInfo {
9020 id: "cloudtasks.projects.locations.get",
9021 http_method: hyper::Method::GET,
9022 });
9023
9024 for &field in ["alt", "name"].iter() {
9025 if self._additional_params.contains_key(field) {
9026 dlg.finished(false);
9027 return Err(common::Error::FieldClash(field));
9028 }
9029 }
9030
9031 let mut params = Params::with_capacity(3 + self._additional_params.len());
9032 params.push("name", self._name);
9033
9034 params.extend(self._additional_params.iter());
9035
9036 params.push("alt", "json");
9037 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
9038 if self._scopes.is_empty() {
9039 self._scopes
9040 .insert(Scope::CloudPlatform.as_ref().to_string());
9041 }
9042
9043 #[allow(clippy::single_element_loop)]
9044 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9045 url = params.uri_replacement(url, param_name, find_this, true);
9046 }
9047 {
9048 let to_remove = ["name"];
9049 params.remove_params(&to_remove);
9050 }
9051
9052 let url = params.parse_with_url(&url);
9053
9054 loop {
9055 let token = match self
9056 .hub
9057 .auth
9058 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9059 .await
9060 {
9061 Ok(token) => token,
9062 Err(e) => match dlg.token(e) {
9063 Ok(token) => token,
9064 Err(e) => {
9065 dlg.finished(false);
9066 return Err(common::Error::MissingToken(e));
9067 }
9068 },
9069 };
9070 let mut req_result = {
9071 let client = &self.hub.client;
9072 dlg.pre_request();
9073 let mut req_builder = hyper::Request::builder()
9074 .method(hyper::Method::GET)
9075 .uri(url.as_str())
9076 .header(USER_AGENT, self.hub._user_agent.clone());
9077
9078 if let Some(token) = token.as_ref() {
9079 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9080 }
9081
9082 let request = req_builder
9083 .header(CONTENT_LENGTH, 0_u64)
9084 .body(common::to_body::<String>(None));
9085
9086 client.request(request.unwrap()).await
9087 };
9088
9089 match req_result {
9090 Err(err) => {
9091 if let common::Retry::After(d) = dlg.http_error(&err) {
9092 sleep(d).await;
9093 continue;
9094 }
9095 dlg.finished(false);
9096 return Err(common::Error::HttpError(err));
9097 }
9098 Ok(res) => {
9099 let (mut parts, body) = res.into_parts();
9100 let mut body = common::Body::new(body);
9101 if !parts.status.is_success() {
9102 let bytes = common::to_bytes(body).await.unwrap_or_default();
9103 let error = serde_json::from_str(&common::to_string(&bytes));
9104 let response = common::to_response(parts, bytes.into());
9105
9106 if let common::Retry::After(d) =
9107 dlg.http_failure(&response, error.as_ref().ok())
9108 {
9109 sleep(d).await;
9110 continue;
9111 }
9112
9113 dlg.finished(false);
9114
9115 return Err(match error {
9116 Ok(value) => common::Error::BadRequest(value),
9117 _ => common::Error::Failure(response),
9118 });
9119 }
9120 let response = {
9121 let bytes = common::to_bytes(body).await.unwrap_or_default();
9122 let encoded = common::to_string(&bytes);
9123 match serde_json::from_str(&encoded) {
9124 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9125 Err(error) => {
9126 dlg.response_json_decode_error(&encoded, &error);
9127 return Err(common::Error::JsonDecodeError(
9128 encoded.to_string(),
9129 error,
9130 ));
9131 }
9132 }
9133 };
9134
9135 dlg.finished(true);
9136 return Ok(response);
9137 }
9138 }
9139 }
9140 }
9141
9142 /// Resource name for the location.
9143 ///
9144 /// Sets the *name* path property to the given value.
9145 ///
9146 /// Even though the property as already been set when instantiating this call,
9147 /// we provide this method for API completeness.
9148 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
9149 self._name = new_value.to_string();
9150 self
9151 }
9152 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9153 /// while executing the actual API request.
9154 ///
9155 /// ````text
9156 /// It should be used to handle progress information, and to implement a certain level of resilience.
9157 /// ````
9158 ///
9159 /// Sets the *delegate* property to the given value.
9160 pub fn delegate(
9161 mut self,
9162 new_value: &'a mut dyn common::Delegate,
9163 ) -> ProjectLocationGetCall<'a, C> {
9164 self._delegate = Some(new_value);
9165 self
9166 }
9167
9168 /// Set any additional parameter of the query string used in the request.
9169 /// It should be used to set parameters which are not yet available through their own
9170 /// setters.
9171 ///
9172 /// Please note that this method must not be used to set any of the known parameters
9173 /// which have their own setter method. If done anyway, the request will fail.
9174 ///
9175 /// # Additional Parameters
9176 ///
9177 /// * *$.xgafv* (query-string) - V1 error format.
9178 /// * *access_token* (query-string) - OAuth access token.
9179 /// * *alt* (query-string) - Data format for response.
9180 /// * *callback* (query-string) - JSONP
9181 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9182 /// * *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.
9183 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9184 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9185 /// * *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.
9186 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9187 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9188 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
9189 where
9190 T: AsRef<str>,
9191 {
9192 self._additional_params
9193 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9194 self
9195 }
9196
9197 /// Identifies the authorization scope for the method you are building.
9198 ///
9199 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9200 /// [`Scope::CloudPlatform`].
9201 ///
9202 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9203 /// tokens for more than one scope.
9204 ///
9205 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9206 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9207 /// sufficient, a read-write scope will do as well.
9208 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
9209 where
9210 St: AsRef<str>,
9211 {
9212 self._scopes.insert(String::from(scope.as_ref()));
9213 self
9214 }
9215 /// Identifies the authorization scope(s) for the method you are building.
9216 ///
9217 /// See [`Self::add_scope()`] for details.
9218 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
9219 where
9220 I: IntoIterator<Item = St>,
9221 St: AsRef<str>,
9222 {
9223 self._scopes
9224 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9225 self
9226 }
9227
9228 /// Removes all scopes, and no default scope will be used either.
9229 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9230 /// for details).
9231 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
9232 self._scopes.clear();
9233 self
9234 }
9235}
9236
9237/// Gets the CMEK config. Gets the Customer Managed Encryption Key configured with the Cloud Tasks lcoation. By default there is no kms_key configured.
9238///
9239/// A builder for the *locations.getCmekConfig* method supported by a *project* resource.
9240/// It is not used directly, but through a [`ProjectMethods`] instance.
9241///
9242/// # Example
9243///
9244/// Instantiate a resource method builder
9245///
9246/// ```test_harness,no_run
9247/// # extern crate hyper;
9248/// # extern crate hyper_rustls;
9249/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
9250/// # async fn dox() {
9251/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9252///
9253/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9255/// # secret,
9256/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9257/// # ).build().await.unwrap();
9258///
9259/// # let client = hyper_util::client::legacy::Client::builder(
9260/// # hyper_util::rt::TokioExecutor::new()
9261/// # )
9262/// # .build(
9263/// # hyper_rustls::HttpsConnectorBuilder::new()
9264/// # .with_native_roots()
9265/// # .unwrap()
9266/// # .https_or_http()
9267/// # .enable_http1()
9268/// # .build()
9269/// # );
9270/// # let mut hub = CloudTasks::new(client, auth);
9271/// // You can configure optional parameters by calling the respective setters at will, and
9272/// // execute the final call using `doit()`.
9273/// // Values shown here are possibly random and not representative !
9274/// let result = hub.projects().locations_get_cmek_config("name")
9275/// .doit().await;
9276/// # }
9277/// ```
9278pub struct ProjectLocationGetCmekConfigCall<'a, C>
9279where
9280 C: 'a,
9281{
9282 hub: &'a CloudTasks<C>,
9283 _name: String,
9284 _delegate: Option<&'a mut dyn common::Delegate>,
9285 _additional_params: HashMap<String, String>,
9286 _scopes: BTreeSet<String>,
9287}
9288
9289impl<'a, C> common::CallBuilder for ProjectLocationGetCmekConfigCall<'a, C> {}
9290
9291impl<'a, C> ProjectLocationGetCmekConfigCall<'a, C>
9292where
9293 C: common::Connector,
9294{
9295 /// Perform the operation you have build so far.
9296 pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
9297 use std::borrow::Cow;
9298 use std::io::{Read, Seek};
9299
9300 use common::{url::Params, ToParts};
9301 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9302
9303 let mut dd = common::DefaultDelegate;
9304 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9305 dlg.begin(common::MethodInfo {
9306 id: "cloudtasks.projects.locations.getCmekConfig",
9307 http_method: hyper::Method::GET,
9308 });
9309
9310 for &field in ["alt", "name"].iter() {
9311 if self._additional_params.contains_key(field) {
9312 dlg.finished(false);
9313 return Err(common::Error::FieldClash(field));
9314 }
9315 }
9316
9317 let mut params = Params::with_capacity(3 + self._additional_params.len());
9318 params.push("name", self._name);
9319
9320 params.extend(self._additional_params.iter());
9321
9322 params.push("alt", "json");
9323 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
9324 if self._scopes.is_empty() {
9325 self._scopes
9326 .insert(Scope::CloudPlatform.as_ref().to_string());
9327 }
9328
9329 #[allow(clippy::single_element_loop)]
9330 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9331 url = params.uri_replacement(url, param_name, find_this, true);
9332 }
9333 {
9334 let to_remove = ["name"];
9335 params.remove_params(&to_remove);
9336 }
9337
9338 let url = params.parse_with_url(&url);
9339
9340 loop {
9341 let token = match self
9342 .hub
9343 .auth
9344 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9345 .await
9346 {
9347 Ok(token) => token,
9348 Err(e) => match dlg.token(e) {
9349 Ok(token) => token,
9350 Err(e) => {
9351 dlg.finished(false);
9352 return Err(common::Error::MissingToken(e));
9353 }
9354 },
9355 };
9356 let mut req_result = {
9357 let client = &self.hub.client;
9358 dlg.pre_request();
9359 let mut req_builder = hyper::Request::builder()
9360 .method(hyper::Method::GET)
9361 .uri(url.as_str())
9362 .header(USER_AGENT, self.hub._user_agent.clone());
9363
9364 if let Some(token) = token.as_ref() {
9365 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9366 }
9367
9368 let request = req_builder
9369 .header(CONTENT_LENGTH, 0_u64)
9370 .body(common::to_body::<String>(None));
9371
9372 client.request(request.unwrap()).await
9373 };
9374
9375 match req_result {
9376 Err(err) => {
9377 if let common::Retry::After(d) = dlg.http_error(&err) {
9378 sleep(d).await;
9379 continue;
9380 }
9381 dlg.finished(false);
9382 return Err(common::Error::HttpError(err));
9383 }
9384 Ok(res) => {
9385 let (mut parts, body) = res.into_parts();
9386 let mut body = common::Body::new(body);
9387 if !parts.status.is_success() {
9388 let bytes = common::to_bytes(body).await.unwrap_or_default();
9389 let error = serde_json::from_str(&common::to_string(&bytes));
9390 let response = common::to_response(parts, bytes.into());
9391
9392 if let common::Retry::After(d) =
9393 dlg.http_failure(&response, error.as_ref().ok())
9394 {
9395 sleep(d).await;
9396 continue;
9397 }
9398
9399 dlg.finished(false);
9400
9401 return Err(match error {
9402 Ok(value) => common::Error::BadRequest(value),
9403 _ => common::Error::Failure(response),
9404 });
9405 }
9406 let response = {
9407 let bytes = common::to_bytes(body).await.unwrap_or_default();
9408 let encoded = common::to_string(&bytes);
9409 match serde_json::from_str(&encoded) {
9410 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9411 Err(error) => {
9412 dlg.response_json_decode_error(&encoded, &error);
9413 return Err(common::Error::JsonDecodeError(
9414 encoded.to_string(),
9415 error,
9416 ));
9417 }
9418 }
9419 };
9420
9421 dlg.finished(true);
9422 return Ok(response);
9423 }
9424 }
9425 }
9426 }
9427
9428 /// Required. The config. For example: projects/PROJECT_ID/locations/LOCATION_ID/CmekConfig`
9429 ///
9430 /// Sets the *name* path property to the given value.
9431 ///
9432 /// Even though the property as already been set when instantiating this call,
9433 /// we provide this method for API completeness.
9434 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
9435 self._name = new_value.to_string();
9436 self
9437 }
9438 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9439 /// while executing the actual API request.
9440 ///
9441 /// ````text
9442 /// It should be used to handle progress information, and to implement a certain level of resilience.
9443 /// ````
9444 ///
9445 /// Sets the *delegate* property to the given value.
9446 pub fn delegate(
9447 mut self,
9448 new_value: &'a mut dyn common::Delegate,
9449 ) -> ProjectLocationGetCmekConfigCall<'a, C> {
9450 self._delegate = Some(new_value);
9451 self
9452 }
9453
9454 /// Set any additional parameter of the query string used in the request.
9455 /// It should be used to set parameters which are not yet available through their own
9456 /// setters.
9457 ///
9458 /// Please note that this method must not be used to set any of the known parameters
9459 /// which have their own setter method. If done anyway, the request will fail.
9460 ///
9461 /// # Additional Parameters
9462 ///
9463 /// * *$.xgafv* (query-string) - V1 error format.
9464 /// * *access_token* (query-string) - OAuth access token.
9465 /// * *alt* (query-string) - Data format for response.
9466 /// * *callback* (query-string) - JSONP
9467 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9468 /// * *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.
9469 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9470 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9471 /// * *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.
9472 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9473 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9474 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCmekConfigCall<'a, C>
9475 where
9476 T: AsRef<str>,
9477 {
9478 self._additional_params
9479 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9480 self
9481 }
9482
9483 /// Identifies the authorization scope for the method you are building.
9484 ///
9485 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9486 /// [`Scope::CloudPlatform`].
9487 ///
9488 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9489 /// tokens for more than one scope.
9490 ///
9491 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9492 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9493 /// sufficient, a read-write scope will do as well.
9494 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCmekConfigCall<'a, C>
9495 where
9496 St: AsRef<str>,
9497 {
9498 self._scopes.insert(String::from(scope.as_ref()));
9499 self
9500 }
9501 /// Identifies the authorization scope(s) for the method you are building.
9502 ///
9503 /// See [`Self::add_scope()`] for details.
9504 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCmekConfigCall<'a, C>
9505 where
9506 I: IntoIterator<Item = St>,
9507 St: AsRef<str>,
9508 {
9509 self._scopes
9510 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9511 self
9512 }
9513
9514 /// Removes all scopes, and no default scope will be used either.
9515 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9516 /// for details).
9517 pub fn clear_scopes(mut self) -> ProjectLocationGetCmekConfigCall<'a, C> {
9518 self._scopes.clear();
9519 self
9520 }
9521}
9522
9523/// Lists information about the supported locations for this service.
9524///
9525/// A builder for the *locations.list* method supported by a *project* resource.
9526/// It is not used directly, but through a [`ProjectMethods`] instance.
9527///
9528/// # Example
9529///
9530/// Instantiate a resource method builder
9531///
9532/// ```test_harness,no_run
9533/// # extern crate hyper;
9534/// # extern crate hyper_rustls;
9535/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
9536/// # async fn dox() {
9537/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9538///
9539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9540/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9541/// # secret,
9542/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9543/// # ).build().await.unwrap();
9544///
9545/// # let client = hyper_util::client::legacy::Client::builder(
9546/// # hyper_util::rt::TokioExecutor::new()
9547/// # )
9548/// # .build(
9549/// # hyper_rustls::HttpsConnectorBuilder::new()
9550/// # .with_native_roots()
9551/// # .unwrap()
9552/// # .https_or_http()
9553/// # .enable_http1()
9554/// # .build()
9555/// # );
9556/// # let mut hub = CloudTasks::new(client, auth);
9557/// // You can configure optional parameters by calling the respective setters at will, and
9558/// // execute the final call using `doit()`.
9559/// // Values shown here are possibly random and not representative !
9560/// let result = hub.projects().locations_list("name")
9561/// .page_token("eos")
9562/// .page_size(-86)
9563/// .filter("sed")
9564/// .doit().await;
9565/// # }
9566/// ```
9567pub struct ProjectLocationListCall<'a, C>
9568where
9569 C: 'a,
9570{
9571 hub: &'a CloudTasks<C>,
9572 _name: String,
9573 _page_token: Option<String>,
9574 _page_size: Option<i32>,
9575 _filter: Option<String>,
9576 _delegate: Option<&'a mut dyn common::Delegate>,
9577 _additional_params: HashMap<String, String>,
9578 _scopes: BTreeSet<String>,
9579}
9580
9581impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
9582
9583impl<'a, C> ProjectLocationListCall<'a, C>
9584where
9585 C: common::Connector,
9586{
9587 /// Perform the operation you have build so far.
9588 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
9589 use std::borrow::Cow;
9590 use std::io::{Read, Seek};
9591
9592 use common::{url::Params, ToParts};
9593 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9594
9595 let mut dd = common::DefaultDelegate;
9596 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9597 dlg.begin(common::MethodInfo {
9598 id: "cloudtasks.projects.locations.list",
9599 http_method: hyper::Method::GET,
9600 });
9601
9602 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
9603 if self._additional_params.contains_key(field) {
9604 dlg.finished(false);
9605 return Err(common::Error::FieldClash(field));
9606 }
9607 }
9608
9609 let mut params = Params::with_capacity(6 + self._additional_params.len());
9610 params.push("name", self._name);
9611 if let Some(value) = self._page_token.as_ref() {
9612 params.push("pageToken", value);
9613 }
9614 if let Some(value) = self._page_size.as_ref() {
9615 params.push("pageSize", value.to_string());
9616 }
9617 if let Some(value) = self._filter.as_ref() {
9618 params.push("filter", value);
9619 }
9620
9621 params.extend(self._additional_params.iter());
9622
9623 params.push("alt", "json");
9624 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}/locations";
9625 if self._scopes.is_empty() {
9626 self._scopes
9627 .insert(Scope::CloudPlatform.as_ref().to_string());
9628 }
9629
9630 #[allow(clippy::single_element_loop)]
9631 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9632 url = params.uri_replacement(url, param_name, find_this, true);
9633 }
9634 {
9635 let to_remove = ["name"];
9636 params.remove_params(&to_remove);
9637 }
9638
9639 let url = params.parse_with_url(&url);
9640
9641 loop {
9642 let token = match self
9643 .hub
9644 .auth
9645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9646 .await
9647 {
9648 Ok(token) => token,
9649 Err(e) => match dlg.token(e) {
9650 Ok(token) => token,
9651 Err(e) => {
9652 dlg.finished(false);
9653 return Err(common::Error::MissingToken(e));
9654 }
9655 },
9656 };
9657 let mut req_result = {
9658 let client = &self.hub.client;
9659 dlg.pre_request();
9660 let mut req_builder = hyper::Request::builder()
9661 .method(hyper::Method::GET)
9662 .uri(url.as_str())
9663 .header(USER_AGENT, self.hub._user_agent.clone());
9664
9665 if let Some(token) = token.as_ref() {
9666 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9667 }
9668
9669 let request = req_builder
9670 .header(CONTENT_LENGTH, 0_u64)
9671 .body(common::to_body::<String>(None));
9672
9673 client.request(request.unwrap()).await
9674 };
9675
9676 match req_result {
9677 Err(err) => {
9678 if let common::Retry::After(d) = dlg.http_error(&err) {
9679 sleep(d).await;
9680 continue;
9681 }
9682 dlg.finished(false);
9683 return Err(common::Error::HttpError(err));
9684 }
9685 Ok(res) => {
9686 let (mut parts, body) = res.into_parts();
9687 let mut body = common::Body::new(body);
9688 if !parts.status.is_success() {
9689 let bytes = common::to_bytes(body).await.unwrap_or_default();
9690 let error = serde_json::from_str(&common::to_string(&bytes));
9691 let response = common::to_response(parts, bytes.into());
9692
9693 if let common::Retry::After(d) =
9694 dlg.http_failure(&response, error.as_ref().ok())
9695 {
9696 sleep(d).await;
9697 continue;
9698 }
9699
9700 dlg.finished(false);
9701
9702 return Err(match error {
9703 Ok(value) => common::Error::BadRequest(value),
9704 _ => common::Error::Failure(response),
9705 });
9706 }
9707 let response = {
9708 let bytes = common::to_bytes(body).await.unwrap_or_default();
9709 let encoded = common::to_string(&bytes);
9710 match serde_json::from_str(&encoded) {
9711 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9712 Err(error) => {
9713 dlg.response_json_decode_error(&encoded, &error);
9714 return Err(common::Error::JsonDecodeError(
9715 encoded.to_string(),
9716 error,
9717 ));
9718 }
9719 }
9720 };
9721
9722 dlg.finished(true);
9723 return Ok(response);
9724 }
9725 }
9726 }
9727 }
9728
9729 /// The resource that owns the locations collection, if applicable.
9730 ///
9731 /// Sets the *name* path property to the given value.
9732 ///
9733 /// Even though the property as already been set when instantiating this call,
9734 /// we provide this method for API completeness.
9735 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
9736 self._name = new_value.to_string();
9737 self
9738 }
9739 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
9740 ///
9741 /// Sets the *page token* query property to the given value.
9742 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
9743 self._page_token = Some(new_value.to_string());
9744 self
9745 }
9746 /// The maximum number of results to return. If not set, the service selects a default.
9747 ///
9748 /// Sets the *page size* query property to the given value.
9749 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
9750 self._page_size = Some(new_value);
9751 self
9752 }
9753 /// 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).
9754 ///
9755 /// Sets the *filter* query property to the given value.
9756 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
9757 self._filter = Some(new_value.to_string());
9758 self
9759 }
9760 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9761 /// while executing the actual API request.
9762 ///
9763 /// ````text
9764 /// It should be used to handle progress information, and to implement a certain level of resilience.
9765 /// ````
9766 ///
9767 /// Sets the *delegate* property to the given value.
9768 pub fn delegate(
9769 mut self,
9770 new_value: &'a mut dyn common::Delegate,
9771 ) -> ProjectLocationListCall<'a, C> {
9772 self._delegate = Some(new_value);
9773 self
9774 }
9775
9776 /// Set any additional parameter of the query string used in the request.
9777 /// It should be used to set parameters which are not yet available through their own
9778 /// setters.
9779 ///
9780 /// Please note that this method must not be used to set any of the known parameters
9781 /// which have their own setter method. If done anyway, the request will fail.
9782 ///
9783 /// # Additional Parameters
9784 ///
9785 /// * *$.xgafv* (query-string) - V1 error format.
9786 /// * *access_token* (query-string) - OAuth access token.
9787 /// * *alt* (query-string) - Data format for response.
9788 /// * *callback* (query-string) - JSONP
9789 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9790 /// * *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.
9791 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9792 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9793 /// * *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.
9794 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9795 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9796 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
9797 where
9798 T: AsRef<str>,
9799 {
9800 self._additional_params
9801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9802 self
9803 }
9804
9805 /// Identifies the authorization scope for the method you are building.
9806 ///
9807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9808 /// [`Scope::CloudPlatform`].
9809 ///
9810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9811 /// tokens for more than one scope.
9812 ///
9813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9815 /// sufficient, a read-write scope will do as well.
9816 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
9817 where
9818 St: AsRef<str>,
9819 {
9820 self._scopes.insert(String::from(scope.as_ref()));
9821 self
9822 }
9823 /// Identifies the authorization scope(s) for the method you are building.
9824 ///
9825 /// See [`Self::add_scope()`] for details.
9826 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
9827 where
9828 I: IntoIterator<Item = St>,
9829 St: AsRef<str>,
9830 {
9831 self._scopes
9832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9833 self
9834 }
9835
9836 /// Removes all scopes, and no default scope will be used either.
9837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9838 /// for details).
9839 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
9840 self._scopes.clear();
9841 self
9842 }
9843}
9844
9845/// 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.
9846///
9847/// A builder for the *locations.updateCmekConfig* method supported by a *project* resource.
9848/// It is not used directly, but through a [`ProjectMethods`] instance.
9849///
9850/// # Example
9851///
9852/// Instantiate a resource method builder
9853///
9854/// ```test_harness,no_run
9855/// # extern crate hyper;
9856/// # extern crate hyper_rustls;
9857/// # extern crate google_cloudtasks2_beta2 as cloudtasks2_beta2;
9858/// use cloudtasks2_beta2::api::CmekConfig;
9859/// # async fn dox() {
9860/// # use cloudtasks2_beta2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9861///
9862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9864/// # secret,
9865/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9866/// # ).build().await.unwrap();
9867///
9868/// # let client = hyper_util::client::legacy::Client::builder(
9869/// # hyper_util::rt::TokioExecutor::new()
9870/// # )
9871/// # .build(
9872/// # hyper_rustls::HttpsConnectorBuilder::new()
9873/// # .with_native_roots()
9874/// # .unwrap()
9875/// # .https_or_http()
9876/// # .enable_http1()
9877/// # .build()
9878/// # );
9879/// # let mut hub = CloudTasks::new(client, auth);
9880/// // As the method needs a request, you would usually fill it with the desired information
9881/// // into the respective structure. Some of the parts shown here might not be applicable !
9882/// // Values shown here are possibly random and not representative !
9883/// let mut req = CmekConfig::default();
9884///
9885/// // You can configure optional parameters by calling the respective setters at will, and
9886/// // execute the final call using `doit()`.
9887/// // Values shown here are possibly random and not representative !
9888/// let result = hub.projects().locations_update_cmek_config(req, "name")
9889/// .update_mask(FieldMask::new::<&str>(&[]))
9890/// .doit().await;
9891/// # }
9892/// ```
9893pub struct ProjectLocationUpdateCmekConfigCall<'a, C>
9894where
9895 C: 'a,
9896{
9897 hub: &'a CloudTasks<C>,
9898 _request: CmekConfig,
9899 _name: String,
9900 _update_mask: Option<common::FieldMask>,
9901 _delegate: Option<&'a mut dyn common::Delegate>,
9902 _additional_params: HashMap<String, String>,
9903 _scopes: BTreeSet<String>,
9904}
9905
9906impl<'a, C> common::CallBuilder for ProjectLocationUpdateCmekConfigCall<'a, C> {}
9907
9908impl<'a, C> ProjectLocationUpdateCmekConfigCall<'a, C>
9909where
9910 C: common::Connector,
9911{
9912 /// Perform the operation you have build so far.
9913 pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
9914 use std::borrow::Cow;
9915 use std::io::{Read, Seek};
9916
9917 use common::{url::Params, ToParts};
9918 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9919
9920 let mut dd = common::DefaultDelegate;
9921 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9922 dlg.begin(common::MethodInfo {
9923 id: "cloudtasks.projects.locations.updateCmekConfig",
9924 http_method: hyper::Method::PATCH,
9925 });
9926
9927 for &field in ["alt", "name", "updateMask"].iter() {
9928 if self._additional_params.contains_key(field) {
9929 dlg.finished(false);
9930 return Err(common::Error::FieldClash(field));
9931 }
9932 }
9933
9934 let mut params = Params::with_capacity(5 + self._additional_params.len());
9935 params.push("name", self._name);
9936 if let Some(value) = self._update_mask.as_ref() {
9937 params.push("updateMask", value.to_string());
9938 }
9939
9940 params.extend(self._additional_params.iter());
9941
9942 params.push("alt", "json");
9943 let mut url = self.hub._base_url.clone() + "v2beta2/{+name}";
9944 if self._scopes.is_empty() {
9945 self._scopes
9946 .insert(Scope::CloudPlatform.as_ref().to_string());
9947 }
9948
9949 #[allow(clippy::single_element_loop)]
9950 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9951 url = params.uri_replacement(url, param_name, find_this, true);
9952 }
9953 {
9954 let to_remove = ["name"];
9955 params.remove_params(&to_remove);
9956 }
9957
9958 let url = params.parse_with_url(&url);
9959
9960 let mut json_mime_type = mime::APPLICATION_JSON;
9961 let mut request_value_reader = {
9962 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9963 common::remove_json_null_values(&mut value);
9964 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9965 serde_json::to_writer(&mut dst, &value).unwrap();
9966 dst
9967 };
9968 let request_size = request_value_reader
9969 .seek(std::io::SeekFrom::End(0))
9970 .unwrap();
9971 request_value_reader
9972 .seek(std::io::SeekFrom::Start(0))
9973 .unwrap();
9974
9975 loop {
9976 let token = match self
9977 .hub
9978 .auth
9979 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9980 .await
9981 {
9982 Ok(token) => token,
9983 Err(e) => match dlg.token(e) {
9984 Ok(token) => token,
9985 Err(e) => {
9986 dlg.finished(false);
9987 return Err(common::Error::MissingToken(e));
9988 }
9989 },
9990 };
9991 request_value_reader
9992 .seek(std::io::SeekFrom::Start(0))
9993 .unwrap();
9994 let mut req_result = {
9995 let client = &self.hub.client;
9996 dlg.pre_request();
9997 let mut req_builder = hyper::Request::builder()
9998 .method(hyper::Method::PATCH)
9999 .uri(url.as_str())
10000 .header(USER_AGENT, self.hub._user_agent.clone());
10001
10002 if let Some(token) = token.as_ref() {
10003 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10004 }
10005
10006 let request = req_builder
10007 .header(CONTENT_TYPE, json_mime_type.to_string())
10008 .header(CONTENT_LENGTH, request_size as u64)
10009 .body(common::to_body(
10010 request_value_reader.get_ref().clone().into(),
10011 ));
10012
10013 client.request(request.unwrap()).await
10014 };
10015
10016 match req_result {
10017 Err(err) => {
10018 if let common::Retry::After(d) = dlg.http_error(&err) {
10019 sleep(d).await;
10020 continue;
10021 }
10022 dlg.finished(false);
10023 return Err(common::Error::HttpError(err));
10024 }
10025 Ok(res) => {
10026 let (mut parts, body) = res.into_parts();
10027 let mut body = common::Body::new(body);
10028 if !parts.status.is_success() {
10029 let bytes = common::to_bytes(body).await.unwrap_or_default();
10030 let error = serde_json::from_str(&common::to_string(&bytes));
10031 let response = common::to_response(parts, bytes.into());
10032
10033 if let common::Retry::After(d) =
10034 dlg.http_failure(&response, error.as_ref().ok())
10035 {
10036 sleep(d).await;
10037 continue;
10038 }
10039
10040 dlg.finished(false);
10041
10042 return Err(match error {
10043 Ok(value) => common::Error::BadRequest(value),
10044 _ => common::Error::Failure(response),
10045 });
10046 }
10047 let response = {
10048 let bytes = common::to_bytes(body).await.unwrap_or_default();
10049 let encoded = common::to_string(&bytes);
10050 match serde_json::from_str(&encoded) {
10051 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10052 Err(error) => {
10053 dlg.response_json_decode_error(&encoded, &error);
10054 return Err(common::Error::JsonDecodeError(
10055 encoded.to_string(),
10056 error,
10057 ));
10058 }
10059 }
10060 };
10061
10062 dlg.finished(true);
10063 return Ok(response);
10064 }
10065 }
10066 }
10067 }
10068
10069 ///
10070 /// Sets the *request* property to the given value.
10071 ///
10072 /// Even though the property as already been set when instantiating this call,
10073 /// we provide this method for API completeness.
10074 pub fn request(mut self, new_value: CmekConfig) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10075 self._request = new_value;
10076 self
10077 }
10078 /// 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`
10079 ///
10080 /// Sets the *name* path property to the given value.
10081 ///
10082 /// Even though the property as already been set when instantiating this call,
10083 /// we provide this method for API completeness.
10084 pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10085 self._name = new_value.to_string();
10086 self
10087 }
10088 /// List of fields to be updated in this request.
10089 ///
10090 /// Sets the *update mask* query property to the given value.
10091 pub fn update_mask(
10092 mut self,
10093 new_value: common::FieldMask,
10094 ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10095 self._update_mask = Some(new_value);
10096 self
10097 }
10098 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10099 /// while executing the actual API request.
10100 ///
10101 /// ````text
10102 /// It should be used to handle progress information, and to implement a certain level of resilience.
10103 /// ````
10104 ///
10105 /// Sets the *delegate* property to the given value.
10106 pub fn delegate(
10107 mut self,
10108 new_value: &'a mut dyn common::Delegate,
10109 ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10110 self._delegate = Some(new_value);
10111 self
10112 }
10113
10114 /// Set any additional parameter of the query string used in the request.
10115 /// It should be used to set parameters which are not yet available through their own
10116 /// setters.
10117 ///
10118 /// Please note that this method must not be used to set any of the known parameters
10119 /// which have their own setter method. If done anyway, the request will fail.
10120 ///
10121 /// # Additional Parameters
10122 ///
10123 /// * *$.xgafv* (query-string) - V1 error format.
10124 /// * *access_token* (query-string) - OAuth access token.
10125 /// * *alt* (query-string) - Data format for response.
10126 /// * *callback* (query-string) - JSONP
10127 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10128 /// * *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.
10129 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10130 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10131 /// * *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.
10132 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10133 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10134 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateCmekConfigCall<'a, C>
10135 where
10136 T: AsRef<str>,
10137 {
10138 self._additional_params
10139 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10140 self
10141 }
10142
10143 /// Identifies the authorization scope for the method you are building.
10144 ///
10145 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10146 /// [`Scope::CloudPlatform`].
10147 ///
10148 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10149 /// tokens for more than one scope.
10150 ///
10151 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10152 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10153 /// sufficient, a read-write scope will do as well.
10154 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateCmekConfigCall<'a, C>
10155 where
10156 St: AsRef<str>,
10157 {
10158 self._scopes.insert(String::from(scope.as_ref()));
10159 self
10160 }
10161 /// Identifies the authorization scope(s) for the method you are building.
10162 ///
10163 /// See [`Self::add_scope()`] for details.
10164 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateCmekConfigCall<'a, C>
10165 where
10166 I: IntoIterator<Item = St>,
10167 St: AsRef<str>,
10168 {
10169 self._scopes
10170 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10171 self
10172 }
10173
10174 /// Removes all scopes, and no default scope will be used either.
10175 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10176 /// for details).
10177 pub fn clear_scopes(mut self) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
10178 self._scopes.clear();
10179 self
10180 }
10181}