google_cloudtasks2/
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 as cloudtasks2;
49/// use cloudtasks2::api::Queue;
50/// use cloudtasks2::{Result, Error};
51/// # async fn dox() {
52/// use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = CloudTasks::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Queue::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_queues_patch(req, "name")
99///              .update_mask(FieldMask::new::<&str>(&[]))
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct CloudTasks<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for CloudTasks<C> {}
131
132impl<'a, C> CloudTasks<C> {
133    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudTasks<C> {
134        CloudTasks {
135            client,
136            auth: Box::new(auth),
137            _user_agent: "google-api-rust-client/7.0.0".to_string(),
138            _base_url: "https://cloudtasks.googleapis.com/".to_string(),
139            _root_url: "https://cloudtasks.googleapis.com/".to_string(),
140        }
141    }
142
143    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
144        ProjectMethods { hub: self }
145    }
146
147    /// Set the user-agent header field to use in all requests to the server.
148    /// It defaults to `google-api-rust-client/7.0.0`.
149    ///
150    /// Returns the previously set user-agent.
151    pub fn user_agent(&mut self, agent_name: String) -> String {
152        std::mem::replace(&mut self._user_agent, agent_name)
153    }
154
155    /// Set the base url to use in all requests to the server.
156    /// It defaults to `https://cloudtasks.googleapis.com/`.
157    ///
158    /// Returns the previously set base url.
159    pub fn base_url(&mut self, new_base_url: String) -> String {
160        std::mem::replace(&mut self._base_url, new_base_url)
161    }
162
163    /// Set the root url to use in all requests to the server.
164    /// It defaults to `https://cloudtasks.googleapis.com/`.
165    ///
166    /// Returns the previously set root url.
167    pub fn root_url(&mut self, new_root_url: String) -> String {
168        std::mem::replace(&mut self._root_url, new_root_url)
169    }
170}
171
172// ############
173// SCHEMAS ###
174// ##########
175/// App Engine HTTP request. The message defines the HTTP request that is sent to an App Engine app when the task is dispatched. 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 app_engine_routing_override is set on the queue, this value 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_uri 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.
176///
177/// This type is not used in any activity, and only used as *part* of another schema.
178///
179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
180#[serde_with::serde_as]
181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
182pub struct AppEngineHttpRequest {
183    /// Task-level setting for App Engine routing. * If app_engine_routing_override is set on the queue, this value is used for all tasks in the queue, no matter what the setting is for the task-level app_engine_routing.
184    #[serde(rename = "appEngineRouting")]
185    pub app_engine_routing: Option<AppEngineRouting>,
186    /// HTTP request body. A request body is allowed only if the HTTP method is POST or PUT. It is an error to set a body on a task with an incompatible HttpMethod.
187    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
188    pub body: Option<Vec<u8>>,
189    /// 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 body, 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/tasks/docs/creating-appengine-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.
190    pub headers: Option<HashMap<String, String>>,
191    /// 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).
192    #[serde(rename = "httpMethod")]
193    pub http_method: Option<String>,
194    /// The relative URI. The relative URI must begin with "/" and must be a valid HTTP relative URI. It can contain a path and query string arguments. If the relative URI is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters.
195    #[serde(rename = "relativeUri")]
196    pub relative_uri: Option<String>,
197}
198
199impl common::Part for AppEngineHttpRequest {}
200
201/// 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). Using AppEngineRouting 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`
202///
203/// This type is not used in any activity, and only used as *part* of another schema.
204///
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct AppEngineRouting {
209    /// Output only. The host that the task is sent to. The host is constructed from the domain name of the app associated with the queue's project ID (for example .appspot.com), and the service, version, and instance. Tasks which were created using the App Engine SDK might have a custom domain name. For more information, see [How Requests are Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed).
210    pub host: Option<String>,
211    /// 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).
212    pub instance: Option<String>,
213    /// 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.
214    pub service: Option<String>,
215    /// 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.
216    pub version: Option<String>,
217}
218
219impl common::Part for AppEngineRouting {}
220
221/// The status of a task attempt.
222///
223/// This type is not used in any activity, and only used as *part* of another schema.
224///
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct Attempt {
229    /// Output only. The time that this attempt was dispatched. `dispatch_time` will be truncated to the nearest microsecond.
230    #[serde(rename = "dispatchTime")]
231    pub dispatch_time: Option<chrono::DateTime<chrono::offset::Utc>>,
232    /// Output only. The response from the worker for this attempt. If `response_time` is unset, then the task has not been attempted or is currently running and the `response_status` field is meaningless.
233    #[serde(rename = "responseStatus")]
234    pub response_status: Option<Status>,
235    /// Output only. The time that this attempt response was received. `response_time` will be truncated to the nearest microsecond.
236    #[serde(rename = "responseTime")]
237    pub response_time: Option<chrono::DateTime<chrono::offset::Utc>>,
238    /// Output only. The time that this attempt was scheduled. `schedule_time` will be truncated to the nearest microsecond.
239    #[serde(rename = "scheduleTime")]
240    pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
241}
242
243impl common::Part for Attempt {}
244
245/// Associates `members`, or principals, with a `role`.
246///
247/// This type is not used in any activity, and only used as *part* of another schema.
248///
249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
250#[serde_with::serde_as]
251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
252pub struct Binding {
253    /// 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).
254    pub condition: Option<Expr>,
255    /// 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`.
256    pub members: Option<Vec<String>>,
257    /// 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).
258    pub role: Option<String>,
259}
260
261impl common::Part for Binding {}
262
263/// Request message for BufferTask.
264///
265/// # Activities
266///
267/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
268/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
269///
270/// * [locations queues tasks buffer projects](ProjectLocationQueueTaskBufferCall) (request)
271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
272#[serde_with::serde_as]
273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
274pub struct BufferTaskRequest {
275    /// Optional. Body of the HTTP request. The body can take any generic value. The value is written to the HttpRequest of the [Task].
276    pub body: Option<HttpBody>,
277}
278
279impl common::RequestValue for BufferTaskRequest {}
280
281/// Response message for BufferTask.
282///
283/// # Activities
284///
285/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
286/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
287///
288/// * [locations queues tasks buffer projects](ProjectLocationQueueTaskBufferCall) (response)
289#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
290#[serde_with::serde_as]
291#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
292pub struct BufferTaskResponse {
293    /// The created task.
294    pub task: Option<Task>,
295}
296
297impl common::ResponseResult for BufferTaskResponse {}
298
299/// Describes the customer-managed encryption key (CMEK) configuration associated with a project and location.
300///
301/// # Activities
302///
303/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
304/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
305///
306/// * [locations get cmek config projects](ProjectLocationGetCmekConfigCall) (response)
307/// * [locations update cmek config projects](ProjectLocationUpdateCmekConfigCall) (request|response)
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct CmekConfig {
312    /// 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.
313    #[serde(rename = "kmsKey")]
314    pub kms_key: Option<String>,
315    /// 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`
316    pub name: Option<String>,
317}
318
319impl common::RequestValue for CmekConfig {}
320impl common::ResponseResult for CmekConfig {}
321
322/// Request message for CreateTask.
323///
324/// # Activities
325///
326/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
327/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
328///
329/// * [locations queues tasks create projects](ProjectLocationQueueTaskCreateCall) (request)
330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
331#[serde_with::serde_as]
332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
333pub struct CreateTaskRequest {
334    /// 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.
335    #[serde(rename = "responseView")]
336    pub response_view: Option<String>,
337    /// 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 executed recently then the call will fail with ALREADY_EXISTS. The IDs of deleted tasks are not immediately available for reuse. It can take up to 24 hours (or 9 days if the task's queue was created using a queue.yaml or queue.xml) for the task ID to be released and made available again. Because there is an extra lookup cost to identify duplicate task names, these CreateTask calls have significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and serve tasks efficiently.
338    pub task: Option<Task>,
339}
340
341impl common::RequestValue for CreateTaskRequest {}
342
343/// 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); }
344///
345/// # Activities
346///
347/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
348/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
349///
350/// * [locations queues tasks delete projects](ProjectLocationQueueTaskDeleteCall) (response)
351/// * [locations queues delete projects](ProjectLocationQueueDeleteCall) (response)
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct Empty {
356    _never_set: Option<bool>,
357}
358
359impl common::ResponseResult for Empty {}
360
361/// 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.
362///
363/// This type is not used in any activity, and only used as *part* of another schema.
364///
365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
366#[serde_with::serde_as]
367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
368pub struct Expr {
369    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
370    pub description: Option<String>,
371    /// Textual representation of an expression in Common Expression Language syntax.
372    pub expression: Option<String>,
373    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
374    pub location: Option<String>,
375    /// 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.
376    pub title: Option<String>,
377}
378
379impl common::Part for Expr {}
380
381/// Request message for `GetIamPolicy` method.
382///
383/// # Activities
384///
385/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
386/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
387///
388/// * [locations queues get iam policy projects](ProjectLocationQueueGetIamPolicyCall) (request)
389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
390#[serde_with::serde_as]
391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
392pub struct GetIamPolicyRequest {
393    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
394    pub options: Option<GetPolicyOptions>,
395}
396
397impl common::RequestValue for GetIamPolicyRequest {}
398
399/// Encapsulates settings provided to GetIamPolicy.
400///
401/// This type is not used in any activity, and only used as *part* of another schema.
402///
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct GetPolicyOptions {
407    /// 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).
408    #[serde(rename = "requestedPolicyVersion")]
409    pub requested_policy_version: Option<i32>,
410}
411
412impl common::Part for GetPolicyOptions {}
413
414/// Defines a header message. A header can have a key and a value.
415///
416/// This type is not used in any activity, and only used as *part* of another schema.
417///
418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
419#[serde_with::serde_as]
420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
421pub struct Header {
422    /// The Key of the header.
423    pub key: Option<String>,
424    /// The Value of the header.
425    pub value: Option<String>,
426}
427
428impl common::Part for Header {}
429
430/// Wraps the Header object.
431///
432/// This type is not used in any activity, and only used as *part* of another schema.
433///
434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
435#[serde_with::serde_as]
436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
437pub struct HeaderOverride {
438    /// 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).
439    pub header: Option<Header>,
440}
441
442impl common::Part for HeaderOverride {}
443
444/// 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.
445///
446/// This type is not used in any activity, and only used as *part* of another schema.
447///
448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
449#[serde_with::serde_as]
450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
451pub struct HttpBody {
452    /// The HTTP Content-Type header value specifying the content type of the body.
453    #[serde(rename = "contentType")]
454    pub content_type: Option<String>,
455    /// The HTTP request/response body as raw binary.
456    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
457    pub data: Option<Vec<u8>>,
458    /// Application specific response metadata. Must be set in the first response for streaming APIs.
459    pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
460}
461
462impl common::Part for HttpBody {}
463
464/// HTTP request. The task will be pushed to the worker as an HTTP request. If the worker or the redirected worker acknowledges the task by returning a successful HTTP response code ([`200` - `299`]), the task will be removed from the queue. If any other HTTP response code is returned or no response is received, the task will be retried according to the following: * User-specified throttling: retry configuration, rate limits, and the queue's state. * System throttling: To prevent the worker from overloading, Cloud Tasks may temporarily reduce the queue's effective rate. User-specified settings will not be changed. System throttling happens because: * Cloud Tasks backs off on all errors. Normally the backoff specified in rate limits will be used. But if the worker returns `429` (Too Many Requests), `503` (Service Unavailable), or the rate of errors is high, Cloud Tasks will use a higher backoff rate. The retry specified in the `Retry-After` HTTP response header is considered. * To prevent traffic spikes and to smooth sudden increases in traffic, dispatches ramp up slowly when the queue is newly created or idle and if large numbers of tasks suddenly become available to dispatch (due to spikes in create task rates, the queue being unpaused, or many tasks that are scheduled at the same time).
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 HttpRequest {
472    /// 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.
473    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
474    pub body: Option<Vec<u8>>,
475    /// HTTP request headers. This map contains the header field names and values. Headers can be set when the 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: * 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.
476    pub headers: Option<HashMap<String, String>>,
477    /// The HTTP method to use for the request. The default is POST.
478    #[serde(rename = "httpMethod")]
479    pub http_method: Option<String>,
480    /// 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.
481    #[serde(rename = "oauthToken")]
482    pub oauth_token: Option<OAuthToken>,
483    /// 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.
484    #[serde(rename = "oidcToken")]
485    pub oidc_token: Option<OidcToken>,
486    /// 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.
487    pub url: Option<String>,
488}
489
490impl common::Part for HttpRequest {}
491
492/// HTTP target. When specified as a Queue, all the tasks with [HttpRequest] will be overridden according to the target.
493///
494/// This type is not used in any activity, and only used as *part* of another schema.
495///
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct HttpTarget {
500    /// HTTP target headers. This map contains the header field names and values. Headers will be set when running the CreateTask and/or BufferTask. These headers represent a subset of the headers that will be configured for 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: * Several predefined headers, prefixed with "X-CloudTasks-", can be used to define properties of the task. * Host: This will be computed by Cloud Tasks and derived from HttpRequest.url. * Content-Length: This will be computed by Cloud Tasks. `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"`. The default value is set to "application/json"`. * User-Agent: This will be set to `"Google-Cloud-Tasks"`. 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).
501    #[serde(rename = "headerOverrides")]
502    pub header_overrides: Option<Vec<HeaderOverride>>,
503    /// 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.
504    #[serde(rename = "httpMethod")]
505    pub http_method: Option<String>,
506    /// If specified, an [OAuth token](https://developers.google.com/identity/protocols/OAuth2) is generated and attached as the `Authorization` header in the HTTP request. This type of authorization should generally be used only when calling Google APIs hosted on *.googleapis.com. Note that both the service account email and the scope MUST be specified when using the queue-level authorization override.
507    #[serde(rename = "oauthToken")]
508    pub oauth_token: Option<OAuthToken>,
509    /// If specified, an [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) token is generated and attached as an `Authorization` header in the HTTP request. This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself. Note that both the service account email and the audience MUST be specified when using the queue-level authorization override.
510    #[serde(rename = "oidcToken")]
511    pub oidc_token: Option<OidcToken>,
512    /// URI override. When specified, overrides the execution URI for all the tasks in the queue.
513    #[serde(rename = "uriOverride")]
514    pub uri_override: Option<UriOverride>,
515}
516
517impl common::Part for HttpTarget {}
518
519/// The response message for Locations.ListLocations.
520///
521/// # Activities
522///
523/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
524/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
525///
526/// * [locations list projects](ProjectLocationListCall) (response)
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct ListLocationsResponse {
531    /// A list of locations that matches the specified filter in the request.
532    pub locations: Option<Vec<Location>>,
533    /// The standard List next-page token.
534    #[serde(rename = "nextPageToken")]
535    pub next_page_token: Option<String>,
536}
537
538impl common::ResponseResult for ListLocationsResponse {}
539
540/// Response message for ListQueues.
541///
542/// # Activities
543///
544/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
545/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
546///
547/// * [locations queues list projects](ProjectLocationQueueListCall) (response)
548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
549#[serde_with::serde_as]
550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
551pub struct ListQueuesResponse {
552    /// 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.
553    #[serde(rename = "nextPageToken")]
554    pub next_page_token: Option<String>,
555    /// The list of queues.
556    pub queues: Option<Vec<Queue>>,
557}
558
559impl common::ResponseResult for ListQueuesResponse {}
560
561/// Response message for listing tasks using ListTasks.
562///
563/// # Activities
564///
565/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
566/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
567///
568/// * [locations queues tasks list projects](ProjectLocationQueueTaskListCall) (response)
569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
570#[serde_with::serde_as]
571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
572pub struct ListTasksResponse {
573    /// 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.
574    #[serde(rename = "nextPageToken")]
575    pub next_page_token: Option<String>,
576    /// The list of tasks.
577    pub tasks: Option<Vec<Task>>,
578}
579
580impl common::ResponseResult for ListTasksResponse {}
581
582/// A resource that represents a Google Cloud location.
583///
584/// # Activities
585///
586/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
587/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
588///
589/// * [locations get projects](ProjectLocationGetCall) (response)
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct Location {
594    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
595    #[serde(rename = "displayName")]
596    pub display_name: Option<String>,
597    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
598    pub labels: Option<HashMap<String, String>>,
599    /// The canonical id for this location. For example: `"us-east1"`.
600    #[serde(rename = "locationId")]
601    pub location_id: Option<String>,
602    /// Service-specific metadata. For example the available capacity at the given location.
603    pub metadata: Option<HashMap<String, serde_json::Value>>,
604    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
605    pub name: Option<String>,
606}
607
608impl common::ResponseResult for Location {}
609
610/// 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.
611///
612/// This type is not used in any activity, and only used as *part* of another schema.
613///
614#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
615#[serde_with::serde_as]
616#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
617pub struct OAuthToken {
618    /// OAuth scope to be used for generating OAuth access token. If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used.
619    pub scope: Option<String>,
620    /// [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.
621    #[serde(rename = "serviceAccountEmail")]
622    pub service_account_email: Option<String>,
623}
624
625impl common::Part for OAuthToken {}
626
627/// 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.
628///
629/// This type is not used in any activity, and only used as *part* of another schema.
630///
631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
632#[serde_with::serde_as]
633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
634pub struct OidcToken {
635    /// Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used.
636    pub audience: Option<String>,
637    /// [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.
638    #[serde(rename = "serviceAccountEmail")]
639    pub service_account_email: Option<String>,
640}
641
642impl common::Part for OidcToken {}
643
644/// PathOverride. Path message defines path override for HTTP targets.
645///
646/// This type is not used in any activity, and only used as *part* of another schema.
647///
648#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
649#[serde_with::serde_as]
650#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
651pub struct PathOverride {
652    /// The URI path (e.g., /users/1234). Default is an empty string.
653    pub path: Option<String>,
654}
655
656impl common::Part for PathOverride {}
657
658/// Request message for PauseQueue.
659///
660/// # Activities
661///
662/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
663/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
664///
665/// * [locations queues pause projects](ProjectLocationQueuePauseCall) (request)
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct PauseQueueRequest {
670    _never_set: Option<bool>,
671}
672
673impl common::RequestValue for PauseQueueRequest {}
674
675/// 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/).
676///
677/// # Activities
678///
679/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
680/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
681///
682/// * [locations queues get iam policy projects](ProjectLocationQueueGetIamPolicyCall) (response)
683/// * [locations queues set iam policy projects](ProjectLocationQueueSetIamPolicyCall) (response)
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct Policy {
688    /// 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`.
689    pub bindings: Option<Vec<Binding>>,
690    /// `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.
691    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
692    pub etag: Option<Vec<u8>>,
693    /// 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).
694    pub version: Option<i32>,
695}
696
697impl common::ResponseResult for Policy {}
698
699/// Request message for PurgeQueue.
700///
701/// # Activities
702///
703/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
704/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
705///
706/// * [locations queues purge projects](ProjectLocationQueuePurgeCall) (request)
707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
708#[serde_with::serde_as]
709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
710pub struct PurgeQueueRequest {
711    _never_set: Option<bool>,
712}
713
714impl common::RequestValue for PurgeQueueRequest {}
715
716/// QueryOverride. Query message defines query override for HTTP targets.
717///
718/// This type is not used in any activity, and only used as *part* of another schema.
719///
720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
721#[serde_with::serde_as]
722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
723pub struct QueryOverride {
724    /// The query parameters (e.g., qparam1=123&qparam2=456). Default is an empty string.
725    #[serde(rename = "queryParams")]
726    pub query_params: Option<String>,
727}
728
729impl common::Part for QueryOverride {}
730
731/// 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, queue types, and others.
732///
733/// # Activities
734///
735/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
736/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
737///
738/// * [locations queues create projects](ProjectLocationQueueCreateCall) (request|response)
739/// * [locations queues get projects](ProjectLocationQueueGetCall) (response)
740/// * [locations queues patch projects](ProjectLocationQueuePatchCall) (request|response)
741/// * [locations queues pause projects](ProjectLocationQueuePauseCall) (response)
742/// * [locations queues purge projects](ProjectLocationQueuePurgeCall) (response)
743/// * [locations queues resume projects](ProjectLocationQueueResumeCall) (response)
744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
745#[serde_with::serde_as]
746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
747pub struct Queue {
748    /// Overrides for task-level app_engine_routing. These settings apply only to App Engine tasks in this queue. Http tasks are not affected. If set, `app_engine_routing_override` is used for all App Engine tasks in the queue, no matter what the setting is for the task-level app_engine_routing.
749    #[serde(rename = "appEngineRoutingOverride")]
750    pub app_engine_routing_override: Option<AppEngineRouting>,
751    /// Modifies HTTP target for HTTP tasks.
752    #[serde(rename = "httpTarget")]
753    pub http_target: Option<HttpTarget>,
754    /// 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.
755    pub name: Option<String>,
756    /// 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.
757    #[serde(rename = "purgeTime")]
758    pub purge_time: Option<chrono::DateTime<chrono::offset::Utc>>,
759    /// Rate limits for task dispatches. rate_limits and retry_config are related because they both control task attempts. However they control task attempts 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). The queue's actual dispatch rate is the result of: * Number of tasks in the queue * User-specified throttling: rate_limits, retry_config, and the queue's state. * System throttling due to `429` (Too Many Requests) or `503` (Service Unavailable) responses from the worker, high error rates, or to smooth sudden large traffic spikes.
760    #[serde(rename = "rateLimits")]
761    pub rate_limits: Option<RateLimits>,
762    /// 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).
763    #[serde(rename = "retryConfig")]
764    pub retry_config: Option<RetryConfig>,
765    /// Configuration options for writing logs to [Stackdriver Logging](https://cloud.google.com/logging/docs/). If this field is unset, then no logs are written.
766    #[serde(rename = "stackdriverLoggingConfig")]
767    pub stackdriver_logging_config: Option<StackdriverLoggingConfig>,
768    /// Output only. The state of the queue. `state` can only be changed by calling PauseQueue, ResumeQueue, or uploading [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref). UpdateQueue cannot be used to change `state`.
769    pub state: Option<String>,
770}
771
772impl common::RequestValue for Queue {}
773impl common::ResponseResult for Queue {}
774
775/// 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.
776///
777/// This type is not used in any activity, and only used as *part* of another schema.
778///
779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
780#[serde_with::serde_as]
781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
782pub struct RateLimits {
783    /// Output only. 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. Cloud Tasks will pick the value of `max_burst_size` based on the value of max_dispatches_per_second. For 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). Since `max_burst_size` is output only, if UpdateQueue is called on a queue created by `queue.yaml/xml`, `max_burst_size` will be reset based on the value of max_dispatches_per_second, regardless of whether max_dispatches_per_second is updated.
784    #[serde(rename = "maxBurstSize")]
785    pub max_burst_size: Option<i32>,
786    /// 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 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).
787    #[serde(rename = "maxConcurrentDispatches")]
788    pub max_concurrent_dispatches: Option<i32>,
789    /// The maximum rate at which tasks are dispatched from this queue. If unspecified when the queue is created, Cloud Tasks will pick the default. * The maximum allowed value is 500. This field has the same meaning as [rate in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate).
790    #[serde(rename = "maxDispatchesPerSecond")]
791    pub max_dispatches_per_second: Option<f64>,
792}
793
794impl common::Part for RateLimits {}
795
796/// Request message for ResumeQueue.
797///
798/// # Activities
799///
800/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
801/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
802///
803/// * [locations queues resume projects](ProjectLocationQueueResumeCall) (request)
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct ResumeQueueRequest {
808    _never_set: Option<bool>,
809}
810
811impl common::RequestValue for ResumeQueueRequest {}
812
813/// Retry config. These settings determine when a failed task attempt is retried.
814///
815/// This type is not used in any activity, and only used as *part* of another schema.
816///
817#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
818#[serde_with::serde_as]
819#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
820pub struct RetryConfig {
821    /// Number of attempts per 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 >= -1. If unspecified when the queue is created, Cloud Tasks will pick the default. -1 indicates unlimited attempts. This field has the same meaning as [task_retry_limit in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters). Note: Cloud Tasks stops retrying only when `max_attempts` and `max_retry_duration` are both satisfied. When the task has been attempted `max_attempts` times and when the `max_retry_duration` time has passed, no further attempts are made, and the task is deleted. If you want your task to retry infinitely, you must set `max_attempts` to -1 and `max_retry_duration` to 0.
822    #[serde(rename = "maxAttempts")]
823    pub max_attempts: Option<i32>,
824    /// 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. The value must be given as a string that indicates the length of time (in seconds) followed by `s` (for "seconds"). For more information on the format, see the documentation for [Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration). `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).
825    #[serde(rename = "maxBackoff")]
826    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
827    pub max_backoff: Option<chrono::Duration>,
828    /// 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 has the same meaning as [max_doublings in queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
829    #[serde(rename = "maxDoublings")]
830    pub max_doublings: Option<i32>,
831    /// 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. The value must be given as a string that indicates the length of time (in seconds) followed by `s` (for "seconds"). For the maximum possible value or the format, see the documentation for [Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration). `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).
832    #[serde(rename = "maxRetryDuration")]
833    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
834    pub max_retry_duration: Option<chrono::Duration>,
835    /// 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. The value must be given as a string that indicates the length of time (in seconds) followed by `s` (for "seconds"). For more information on the format, see the documentation for [Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration). `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).
836    #[serde(rename = "minBackoff")]
837    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
838    pub min_backoff: Option<chrono::Duration>,
839}
840
841impl common::Part for RetryConfig {}
842
843/// Request message for forcing a task to run now using RunTask.
844///
845/// # Activities
846///
847/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
848/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
849///
850/// * [locations queues tasks run projects](ProjectLocationQueueTaskRunCall) (request)
851#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
852#[serde_with::serde_as]
853#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
854pub struct RunTaskRequest {
855    /// 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.
856    #[serde(rename = "responseView")]
857    pub response_view: Option<String>,
858}
859
860impl common::RequestValue for RunTaskRequest {}
861
862/// Request message for `SetIamPolicy` method.
863///
864/// # Activities
865///
866/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
867/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
868///
869/// * [locations queues set iam policy projects](ProjectLocationQueueSetIamPolicyCall) (request)
870#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
871#[serde_with::serde_as]
872#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
873pub struct SetIamPolicyRequest {
874    /// 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.
875    pub policy: Option<Policy>,
876}
877
878impl common::RequestValue for SetIamPolicyRequest {}
879
880/// Configuration options for writing logs to [Stackdriver Logging](https://cloud.google.com/logging/docs/).
881///
882/// This type is not used in any activity, and only used as *part* of another schema.
883///
884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
885#[serde_with::serde_as]
886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
887pub struct StackdriverLoggingConfig {
888    /// Specifies the fraction of operations to write to [Stackdriver Logging](https://cloud.google.com/logging/docs/). This field may contain any value between 0.0 and 1.0, inclusive. 0.0 is the default and means that no operations are logged.
889    #[serde(rename = "samplingRatio")]
890    pub sampling_ratio: Option<f64>,
891}
892
893impl common::Part for StackdriverLoggingConfig {}
894
895/// 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).
896///
897/// This type is not used in any activity, and only used as *part* of another schema.
898///
899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
900#[serde_with::serde_as]
901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
902pub struct Status {
903    /// The status code, which should be an enum value of google.rpc.Code.
904    pub code: Option<i32>,
905    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
906    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
907    /// 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.
908    pub message: Option<String>,
909}
910
911impl common::Part for Status {}
912
913/// A unit of scheduled work.
914///
915/// # Activities
916///
917/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
918/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
919///
920/// * [locations queues tasks create projects](ProjectLocationQueueTaskCreateCall) (response)
921/// * [locations queues tasks get projects](ProjectLocationQueueTaskGetCall) (response)
922/// * [locations queues tasks run projects](ProjectLocationQueueTaskRunCall) (response)
923#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
924#[serde_with::serde_as]
925#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
926pub struct Task {
927    /// HTTP request that is sent to the App Engine app handler. An App Engine task is a task that has AppEngineHttpRequest set.
928    #[serde(rename = "appEngineHttpRequest")]
929    pub app_engine_http_request: Option<AppEngineHttpRequest>,
930    /// Output only. The time that the task was created. `create_time` will be truncated to the nearest second.
931    #[serde(rename = "createTime")]
932    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
933    /// Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response.
934    #[serde(rename = "dispatchCount")]
935    pub dispatch_count: Option<i32>,
936    /// The deadline for requests sent to the worker. If the worker does not respond by this deadline then the request is cancelled and the attempt is marked as a `DEADLINE_EXCEEDED` failure. Cloud Tasks will retry the task according to the RetryConfig. Note that when the request is cancelled, Cloud Tasks will stop listening for the response, but whether the worker stops processing depends on the worker. For example, if the worker is stuck, it may not react to cancelled requests. The default and maximum values depend on the type of request: * For HTTP tasks, the default is 10 minutes. The deadline must be in the interval [15 seconds, 30 minutes]. * For App Engine tasks, 0 indicates that the request has the default deadline. The default deadline depends on the [scaling type](https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#instance_scaling) of the service: 10 minutes for standard apps with automatic scaling, 24 hours for standard apps with manual and basic scaling, and 60 minutes for flex apps. If the request deadline is set, it must be in the interval [15 seconds, 24 hours 15 seconds]. Regardless of the task's `dispatch_deadline`, the app handler will not run for longer than than the service's timeout. We recommend setting the `dispatch_deadline` to at most a few seconds more than the app handler's timeout. For more information see [Timeouts](https://cloud.google.com/tasks/docs/creating-appengine-handlers#timeouts). The value must be given as a string that indicates the length of time (in seconds) followed by `s` (for "seconds"). For more information on the format, see the documentation for [Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration). `dispatch_deadline` will be truncated to the nearest millisecond. The deadline is an approximate deadline.
937    #[serde(rename = "dispatchDeadline")]
938    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
939    pub dispatch_deadline: Option<chrono::Duration>,
940    /// Output only. The status of the task's first attempt. Only dispatch_time will be set. The other Attempt information is not retained by Cloud Tasks.
941    #[serde(rename = "firstAttempt")]
942    pub first_attempt: Option<Attempt>,
943    /// HTTP request that is sent to the worker. An HTTP task is a task that has HttpRequest set.
944    #[serde(rename = "httpRequest")]
945    pub http_request: Option<HttpRequest>,
946    /// Output only. The status of the task's last attempt.
947    #[serde(rename = "lastAttempt")]
948    pub last_attempt: Option<Attempt>,
949    /// 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.
950    pub name: Option<String>,
951    /// Output only. The number of attempts which have received a response.
952    #[serde(rename = "responseCount")]
953    pub response_count: Option<i32>,
954    /// The time when the task is scheduled to be attempted or retried. `schedule_time` will be truncated to the nearest microsecond.
955    #[serde(rename = "scheduleTime")]
956    pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
957    /// Output only. The view specifies which subset of the Task has been returned.
958    pub view: Option<String>,
959}
960
961impl common::ResponseResult for Task {}
962
963/// Request message for `TestIamPermissions` method.
964///
965/// # Activities
966///
967/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
968/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
969///
970/// * [locations queues test iam permissions projects](ProjectLocationQueueTestIamPermissionCall) (request)
971#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
972#[serde_with::serde_as]
973#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
974pub struct TestIamPermissionsRequest {
975    /// 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).
976    pub permissions: Option<Vec<String>>,
977}
978
979impl common::RequestValue for TestIamPermissionsRequest {}
980
981/// Response message for `TestIamPermissions` method.
982///
983/// # Activities
984///
985/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
986/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
987///
988/// * [locations queues test iam permissions projects](ProjectLocationQueueTestIamPermissionCall) (response)
989#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
990#[serde_with::serde_as]
991#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
992pub struct TestIamPermissionsResponse {
993    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
994    pub permissions: Option<Vec<String>>,
995}
996
997impl common::ResponseResult for TestIamPermissionsResponse {}
998
999/// URI Override. When specified, all the HTTP tasks inside the queue will be partially or fully overridden depending on the configured values.
1000///
1001/// This type is not used in any activity, and only used as *part* of another schema.
1002///
1003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1004#[serde_with::serde_as]
1005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1006pub struct UriOverride {
1007    /// 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).
1008    pub host: Option<String>,
1009    /// 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.
1010    #[serde(rename = "pathOverride")]
1011    pub path_override: Option<PathOverride>,
1012    /// Port override. When specified, replaces the port part of the task URI. For instance, for a URI "https://www.example.com/example" and port=123, the overridden URI becomes "https://www.example.com:123/example". Note that the port value must be a positive integer. Setting the port to 0 (Zero) clears the URI port.
1013    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1014    pub port: Option<i64>,
1015    /// 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.
1016    #[serde(rename = "queryOverride")]
1017    pub query_override: Option<QueryOverride>,
1018    /// Scheme override. When specified, the task URI scheme is replaced by the provided value (HTTP or HTTPS).
1019    pub scheme: Option<String>,
1020    /// URI Override Enforce Mode When specified, determines the Target UriOverride mode. If not specified, it defaults to ALWAYS.
1021    #[serde(rename = "uriOverrideEnforceMode")]
1022    pub uri_override_enforce_mode: Option<String>,
1023}
1024
1025impl common::Part for UriOverride {}
1026
1027// ###################
1028// MethodBuilders ###
1029// #################
1030
1031/// A builder providing access to all methods supported on *project* resources.
1032/// It is not used directly, but through the [`CloudTasks`] hub.
1033///
1034/// # Example
1035///
1036/// Instantiate a resource builder
1037///
1038/// ```test_harness,no_run
1039/// extern crate hyper;
1040/// extern crate hyper_rustls;
1041/// extern crate google_cloudtasks2 as cloudtasks2;
1042///
1043/// # async fn dox() {
1044/// use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1045///
1046/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1047/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1048///     .with_native_roots()
1049///     .unwrap()
1050///     .https_only()
1051///     .enable_http2()
1052///     .build();
1053///
1054/// let executor = hyper_util::rt::TokioExecutor::new();
1055/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1056///     secret,
1057///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1058///     yup_oauth2::client::CustomHyperClientBuilder::from(
1059///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1060///     ),
1061/// ).build().await.unwrap();
1062///
1063/// let client = hyper_util::client::legacy::Client::builder(
1064///     hyper_util::rt::TokioExecutor::new()
1065/// )
1066/// .build(
1067///     hyper_rustls::HttpsConnectorBuilder::new()
1068///         .with_native_roots()
1069///         .unwrap()
1070///         .https_or_http()
1071///         .enable_http2()
1072///         .build()
1073/// );
1074/// let mut hub = CloudTasks::new(client, auth);
1075/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1076/// // 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_buffer(...)`, `locations_queues_tasks_create(...)`, `locations_queues_tasks_delete(...)`, `locations_queues_tasks_get(...)`, `locations_queues_tasks_list(...)`, `locations_queues_tasks_run(...)`, `locations_queues_test_iam_permissions(...)` and `locations_update_cmek_config(...)`
1077/// // to build up your call.
1078/// let rb = hub.projects();
1079/// # }
1080/// ```
1081pub struct ProjectMethods<'a, C>
1082where
1083    C: 'a,
1084{
1085    hub: &'a CloudTasks<C>,
1086}
1087
1088impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1089
1090impl<'a, C> ProjectMethods<'a, C> {
1091    /// Create a builder to help you perform the following task:
1092    ///
1093    /// 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.
1094    ///
1095    /// # Arguments
1096    ///
1097    /// * `request` - No description provided.
1098    /// * `queue` - Required. The parent queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1099    /// * `taskId` - Optional. Task ID for the task being created. If not provided, Cloud Tasks generates an ID for the task.
1100    pub fn locations_queues_tasks_buffer(
1101        &self,
1102        request: BufferTaskRequest,
1103        queue: &str,
1104        task_id: &str,
1105    ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1106        ProjectLocationQueueTaskBufferCall {
1107            hub: self.hub,
1108            _request: request,
1109            _queue: queue.to_string(),
1110            _task_id: task_id.to_string(),
1111            _delegate: Default::default(),
1112            _additional_params: Default::default(),
1113            _scopes: Default::default(),
1114        }
1115    }
1116
1117    /// Create a builder to help you perform the following task:
1118    ///
1119    /// Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command. * The maximum task size is 100KB.
1120    ///
1121    /// # Arguments
1122    ///
1123    /// * `request` - No description provided.
1124    /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1125    pub fn locations_queues_tasks_create(
1126        &self,
1127        request: CreateTaskRequest,
1128        parent: &str,
1129    ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
1130        ProjectLocationQueueTaskCreateCall {
1131            hub: self.hub,
1132            _request: request,
1133            _parent: parent.to_string(),
1134            _delegate: Default::default(),
1135            _additional_params: Default::default(),
1136            _scopes: Default::default(),
1137        }
1138    }
1139
1140    /// Create a builder to help you perform the following task:
1141    ///
1142    /// Deletes a task. A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has executed successfully or permanently failed.
1143    ///
1144    /// # Arguments
1145    ///
1146    /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1147    pub fn locations_queues_tasks_delete(
1148        &self,
1149        name: &str,
1150    ) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
1151        ProjectLocationQueueTaskDeleteCall {
1152            hub: self.hub,
1153            _name: name.to_string(),
1154            _delegate: Default::default(),
1155            _additional_params: Default::default(),
1156            _scopes: Default::default(),
1157        }
1158    }
1159
1160    /// Create a builder to help you perform the following task:
1161    ///
1162    /// Gets a task. After a task is successfully executed or has exhausted its retry attempts, the task is deleted. A `GetTask` request for a deleted task returns a `NOT_FOUND` error.
1163    ///
1164    /// # Arguments
1165    ///
1166    /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1167    pub fn locations_queues_tasks_get(&self, name: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
1168        ProjectLocationQueueTaskGetCall {
1169            hub: self.hub,
1170            _name: name.to_string(),
1171            _response_view: Default::default(),
1172            _delegate: Default::default(),
1173            _additional_params: Default::default(),
1174            _scopes: Default::default(),
1175        }
1176    }
1177
1178    /// Create a builder to help you perform the following task:
1179    ///
1180    /// 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.
1181    ///
1182    /// # Arguments
1183    ///
1184    /// * `parent` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1185    pub fn locations_queues_tasks_list(
1186        &self,
1187        parent: &str,
1188    ) -> ProjectLocationQueueTaskListCall<'a, C> {
1189        ProjectLocationQueueTaskListCall {
1190            hub: self.hub,
1191            _parent: parent.to_string(),
1192            _response_view: Default::default(),
1193            _page_token: Default::default(),
1194            _page_size: Default::default(),
1195            _delegate: Default::default(),
1196            _additional_params: Default::default(),
1197            _scopes: Default::default(),
1198        }
1199    }
1200
1201    /// Create a builder to help you perform the following task:
1202    ///
1203    /// 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. 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.
1204    ///
1205    /// # Arguments
1206    ///
1207    /// * `request` - No description provided.
1208    /// * `name` - Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1209    pub fn locations_queues_tasks_run(
1210        &self,
1211        request: RunTaskRequest,
1212        name: &str,
1213    ) -> ProjectLocationQueueTaskRunCall<'a, C> {
1214        ProjectLocationQueueTaskRunCall {
1215            hub: self.hub,
1216            _request: request,
1217            _name: name.to_string(),
1218            _delegate: Default::default(),
1219            _additional_params: Default::default(),
1220            _scopes: Default::default(),
1221        }
1222    }
1223
1224    /// Create a builder to help you perform the following task:
1225    ///
1226    /// 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.
1227    ///
1228    /// # Arguments
1229    ///
1230    /// * `request` - No description provided.
1231    /// * `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.
1232    pub fn locations_queues_create(
1233        &self,
1234        request: Queue,
1235        parent: &str,
1236    ) -> ProjectLocationQueueCreateCall<'a, C> {
1237        ProjectLocationQueueCreateCall {
1238            hub: self.hub,
1239            _request: request,
1240            _parent: parent.to_string(),
1241            _delegate: Default::default(),
1242            _additional_params: Default::default(),
1243            _scopes: Default::default(),
1244        }
1245    }
1246
1247    /// Create a builder to help you perform the following task:
1248    ///
1249    /// 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.
1250    ///
1251    /// # Arguments
1252    ///
1253    /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1254    pub fn locations_queues_delete(&self, name: &str) -> ProjectLocationQueueDeleteCall<'a, C> {
1255        ProjectLocationQueueDeleteCall {
1256            hub: self.hub,
1257            _name: name.to_string(),
1258            _delegate: Default::default(),
1259            _additional_params: Default::default(),
1260            _scopes: Default::default(),
1261        }
1262    }
1263
1264    /// Create a builder to help you perform the following task:
1265    ///
1266    /// Gets a queue.
1267    ///
1268    /// # Arguments
1269    ///
1270    /// * `name` - Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1271    pub fn locations_queues_get(&self, name: &str) -> ProjectLocationQueueGetCall<'a, C> {
1272        ProjectLocationQueueGetCall {
1273            hub: self.hub,
1274            _name: name.to_string(),
1275            _delegate: Default::default(),
1276            _additional_params: Default::default(),
1277            _scopes: Default::default(),
1278        }
1279    }
1280
1281    /// Create a builder to help you perform the following task:
1282    ///
1283    /// 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`
1284    ///
1285    /// # Arguments
1286    ///
1287    /// * `request` - No description provided.
1288    /// * `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.
1289    pub fn locations_queues_get_iam_policy(
1290        &self,
1291        request: GetIamPolicyRequest,
1292        resource: &str,
1293    ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
1294        ProjectLocationQueueGetIamPolicyCall {
1295            hub: self.hub,
1296            _request: request,
1297            _resource: resource.to_string(),
1298            _delegate: Default::default(),
1299            _additional_params: Default::default(),
1300            _scopes: Default::default(),
1301        }
1302    }
1303
1304    /// Create a builder to help you perform the following task:
1305    ///
1306    /// Lists queues. Queues are returned in lexicographical order.
1307    ///
1308    /// # Arguments
1309    ///
1310    /// * `parent` - Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`
1311    pub fn locations_queues_list(&self, parent: &str) -> ProjectLocationQueueListCall<'a, C> {
1312        ProjectLocationQueueListCall {
1313            hub: self.hub,
1314            _parent: parent.to_string(),
1315            _page_token: Default::default(),
1316            _page_size: Default::default(),
1317            _filter: Default::default(),
1318            _delegate: Default::default(),
1319            _additional_params: Default::default(),
1320            _scopes: Default::default(),
1321        }
1322    }
1323
1324    /// Create a builder to help you perform the following task:
1325    ///
1326    /// 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.
1327    ///
1328    /// # Arguments
1329    ///
1330    /// * `request` - No description provided.
1331    /// * `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.
1332    pub fn locations_queues_patch(
1333        &self,
1334        request: Queue,
1335        name: &str,
1336    ) -> ProjectLocationQueuePatchCall<'a, C> {
1337        ProjectLocationQueuePatchCall {
1338            hub: self.hub,
1339            _request: request,
1340            _name: name.to_string(),
1341            _update_mask: Default::default(),
1342            _delegate: Default::default(),
1343            _additional_params: Default::default(),
1344            _scopes: Default::default(),
1345        }
1346    }
1347
1348    /// Create a builder to help you perform the following task:
1349    ///
1350    /// 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.
1351    ///
1352    /// # Arguments
1353    ///
1354    /// * `request` - No description provided.
1355    /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1356    pub fn locations_queues_pause(
1357        &self,
1358        request: PauseQueueRequest,
1359        name: &str,
1360    ) -> ProjectLocationQueuePauseCall<'a, C> {
1361        ProjectLocationQueuePauseCall {
1362            hub: self.hub,
1363            _request: request,
1364            _name: name.to_string(),
1365            _delegate: Default::default(),
1366            _additional_params: Default::default(),
1367            _scopes: Default::default(),
1368        }
1369    }
1370
1371    /// Create a builder to help you perform the following task:
1372    ///
1373    /// 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.
1374    ///
1375    /// # Arguments
1376    ///
1377    /// * `request` - No description provided.
1378    /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1379    pub fn locations_queues_purge(
1380        &self,
1381        request: PurgeQueueRequest,
1382        name: &str,
1383    ) -> ProjectLocationQueuePurgeCall<'a, C> {
1384        ProjectLocationQueuePurgeCall {
1385            hub: self.hub,
1386            _request: request,
1387            _name: name.to_string(),
1388            _delegate: Default::default(),
1389            _additional_params: Default::default(),
1390            _scopes: Default::default(),
1391        }
1392    }
1393
1394    /// Create a builder to help you perform the following task:
1395    ///
1396    /// 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).
1397    ///
1398    /// # Arguments
1399    ///
1400    /// * `request` - No description provided.
1401    /// * `name` - Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
1402    pub fn locations_queues_resume(
1403        &self,
1404        request: ResumeQueueRequest,
1405        name: &str,
1406    ) -> ProjectLocationQueueResumeCall<'a, C> {
1407        ProjectLocationQueueResumeCall {
1408            hub: self.hub,
1409            _request: request,
1410            _name: name.to_string(),
1411            _delegate: Default::default(),
1412            _additional_params: Default::default(),
1413            _scopes: Default::default(),
1414        }
1415    }
1416
1417    /// Create a builder to help you perform the following task:
1418    ///
1419    /// 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`
1420    ///
1421    /// # Arguments
1422    ///
1423    /// * `request` - No description provided.
1424    /// * `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.
1425    pub fn locations_queues_set_iam_policy(
1426        &self,
1427        request: SetIamPolicyRequest,
1428        resource: &str,
1429    ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
1430        ProjectLocationQueueSetIamPolicyCall {
1431            hub: self.hub,
1432            _request: request,
1433            _resource: resource.to_string(),
1434            _delegate: Default::default(),
1435            _additional_params: Default::default(),
1436            _scopes: Default::default(),
1437        }
1438    }
1439
1440    /// Create a builder to help you perform the following task:
1441    ///
1442    /// 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.
1443    ///
1444    /// # Arguments
1445    ///
1446    /// * `request` - No description provided.
1447    /// * `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.
1448    pub fn locations_queues_test_iam_permissions(
1449        &self,
1450        request: TestIamPermissionsRequest,
1451        resource: &str,
1452    ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
1453        ProjectLocationQueueTestIamPermissionCall {
1454            hub: self.hub,
1455            _request: request,
1456            _resource: resource.to_string(),
1457            _delegate: Default::default(),
1458            _additional_params: Default::default(),
1459            _scopes: Default::default(),
1460        }
1461    }
1462
1463    /// Create a builder to help you perform the following task:
1464    ///
1465    /// Gets information about a location.
1466    ///
1467    /// # Arguments
1468    ///
1469    /// * `name` - Resource name for the location.
1470    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1471        ProjectLocationGetCall {
1472            hub: self.hub,
1473            _name: name.to_string(),
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    /// Gets the CMEK config. Gets the Customer Managed Encryption Key configured with the Cloud Tasks lcoation. By default there is no kms_key configured.
1483    ///
1484    /// # Arguments
1485    ///
1486    /// * `name` - Required. The config. For example: projects/PROJECT_ID/locations/LOCATION_ID/CmekConfig`
1487    pub fn locations_get_cmek_config(&self, name: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
1488        ProjectLocationGetCmekConfigCall {
1489            hub: self.hub,
1490            _name: name.to_string(),
1491            _delegate: Default::default(),
1492            _additional_params: Default::default(),
1493            _scopes: Default::default(),
1494        }
1495    }
1496
1497    /// Create a builder to help you perform the following task:
1498    ///
1499    /// Lists information about the supported locations for this service.
1500    ///
1501    /// # Arguments
1502    ///
1503    /// * `name` - The resource that owns the locations collection, if applicable.
1504    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1505        ProjectLocationListCall {
1506            hub: self.hub,
1507            _name: name.to_string(),
1508            _page_token: Default::default(),
1509            _page_size: Default::default(),
1510            _filter: Default::default(),
1511            _extra_location_types: Default::default(),
1512            _delegate: Default::default(),
1513            _additional_params: Default::default(),
1514            _scopes: Default::default(),
1515        }
1516    }
1517
1518    /// Create a builder to help you perform the following task:
1519    ///
1520    /// 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.
1521    ///
1522    /// # Arguments
1523    ///
1524    /// * `request` - No description provided.
1525    /// * `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`
1526    pub fn locations_update_cmek_config(
1527        &self,
1528        request: CmekConfig,
1529        name: &str,
1530    ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
1531        ProjectLocationUpdateCmekConfigCall {
1532            hub: self.hub,
1533            _request: request,
1534            _name: name.to_string(),
1535            _update_mask: Default::default(),
1536            _delegate: Default::default(),
1537            _additional_params: Default::default(),
1538            _scopes: Default::default(),
1539        }
1540    }
1541}
1542
1543// ###################
1544// CallBuilders   ###
1545// #################
1546
1547/// 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.
1548///
1549/// A builder for the *locations.queues.tasks.buffer* method supported by a *project* resource.
1550/// It is not used directly, but through a [`ProjectMethods`] instance.
1551///
1552/// # Example
1553///
1554/// Instantiate a resource method builder
1555///
1556/// ```test_harness,no_run
1557/// # extern crate hyper;
1558/// # extern crate hyper_rustls;
1559/// # extern crate google_cloudtasks2 as cloudtasks2;
1560/// use cloudtasks2::api::BufferTaskRequest;
1561/// # async fn dox() {
1562/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1563///
1564/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1565/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1566/// #     .with_native_roots()
1567/// #     .unwrap()
1568/// #     .https_only()
1569/// #     .enable_http2()
1570/// #     .build();
1571///
1572/// # let executor = hyper_util::rt::TokioExecutor::new();
1573/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1574/// #     secret,
1575/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1576/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1577/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1578/// #     ),
1579/// # ).build().await.unwrap();
1580///
1581/// # let client = hyper_util::client::legacy::Client::builder(
1582/// #     hyper_util::rt::TokioExecutor::new()
1583/// # )
1584/// # .build(
1585/// #     hyper_rustls::HttpsConnectorBuilder::new()
1586/// #         .with_native_roots()
1587/// #         .unwrap()
1588/// #         .https_or_http()
1589/// #         .enable_http2()
1590/// #         .build()
1591/// # );
1592/// # let mut hub = CloudTasks::new(client, auth);
1593/// // As the method needs a request, you would usually fill it with the desired information
1594/// // into the respective structure. Some of the parts shown here might not be applicable !
1595/// // Values shown here are possibly random and not representative !
1596/// let mut req = BufferTaskRequest::default();
1597///
1598/// // You can configure optional parameters by calling the respective setters at will, and
1599/// // execute the final call using `doit()`.
1600/// // Values shown here are possibly random and not representative !
1601/// let result = hub.projects().locations_queues_tasks_buffer(req, "queue", "taskId")
1602///              .doit().await;
1603/// # }
1604/// ```
1605pub struct ProjectLocationQueueTaskBufferCall<'a, C>
1606where
1607    C: 'a,
1608{
1609    hub: &'a CloudTasks<C>,
1610    _request: BufferTaskRequest,
1611    _queue: String,
1612    _task_id: String,
1613    _delegate: Option<&'a mut dyn common::Delegate>,
1614    _additional_params: HashMap<String, String>,
1615    _scopes: BTreeSet<String>,
1616}
1617
1618impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskBufferCall<'a, C> {}
1619
1620impl<'a, C> ProjectLocationQueueTaskBufferCall<'a, C>
1621where
1622    C: common::Connector,
1623{
1624    /// Perform the operation you have build so far.
1625    pub async fn doit(mut self) -> common::Result<(common::Response, BufferTaskResponse)> {
1626        use std::borrow::Cow;
1627        use std::io::{Read, Seek};
1628
1629        use common::{url::Params, ToParts};
1630        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1631
1632        let mut dd = common::DefaultDelegate;
1633        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1634        dlg.begin(common::MethodInfo {
1635            id: "cloudtasks.projects.locations.queues.tasks.buffer",
1636            http_method: hyper::Method::POST,
1637        });
1638
1639        for &field in ["alt", "queue", "taskId"].iter() {
1640            if self._additional_params.contains_key(field) {
1641                dlg.finished(false);
1642                return Err(common::Error::FieldClash(field));
1643            }
1644        }
1645
1646        let mut params = Params::with_capacity(5 + self._additional_params.len());
1647        params.push("queue", self._queue);
1648        params.push("taskId", self._task_id);
1649
1650        params.extend(self._additional_params.iter());
1651
1652        params.push("alt", "json");
1653        let mut url = self.hub._base_url.clone() + "v2/{+queue}/tasks/{taskId}:buffer";
1654        if self._scopes.is_empty() {
1655            self._scopes
1656                .insert(Scope::CloudPlatform.as_ref().to_string());
1657        }
1658
1659        #[allow(clippy::single_element_loop)]
1660        for &(find_this, param_name) in [("{+queue}", "queue"), ("{taskId}", "taskId")].iter() {
1661            url = params.uri_replacement(url, param_name, find_this, true);
1662        }
1663        {
1664            let to_remove = ["taskId", "queue"];
1665            params.remove_params(&to_remove);
1666        }
1667
1668        let url = params.parse_with_url(&url);
1669
1670        let mut json_mime_type = mime::APPLICATION_JSON;
1671        let mut request_value_reader = {
1672            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1673            common::remove_json_null_values(&mut value);
1674            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1675            serde_json::to_writer(&mut dst, &value).unwrap();
1676            dst
1677        };
1678        let request_size = request_value_reader
1679            .seek(std::io::SeekFrom::End(0))
1680            .unwrap();
1681        request_value_reader
1682            .seek(std::io::SeekFrom::Start(0))
1683            .unwrap();
1684
1685        loop {
1686            let token = match self
1687                .hub
1688                .auth
1689                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1690                .await
1691            {
1692                Ok(token) => token,
1693                Err(e) => match dlg.token(e) {
1694                    Ok(token) => token,
1695                    Err(e) => {
1696                        dlg.finished(false);
1697                        return Err(common::Error::MissingToken(e));
1698                    }
1699                },
1700            };
1701            request_value_reader
1702                .seek(std::io::SeekFrom::Start(0))
1703                .unwrap();
1704            let mut req_result = {
1705                let client = &self.hub.client;
1706                dlg.pre_request();
1707                let mut req_builder = hyper::Request::builder()
1708                    .method(hyper::Method::POST)
1709                    .uri(url.as_str())
1710                    .header(USER_AGENT, self.hub._user_agent.clone());
1711
1712                if let Some(token) = token.as_ref() {
1713                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1714                }
1715
1716                let request = req_builder
1717                    .header(CONTENT_TYPE, json_mime_type.to_string())
1718                    .header(CONTENT_LENGTH, request_size as u64)
1719                    .body(common::to_body(
1720                        request_value_reader.get_ref().clone().into(),
1721                    ));
1722
1723                client.request(request.unwrap()).await
1724            };
1725
1726            match req_result {
1727                Err(err) => {
1728                    if let common::Retry::After(d) = dlg.http_error(&err) {
1729                        sleep(d).await;
1730                        continue;
1731                    }
1732                    dlg.finished(false);
1733                    return Err(common::Error::HttpError(err));
1734                }
1735                Ok(res) => {
1736                    let (mut parts, body) = res.into_parts();
1737                    let mut body = common::Body::new(body);
1738                    if !parts.status.is_success() {
1739                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1740                        let error = serde_json::from_str(&common::to_string(&bytes));
1741                        let response = common::to_response(parts, bytes.into());
1742
1743                        if let common::Retry::After(d) =
1744                            dlg.http_failure(&response, error.as_ref().ok())
1745                        {
1746                            sleep(d).await;
1747                            continue;
1748                        }
1749
1750                        dlg.finished(false);
1751
1752                        return Err(match error {
1753                            Ok(value) => common::Error::BadRequest(value),
1754                            _ => common::Error::Failure(response),
1755                        });
1756                    }
1757                    let response = {
1758                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1759                        let encoded = common::to_string(&bytes);
1760                        match serde_json::from_str(&encoded) {
1761                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1762                            Err(error) => {
1763                                dlg.response_json_decode_error(&encoded, &error);
1764                                return Err(common::Error::JsonDecodeError(
1765                                    encoded.to_string(),
1766                                    error,
1767                                ));
1768                            }
1769                        }
1770                    };
1771
1772                    dlg.finished(true);
1773                    return Ok(response);
1774                }
1775            }
1776        }
1777    }
1778
1779    ///
1780    /// Sets the *request* property to the given value.
1781    ///
1782    /// Even though the property as already been set when instantiating this call,
1783    /// we provide this method for API completeness.
1784    pub fn request(
1785        mut self,
1786        new_value: BufferTaskRequest,
1787    ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1788        self._request = new_value;
1789        self
1790    }
1791    /// Required. The parent queue name. For example: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
1792    ///
1793    /// Sets the *queue* path property to the given value.
1794    ///
1795    /// Even though the property as already been set when instantiating this call,
1796    /// we provide this method for API completeness.
1797    pub fn queue(mut self, new_value: &str) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1798        self._queue = new_value.to_string();
1799        self
1800    }
1801    /// Optional. Task ID for the task being created. If not provided, Cloud Tasks generates an ID for the task.
1802    ///
1803    /// Sets the *task id* path property to the given value.
1804    ///
1805    /// Even though the property as already been set when instantiating this call,
1806    /// we provide this method for API completeness.
1807    pub fn task_id(mut self, new_value: &str) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1808        self._task_id = new_value.to_string();
1809        self
1810    }
1811    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1812    /// while executing the actual API request.
1813    ///
1814    /// ````text
1815    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1816    /// ````
1817    ///
1818    /// Sets the *delegate* property to the given value.
1819    pub fn delegate(
1820        mut self,
1821        new_value: &'a mut dyn common::Delegate,
1822    ) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1823        self._delegate = Some(new_value);
1824        self
1825    }
1826
1827    /// Set any additional parameter of the query string used in the request.
1828    /// It should be used to set parameters which are not yet available through their own
1829    /// setters.
1830    ///
1831    /// Please note that this method must not be used to set any of the known parameters
1832    /// which have their own setter method. If done anyway, the request will fail.
1833    ///
1834    /// # Additional Parameters
1835    ///
1836    /// * *$.xgafv* (query-string) - V1 error format.
1837    /// * *access_token* (query-string) - OAuth access token.
1838    /// * *alt* (query-string) - Data format for response.
1839    /// * *callback* (query-string) - JSONP
1840    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1841    /// * *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.
1842    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1843    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1844    /// * *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.
1845    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1846    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1847    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskBufferCall<'a, C>
1848    where
1849        T: AsRef<str>,
1850    {
1851        self._additional_params
1852            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1853        self
1854    }
1855
1856    /// Identifies the authorization scope for the method you are building.
1857    ///
1858    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1859    /// [`Scope::CloudPlatform`].
1860    ///
1861    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1862    /// tokens for more than one scope.
1863    ///
1864    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1865    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1866    /// sufficient, a read-write scope will do as well.
1867    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskBufferCall<'a, C>
1868    where
1869        St: AsRef<str>,
1870    {
1871        self._scopes.insert(String::from(scope.as_ref()));
1872        self
1873    }
1874    /// Identifies the authorization scope(s) for the method you are building.
1875    ///
1876    /// See [`Self::add_scope()`] for details.
1877    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskBufferCall<'a, C>
1878    where
1879        I: IntoIterator<Item = St>,
1880        St: AsRef<str>,
1881    {
1882        self._scopes
1883            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1884        self
1885    }
1886
1887    /// Removes all scopes, and no default scope will be used either.
1888    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1889    /// for details).
1890    pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskBufferCall<'a, C> {
1891        self._scopes.clear();
1892        self
1893    }
1894}
1895
1896/// Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command. * The maximum task size is 100KB.
1897///
1898/// A builder for the *locations.queues.tasks.create* method supported by a *project* resource.
1899/// It is not used directly, but through a [`ProjectMethods`] 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 as cloudtasks2;
1909/// use cloudtasks2::api::CreateTaskRequest;
1910/// # async fn dox() {
1911/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1912///
1913/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1914/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1915/// #     .with_native_roots()
1916/// #     .unwrap()
1917/// #     .https_only()
1918/// #     .enable_http2()
1919/// #     .build();
1920///
1921/// # let executor = hyper_util::rt::TokioExecutor::new();
1922/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1923/// #     secret,
1924/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1925/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1926/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1927/// #     ),
1928/// # ).build().await.unwrap();
1929///
1930/// # let client = hyper_util::client::legacy::Client::builder(
1931/// #     hyper_util::rt::TokioExecutor::new()
1932/// # )
1933/// # .build(
1934/// #     hyper_rustls::HttpsConnectorBuilder::new()
1935/// #         .with_native_roots()
1936/// #         .unwrap()
1937/// #         .https_or_http()
1938/// #         .enable_http2()
1939/// #         .build()
1940/// # );
1941/// # let mut hub = CloudTasks::new(client, auth);
1942/// // As the method needs a request, you would usually fill it with the desired information
1943/// // into the respective structure. Some of the parts shown here might not be applicable !
1944/// // Values shown here are possibly random and not representative !
1945/// let mut req = CreateTaskRequest::default();
1946///
1947/// // You can configure optional parameters by calling the respective setters at will, and
1948/// // execute the final call using `doit()`.
1949/// // Values shown here are possibly random and not representative !
1950/// let result = hub.projects().locations_queues_tasks_create(req, "parent")
1951///              .doit().await;
1952/// # }
1953/// ```
1954pub struct ProjectLocationQueueTaskCreateCall<'a, C>
1955where
1956    C: 'a,
1957{
1958    hub: &'a CloudTasks<C>,
1959    _request: CreateTaskRequest,
1960    _parent: String,
1961    _delegate: Option<&'a mut dyn common::Delegate>,
1962    _additional_params: HashMap<String, String>,
1963    _scopes: BTreeSet<String>,
1964}
1965
1966impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskCreateCall<'a, C> {}
1967
1968impl<'a, C> ProjectLocationQueueTaskCreateCall<'a, C>
1969where
1970    C: common::Connector,
1971{
1972    /// Perform the operation you have build so far.
1973    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
1974        use std::borrow::Cow;
1975        use std::io::{Read, Seek};
1976
1977        use common::{url::Params, ToParts};
1978        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1979
1980        let mut dd = common::DefaultDelegate;
1981        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1982        dlg.begin(common::MethodInfo {
1983            id: "cloudtasks.projects.locations.queues.tasks.create",
1984            http_method: hyper::Method::POST,
1985        });
1986
1987        for &field in ["alt", "parent"].iter() {
1988            if self._additional_params.contains_key(field) {
1989                dlg.finished(false);
1990                return Err(common::Error::FieldClash(field));
1991            }
1992        }
1993
1994        let mut params = Params::with_capacity(4 + self._additional_params.len());
1995        params.push("parent", self._parent);
1996
1997        params.extend(self._additional_params.iter());
1998
1999        params.push("alt", "json");
2000        let mut url = self.hub._base_url.clone() + "v2/{+parent}/tasks";
2001        if self._scopes.is_empty() {
2002            self._scopes
2003                .insert(Scope::CloudPlatform.as_ref().to_string());
2004        }
2005
2006        #[allow(clippy::single_element_loop)]
2007        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2008            url = params.uri_replacement(url, param_name, find_this, true);
2009        }
2010        {
2011            let to_remove = ["parent"];
2012            params.remove_params(&to_remove);
2013        }
2014
2015        let url = params.parse_with_url(&url);
2016
2017        let mut json_mime_type = mime::APPLICATION_JSON;
2018        let mut request_value_reader = {
2019            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2020            common::remove_json_null_values(&mut value);
2021            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2022            serde_json::to_writer(&mut dst, &value).unwrap();
2023            dst
2024        };
2025        let request_size = request_value_reader
2026            .seek(std::io::SeekFrom::End(0))
2027            .unwrap();
2028        request_value_reader
2029            .seek(std::io::SeekFrom::Start(0))
2030            .unwrap();
2031
2032        loop {
2033            let token = match self
2034                .hub
2035                .auth
2036                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2037                .await
2038            {
2039                Ok(token) => token,
2040                Err(e) => match dlg.token(e) {
2041                    Ok(token) => token,
2042                    Err(e) => {
2043                        dlg.finished(false);
2044                        return Err(common::Error::MissingToken(e));
2045                    }
2046                },
2047            };
2048            request_value_reader
2049                .seek(std::io::SeekFrom::Start(0))
2050                .unwrap();
2051            let mut req_result = {
2052                let client = &self.hub.client;
2053                dlg.pre_request();
2054                let mut req_builder = hyper::Request::builder()
2055                    .method(hyper::Method::POST)
2056                    .uri(url.as_str())
2057                    .header(USER_AGENT, self.hub._user_agent.clone());
2058
2059                if let Some(token) = token.as_ref() {
2060                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2061                }
2062
2063                let request = req_builder
2064                    .header(CONTENT_TYPE, json_mime_type.to_string())
2065                    .header(CONTENT_LENGTH, request_size as u64)
2066                    .body(common::to_body(
2067                        request_value_reader.get_ref().clone().into(),
2068                    ));
2069
2070                client.request(request.unwrap()).await
2071            };
2072
2073            match req_result {
2074                Err(err) => {
2075                    if let common::Retry::After(d) = dlg.http_error(&err) {
2076                        sleep(d).await;
2077                        continue;
2078                    }
2079                    dlg.finished(false);
2080                    return Err(common::Error::HttpError(err));
2081                }
2082                Ok(res) => {
2083                    let (mut parts, body) = res.into_parts();
2084                    let mut body = common::Body::new(body);
2085                    if !parts.status.is_success() {
2086                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2087                        let error = serde_json::from_str(&common::to_string(&bytes));
2088                        let response = common::to_response(parts, bytes.into());
2089
2090                        if let common::Retry::After(d) =
2091                            dlg.http_failure(&response, error.as_ref().ok())
2092                        {
2093                            sleep(d).await;
2094                            continue;
2095                        }
2096
2097                        dlg.finished(false);
2098
2099                        return Err(match error {
2100                            Ok(value) => common::Error::BadRequest(value),
2101                            _ => common::Error::Failure(response),
2102                        });
2103                    }
2104                    let response = {
2105                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2106                        let encoded = common::to_string(&bytes);
2107                        match serde_json::from_str(&encoded) {
2108                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2109                            Err(error) => {
2110                                dlg.response_json_decode_error(&encoded, &error);
2111                                return Err(common::Error::JsonDecodeError(
2112                                    encoded.to_string(),
2113                                    error,
2114                                ));
2115                            }
2116                        }
2117                    };
2118
2119                    dlg.finished(true);
2120                    return Ok(response);
2121                }
2122            }
2123        }
2124    }
2125
2126    ///
2127    /// Sets the *request* property to the given value.
2128    ///
2129    /// Even though the property as already been set when instantiating this call,
2130    /// we provide this method for API completeness.
2131    pub fn request(
2132        mut self,
2133        new_value: CreateTaskRequest,
2134    ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
2135        self._request = new_value;
2136        self
2137    }
2138    /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist.
2139    ///
2140    /// Sets the *parent* path property to the given value.
2141    ///
2142    /// Even though the property as already been set when instantiating this call,
2143    /// we provide this method for API completeness.
2144    pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskCreateCall<'a, C> {
2145        self._parent = new_value.to_string();
2146        self
2147    }
2148    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2149    /// while executing the actual API request.
2150    ///
2151    /// ````text
2152    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2153    /// ````
2154    ///
2155    /// Sets the *delegate* property to the given value.
2156    pub fn delegate(
2157        mut self,
2158        new_value: &'a mut dyn common::Delegate,
2159    ) -> ProjectLocationQueueTaskCreateCall<'a, C> {
2160        self._delegate = Some(new_value);
2161        self
2162    }
2163
2164    /// Set any additional parameter of the query string used in the request.
2165    /// It should be used to set parameters which are not yet available through their own
2166    /// setters.
2167    ///
2168    /// Please note that this method must not be used to set any of the known parameters
2169    /// which have their own setter method. If done anyway, the request will fail.
2170    ///
2171    /// # Additional Parameters
2172    ///
2173    /// * *$.xgafv* (query-string) - V1 error format.
2174    /// * *access_token* (query-string) - OAuth access token.
2175    /// * *alt* (query-string) - Data format for response.
2176    /// * *callback* (query-string) - JSONP
2177    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2178    /// * *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.
2179    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2180    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2181    /// * *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.
2182    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2183    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2184    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskCreateCall<'a, C>
2185    where
2186        T: AsRef<str>,
2187    {
2188        self._additional_params
2189            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2190        self
2191    }
2192
2193    /// Identifies the authorization scope for the method you are building.
2194    ///
2195    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2196    /// [`Scope::CloudPlatform`].
2197    ///
2198    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2199    /// tokens for more than one scope.
2200    ///
2201    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2202    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2203    /// sufficient, a read-write scope will do as well.
2204    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskCreateCall<'a, C>
2205    where
2206        St: AsRef<str>,
2207    {
2208        self._scopes.insert(String::from(scope.as_ref()));
2209        self
2210    }
2211    /// Identifies the authorization scope(s) for the method you are building.
2212    ///
2213    /// See [`Self::add_scope()`] for details.
2214    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskCreateCall<'a, C>
2215    where
2216        I: IntoIterator<Item = St>,
2217        St: AsRef<str>,
2218    {
2219        self._scopes
2220            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2221        self
2222    }
2223
2224    /// Removes all scopes, and no default scope will be used either.
2225    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2226    /// for details).
2227    pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskCreateCall<'a, C> {
2228        self._scopes.clear();
2229        self
2230    }
2231}
2232
2233/// Deletes a task. A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has executed successfully or permanently failed.
2234///
2235/// A builder for the *locations.queues.tasks.delete* method supported by a *project* resource.
2236/// It is not used directly, but through a [`ProjectMethods`] instance.
2237///
2238/// # Example
2239///
2240/// Instantiate a resource method builder
2241///
2242/// ```test_harness,no_run
2243/// # extern crate hyper;
2244/// # extern crate hyper_rustls;
2245/// # extern crate google_cloudtasks2 as cloudtasks2;
2246/// # async fn dox() {
2247/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2248///
2249/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2250/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2251/// #     .with_native_roots()
2252/// #     .unwrap()
2253/// #     .https_only()
2254/// #     .enable_http2()
2255/// #     .build();
2256///
2257/// # let executor = hyper_util::rt::TokioExecutor::new();
2258/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2259/// #     secret,
2260/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2261/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2262/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2263/// #     ),
2264/// # ).build().await.unwrap();
2265///
2266/// # let client = hyper_util::client::legacy::Client::builder(
2267/// #     hyper_util::rt::TokioExecutor::new()
2268/// # )
2269/// # .build(
2270/// #     hyper_rustls::HttpsConnectorBuilder::new()
2271/// #         .with_native_roots()
2272/// #         .unwrap()
2273/// #         .https_or_http()
2274/// #         .enable_http2()
2275/// #         .build()
2276/// # );
2277/// # let mut hub = CloudTasks::new(client, auth);
2278/// // You can configure optional parameters by calling the respective setters at will, and
2279/// // execute the final call using `doit()`.
2280/// // Values shown here are possibly random and not representative !
2281/// let result = hub.projects().locations_queues_tasks_delete("name")
2282///              .doit().await;
2283/// # }
2284/// ```
2285pub struct ProjectLocationQueueTaskDeleteCall<'a, C>
2286where
2287    C: 'a,
2288{
2289    hub: &'a CloudTasks<C>,
2290    _name: String,
2291    _delegate: Option<&'a mut dyn common::Delegate>,
2292    _additional_params: HashMap<String, String>,
2293    _scopes: BTreeSet<String>,
2294}
2295
2296impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskDeleteCall<'a, C> {}
2297
2298impl<'a, C> ProjectLocationQueueTaskDeleteCall<'a, C>
2299where
2300    C: common::Connector,
2301{
2302    /// Perform the operation you have build so far.
2303    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2304        use std::borrow::Cow;
2305        use std::io::{Read, Seek};
2306
2307        use common::{url::Params, ToParts};
2308        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2309
2310        let mut dd = common::DefaultDelegate;
2311        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2312        dlg.begin(common::MethodInfo {
2313            id: "cloudtasks.projects.locations.queues.tasks.delete",
2314            http_method: hyper::Method::DELETE,
2315        });
2316
2317        for &field in ["alt", "name"].iter() {
2318            if self._additional_params.contains_key(field) {
2319                dlg.finished(false);
2320                return Err(common::Error::FieldClash(field));
2321            }
2322        }
2323
2324        let mut params = Params::with_capacity(3 + self._additional_params.len());
2325        params.push("name", self._name);
2326
2327        params.extend(self._additional_params.iter());
2328
2329        params.push("alt", "json");
2330        let mut url = self.hub._base_url.clone() + "v2/{+name}";
2331        if self._scopes.is_empty() {
2332            self._scopes
2333                .insert(Scope::CloudPlatform.as_ref().to_string());
2334        }
2335
2336        #[allow(clippy::single_element_loop)]
2337        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2338            url = params.uri_replacement(url, param_name, find_this, true);
2339        }
2340        {
2341            let to_remove = ["name"];
2342            params.remove_params(&to_remove);
2343        }
2344
2345        let url = params.parse_with_url(&url);
2346
2347        loop {
2348            let token = match self
2349                .hub
2350                .auth
2351                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2352                .await
2353            {
2354                Ok(token) => token,
2355                Err(e) => match dlg.token(e) {
2356                    Ok(token) => token,
2357                    Err(e) => {
2358                        dlg.finished(false);
2359                        return Err(common::Error::MissingToken(e));
2360                    }
2361                },
2362            };
2363            let mut req_result = {
2364                let client = &self.hub.client;
2365                dlg.pre_request();
2366                let mut req_builder = hyper::Request::builder()
2367                    .method(hyper::Method::DELETE)
2368                    .uri(url.as_str())
2369                    .header(USER_AGENT, self.hub._user_agent.clone());
2370
2371                if let Some(token) = token.as_ref() {
2372                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2373                }
2374
2375                let request = req_builder
2376                    .header(CONTENT_LENGTH, 0_u64)
2377                    .body(common::to_body::<String>(None));
2378
2379                client.request(request.unwrap()).await
2380            };
2381
2382            match req_result {
2383                Err(err) => {
2384                    if let common::Retry::After(d) = dlg.http_error(&err) {
2385                        sleep(d).await;
2386                        continue;
2387                    }
2388                    dlg.finished(false);
2389                    return Err(common::Error::HttpError(err));
2390                }
2391                Ok(res) => {
2392                    let (mut parts, body) = res.into_parts();
2393                    let mut body = common::Body::new(body);
2394                    if !parts.status.is_success() {
2395                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2396                        let error = serde_json::from_str(&common::to_string(&bytes));
2397                        let response = common::to_response(parts, bytes.into());
2398
2399                        if let common::Retry::After(d) =
2400                            dlg.http_failure(&response, error.as_ref().ok())
2401                        {
2402                            sleep(d).await;
2403                            continue;
2404                        }
2405
2406                        dlg.finished(false);
2407
2408                        return Err(match error {
2409                            Ok(value) => common::Error::BadRequest(value),
2410                            _ => common::Error::Failure(response),
2411                        });
2412                    }
2413                    let response = {
2414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2415                        let encoded = common::to_string(&bytes);
2416                        match serde_json::from_str(&encoded) {
2417                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2418                            Err(error) => {
2419                                dlg.response_json_decode_error(&encoded, &error);
2420                                return Err(common::Error::JsonDecodeError(
2421                                    encoded.to_string(),
2422                                    error,
2423                                ));
2424                            }
2425                        }
2426                    };
2427
2428                    dlg.finished(true);
2429                    return Ok(response);
2430                }
2431            }
2432        }
2433    }
2434
2435    /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2436    ///
2437    /// Sets the *name* path property to the given value.
2438    ///
2439    /// Even though the property as already been set when instantiating this call,
2440    /// we provide this method for API completeness.
2441    pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
2442        self._name = new_value.to_string();
2443        self
2444    }
2445    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2446    /// while executing the actual API request.
2447    ///
2448    /// ````text
2449    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2450    /// ````
2451    ///
2452    /// Sets the *delegate* property to the given value.
2453    pub fn delegate(
2454        mut self,
2455        new_value: &'a mut dyn common::Delegate,
2456    ) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
2457        self._delegate = Some(new_value);
2458        self
2459    }
2460
2461    /// Set any additional parameter of the query string used in the request.
2462    /// It should be used to set parameters which are not yet available through their own
2463    /// setters.
2464    ///
2465    /// Please note that this method must not be used to set any of the known parameters
2466    /// which have their own setter method. If done anyway, the request will fail.
2467    ///
2468    /// # Additional Parameters
2469    ///
2470    /// * *$.xgafv* (query-string) - V1 error format.
2471    /// * *access_token* (query-string) - OAuth access token.
2472    /// * *alt* (query-string) - Data format for response.
2473    /// * *callback* (query-string) - JSONP
2474    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2475    /// * *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.
2476    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2477    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2478    /// * *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.
2479    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2480    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2481    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskDeleteCall<'a, C>
2482    where
2483        T: AsRef<str>,
2484    {
2485        self._additional_params
2486            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2487        self
2488    }
2489
2490    /// Identifies the authorization scope for the method you are building.
2491    ///
2492    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2493    /// [`Scope::CloudPlatform`].
2494    ///
2495    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2496    /// tokens for more than one scope.
2497    ///
2498    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2499    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2500    /// sufficient, a read-write scope will do as well.
2501    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskDeleteCall<'a, C>
2502    where
2503        St: AsRef<str>,
2504    {
2505        self._scopes.insert(String::from(scope.as_ref()));
2506        self
2507    }
2508    /// Identifies the authorization scope(s) for the method you are building.
2509    ///
2510    /// See [`Self::add_scope()`] for details.
2511    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskDeleteCall<'a, C>
2512    where
2513        I: IntoIterator<Item = St>,
2514        St: AsRef<str>,
2515    {
2516        self._scopes
2517            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2518        self
2519    }
2520
2521    /// Removes all scopes, and no default scope will be used either.
2522    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2523    /// for details).
2524    pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskDeleteCall<'a, C> {
2525        self._scopes.clear();
2526        self
2527    }
2528}
2529
2530/// Gets a task. After a task is successfully executed or has exhausted its retry attempts, the task is deleted. A `GetTask` request for a deleted task returns a `NOT_FOUND` error.
2531///
2532/// A builder for the *locations.queues.tasks.get* method supported by a *project* resource.
2533/// It is not used directly, but through a [`ProjectMethods`] instance.
2534///
2535/// # Example
2536///
2537/// Instantiate a resource method builder
2538///
2539/// ```test_harness,no_run
2540/// # extern crate hyper;
2541/// # extern crate hyper_rustls;
2542/// # extern crate google_cloudtasks2 as cloudtasks2;
2543/// # async fn dox() {
2544/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2545///
2546/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2547/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2548/// #     .with_native_roots()
2549/// #     .unwrap()
2550/// #     .https_only()
2551/// #     .enable_http2()
2552/// #     .build();
2553///
2554/// # let executor = hyper_util::rt::TokioExecutor::new();
2555/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2556/// #     secret,
2557/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2558/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2559/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2560/// #     ),
2561/// # ).build().await.unwrap();
2562///
2563/// # let client = hyper_util::client::legacy::Client::builder(
2564/// #     hyper_util::rt::TokioExecutor::new()
2565/// # )
2566/// # .build(
2567/// #     hyper_rustls::HttpsConnectorBuilder::new()
2568/// #         .with_native_roots()
2569/// #         .unwrap()
2570/// #         .https_or_http()
2571/// #         .enable_http2()
2572/// #         .build()
2573/// # );
2574/// # let mut hub = CloudTasks::new(client, auth);
2575/// // You can configure optional parameters by calling the respective setters at will, and
2576/// // execute the final call using `doit()`.
2577/// // Values shown here are possibly random and not representative !
2578/// let result = hub.projects().locations_queues_tasks_get("name")
2579///              .response_view("amet.")
2580///              .doit().await;
2581/// # }
2582/// ```
2583pub struct ProjectLocationQueueTaskGetCall<'a, C>
2584where
2585    C: 'a,
2586{
2587    hub: &'a CloudTasks<C>,
2588    _name: String,
2589    _response_view: Option<String>,
2590    _delegate: Option<&'a mut dyn common::Delegate>,
2591    _additional_params: HashMap<String, String>,
2592    _scopes: BTreeSet<String>,
2593}
2594
2595impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskGetCall<'a, C> {}
2596
2597impl<'a, C> ProjectLocationQueueTaskGetCall<'a, C>
2598where
2599    C: common::Connector,
2600{
2601    /// Perform the operation you have build so far.
2602    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
2603        use std::borrow::Cow;
2604        use std::io::{Read, Seek};
2605
2606        use common::{url::Params, ToParts};
2607        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2608
2609        let mut dd = common::DefaultDelegate;
2610        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2611        dlg.begin(common::MethodInfo {
2612            id: "cloudtasks.projects.locations.queues.tasks.get",
2613            http_method: hyper::Method::GET,
2614        });
2615
2616        for &field in ["alt", "name", "responseView"].iter() {
2617            if self._additional_params.contains_key(field) {
2618                dlg.finished(false);
2619                return Err(common::Error::FieldClash(field));
2620            }
2621        }
2622
2623        let mut params = Params::with_capacity(4 + self._additional_params.len());
2624        params.push("name", self._name);
2625        if let Some(value) = self._response_view.as_ref() {
2626            params.push("responseView", value);
2627        }
2628
2629        params.extend(self._additional_params.iter());
2630
2631        params.push("alt", "json");
2632        let mut url = self.hub._base_url.clone() + "v2/{+name}";
2633        if self._scopes.is_empty() {
2634            self._scopes
2635                .insert(Scope::CloudPlatform.as_ref().to_string());
2636        }
2637
2638        #[allow(clippy::single_element_loop)]
2639        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2640            url = params.uri_replacement(url, param_name, find_this, true);
2641        }
2642        {
2643            let to_remove = ["name"];
2644            params.remove_params(&to_remove);
2645        }
2646
2647        let url = params.parse_with_url(&url);
2648
2649        loop {
2650            let token = match self
2651                .hub
2652                .auth
2653                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2654                .await
2655            {
2656                Ok(token) => token,
2657                Err(e) => match dlg.token(e) {
2658                    Ok(token) => token,
2659                    Err(e) => {
2660                        dlg.finished(false);
2661                        return Err(common::Error::MissingToken(e));
2662                    }
2663                },
2664            };
2665            let mut req_result = {
2666                let client = &self.hub.client;
2667                dlg.pre_request();
2668                let mut req_builder = hyper::Request::builder()
2669                    .method(hyper::Method::GET)
2670                    .uri(url.as_str())
2671                    .header(USER_AGENT, self.hub._user_agent.clone());
2672
2673                if let Some(token) = token.as_ref() {
2674                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2675                }
2676
2677                let request = req_builder
2678                    .header(CONTENT_LENGTH, 0_u64)
2679                    .body(common::to_body::<String>(None));
2680
2681                client.request(request.unwrap()).await
2682            };
2683
2684            match req_result {
2685                Err(err) => {
2686                    if let common::Retry::After(d) = dlg.http_error(&err) {
2687                        sleep(d).await;
2688                        continue;
2689                    }
2690                    dlg.finished(false);
2691                    return Err(common::Error::HttpError(err));
2692                }
2693                Ok(res) => {
2694                    let (mut parts, body) = res.into_parts();
2695                    let mut body = common::Body::new(body);
2696                    if !parts.status.is_success() {
2697                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2698                        let error = serde_json::from_str(&common::to_string(&bytes));
2699                        let response = common::to_response(parts, bytes.into());
2700
2701                        if let common::Retry::After(d) =
2702                            dlg.http_failure(&response, error.as_ref().ok())
2703                        {
2704                            sleep(d).await;
2705                            continue;
2706                        }
2707
2708                        dlg.finished(false);
2709
2710                        return Err(match error {
2711                            Ok(value) => common::Error::BadRequest(value),
2712                            _ => common::Error::Failure(response),
2713                        });
2714                    }
2715                    let response = {
2716                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2717                        let encoded = common::to_string(&bytes);
2718                        match serde_json::from_str(&encoded) {
2719                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2720                            Err(error) => {
2721                                dlg.response_json_decode_error(&encoded, &error);
2722                                return Err(common::Error::JsonDecodeError(
2723                                    encoded.to_string(),
2724                                    error,
2725                                ));
2726                            }
2727                        }
2728                    };
2729
2730                    dlg.finished(true);
2731                    return Ok(response);
2732                }
2733            }
2734        }
2735    }
2736
2737    /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2738    ///
2739    /// Sets the *name* path property to the given value.
2740    ///
2741    /// Even though the property as already been set when instantiating this call,
2742    /// we provide this method for API completeness.
2743    pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
2744        self._name = new_value.to_string();
2745        self
2746    }
2747    /// 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.
2748    ///
2749    /// Sets the *response view* query property to the given value.
2750    pub fn response_view(mut self, new_value: &str) -> ProjectLocationQueueTaskGetCall<'a, C> {
2751        self._response_view = Some(new_value.to_string());
2752        self
2753    }
2754    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2755    /// while executing the actual API request.
2756    ///
2757    /// ````text
2758    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2759    /// ````
2760    ///
2761    /// Sets the *delegate* property to the given value.
2762    pub fn delegate(
2763        mut self,
2764        new_value: &'a mut dyn common::Delegate,
2765    ) -> ProjectLocationQueueTaskGetCall<'a, C> {
2766        self._delegate = Some(new_value);
2767        self
2768    }
2769
2770    /// Set any additional parameter of the query string used in the request.
2771    /// It should be used to set parameters which are not yet available through their own
2772    /// setters.
2773    ///
2774    /// Please note that this method must not be used to set any of the known parameters
2775    /// which have their own setter method. If done anyway, the request will fail.
2776    ///
2777    /// # Additional Parameters
2778    ///
2779    /// * *$.xgafv* (query-string) - V1 error format.
2780    /// * *access_token* (query-string) - OAuth access token.
2781    /// * *alt* (query-string) - Data format for response.
2782    /// * *callback* (query-string) - JSONP
2783    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2784    /// * *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.
2785    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2786    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2787    /// * *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.
2788    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2789    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2790    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskGetCall<'a, C>
2791    where
2792        T: AsRef<str>,
2793    {
2794        self._additional_params
2795            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2796        self
2797    }
2798
2799    /// Identifies the authorization scope for the method you are building.
2800    ///
2801    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2802    /// [`Scope::CloudPlatform`].
2803    ///
2804    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2805    /// tokens for more than one scope.
2806    ///
2807    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2808    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2809    /// sufficient, a read-write scope will do as well.
2810    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskGetCall<'a, C>
2811    where
2812        St: AsRef<str>,
2813    {
2814        self._scopes.insert(String::from(scope.as_ref()));
2815        self
2816    }
2817    /// Identifies the authorization scope(s) for the method you are building.
2818    ///
2819    /// See [`Self::add_scope()`] for details.
2820    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskGetCall<'a, C>
2821    where
2822        I: IntoIterator<Item = St>,
2823        St: AsRef<str>,
2824    {
2825        self._scopes
2826            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2827        self
2828    }
2829
2830    /// Removes all scopes, and no default scope will be used either.
2831    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2832    /// for details).
2833    pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskGetCall<'a, C> {
2834        self._scopes.clear();
2835        self
2836    }
2837}
2838
2839/// 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.
2840///
2841/// A builder for the *locations.queues.tasks.list* method supported by a *project* resource.
2842/// It is not used directly, but through a [`ProjectMethods`] instance.
2843///
2844/// # Example
2845///
2846/// Instantiate a resource method builder
2847///
2848/// ```test_harness,no_run
2849/// # extern crate hyper;
2850/// # extern crate hyper_rustls;
2851/// # extern crate google_cloudtasks2 as cloudtasks2;
2852/// # async fn dox() {
2853/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2854///
2855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2856/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2857/// #     .with_native_roots()
2858/// #     .unwrap()
2859/// #     .https_only()
2860/// #     .enable_http2()
2861/// #     .build();
2862///
2863/// # let executor = hyper_util::rt::TokioExecutor::new();
2864/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2865/// #     secret,
2866/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2867/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2868/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2869/// #     ),
2870/// # ).build().await.unwrap();
2871///
2872/// # let client = hyper_util::client::legacy::Client::builder(
2873/// #     hyper_util::rt::TokioExecutor::new()
2874/// # )
2875/// # .build(
2876/// #     hyper_rustls::HttpsConnectorBuilder::new()
2877/// #         .with_native_roots()
2878/// #         .unwrap()
2879/// #         .https_or_http()
2880/// #         .enable_http2()
2881/// #         .build()
2882/// # );
2883/// # let mut hub = CloudTasks::new(client, auth);
2884/// // You can configure optional parameters by calling the respective setters at will, and
2885/// // execute the final call using `doit()`.
2886/// // Values shown here are possibly random and not representative !
2887/// let result = hub.projects().locations_queues_tasks_list("parent")
2888///              .response_view("amet.")
2889///              .page_token("duo")
2890///              .page_size(-55)
2891///              .doit().await;
2892/// # }
2893/// ```
2894pub struct ProjectLocationQueueTaskListCall<'a, C>
2895where
2896    C: 'a,
2897{
2898    hub: &'a CloudTasks<C>,
2899    _parent: String,
2900    _response_view: Option<String>,
2901    _page_token: Option<String>,
2902    _page_size: Option<i32>,
2903    _delegate: Option<&'a mut dyn common::Delegate>,
2904    _additional_params: HashMap<String, String>,
2905    _scopes: BTreeSet<String>,
2906}
2907
2908impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskListCall<'a, C> {}
2909
2910impl<'a, C> ProjectLocationQueueTaskListCall<'a, C>
2911where
2912    C: common::Connector,
2913{
2914    /// Perform the operation you have build so far.
2915    pub async fn doit(mut self) -> common::Result<(common::Response, ListTasksResponse)> {
2916        use std::borrow::Cow;
2917        use std::io::{Read, Seek};
2918
2919        use common::{url::Params, ToParts};
2920        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2921
2922        let mut dd = common::DefaultDelegate;
2923        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2924        dlg.begin(common::MethodInfo {
2925            id: "cloudtasks.projects.locations.queues.tasks.list",
2926            http_method: hyper::Method::GET,
2927        });
2928
2929        for &field in ["alt", "parent", "responseView", "pageToken", "pageSize"].iter() {
2930            if self._additional_params.contains_key(field) {
2931                dlg.finished(false);
2932                return Err(common::Error::FieldClash(field));
2933            }
2934        }
2935
2936        let mut params = Params::with_capacity(6 + self._additional_params.len());
2937        params.push("parent", self._parent);
2938        if let Some(value) = self._response_view.as_ref() {
2939            params.push("responseView", value);
2940        }
2941        if let Some(value) = self._page_token.as_ref() {
2942            params.push("pageToken", value);
2943        }
2944        if let Some(value) = self._page_size.as_ref() {
2945            params.push("pageSize", value.to_string());
2946        }
2947
2948        params.extend(self._additional_params.iter());
2949
2950        params.push("alt", "json");
2951        let mut url = self.hub._base_url.clone() + "v2/{+parent}/tasks";
2952        if self._scopes.is_empty() {
2953            self._scopes
2954                .insert(Scope::CloudPlatform.as_ref().to_string());
2955        }
2956
2957        #[allow(clippy::single_element_loop)]
2958        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2959            url = params.uri_replacement(url, param_name, find_this, true);
2960        }
2961        {
2962            let to_remove = ["parent"];
2963            params.remove_params(&to_remove);
2964        }
2965
2966        let url = params.parse_with_url(&url);
2967
2968        loop {
2969            let token = match self
2970                .hub
2971                .auth
2972                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2973                .await
2974            {
2975                Ok(token) => token,
2976                Err(e) => match dlg.token(e) {
2977                    Ok(token) => token,
2978                    Err(e) => {
2979                        dlg.finished(false);
2980                        return Err(common::Error::MissingToken(e));
2981                    }
2982                },
2983            };
2984            let mut req_result = {
2985                let client = &self.hub.client;
2986                dlg.pre_request();
2987                let mut req_builder = hyper::Request::builder()
2988                    .method(hyper::Method::GET)
2989                    .uri(url.as_str())
2990                    .header(USER_AGENT, self.hub._user_agent.clone());
2991
2992                if let Some(token) = token.as_ref() {
2993                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2994                }
2995
2996                let request = req_builder
2997                    .header(CONTENT_LENGTH, 0_u64)
2998                    .body(common::to_body::<String>(None));
2999
3000                client.request(request.unwrap()).await
3001            };
3002
3003            match req_result {
3004                Err(err) => {
3005                    if let common::Retry::After(d) = dlg.http_error(&err) {
3006                        sleep(d).await;
3007                        continue;
3008                    }
3009                    dlg.finished(false);
3010                    return Err(common::Error::HttpError(err));
3011                }
3012                Ok(res) => {
3013                    let (mut parts, body) = res.into_parts();
3014                    let mut body = common::Body::new(body);
3015                    if !parts.status.is_success() {
3016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3017                        let error = serde_json::from_str(&common::to_string(&bytes));
3018                        let response = common::to_response(parts, bytes.into());
3019
3020                        if let common::Retry::After(d) =
3021                            dlg.http_failure(&response, error.as_ref().ok())
3022                        {
3023                            sleep(d).await;
3024                            continue;
3025                        }
3026
3027                        dlg.finished(false);
3028
3029                        return Err(match error {
3030                            Ok(value) => common::Error::BadRequest(value),
3031                            _ => common::Error::Failure(response),
3032                        });
3033                    }
3034                    let response = {
3035                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3036                        let encoded = common::to_string(&bytes);
3037                        match serde_json::from_str(&encoded) {
3038                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3039                            Err(error) => {
3040                                dlg.response_json_decode_error(&encoded, &error);
3041                                return Err(common::Error::JsonDecodeError(
3042                                    encoded.to_string(),
3043                                    error,
3044                                ));
3045                            }
3046                        }
3047                    };
3048
3049                    dlg.finished(true);
3050                    return Ok(response);
3051                }
3052            }
3053        }
3054    }
3055
3056    /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
3057    ///
3058    /// Sets the *parent* path property to the given value.
3059    ///
3060    /// Even though the property as already been set when instantiating this call,
3061    /// we provide this method for API completeness.
3062    pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
3063        self._parent = new_value.to_string();
3064        self
3065    }
3066    /// 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.
3067    ///
3068    /// Sets the *response view* query property to the given value.
3069    pub fn response_view(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
3070        self._response_view = Some(new_value.to_string());
3071        self
3072    }
3073    /// 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.
3074    ///
3075    /// Sets the *page token* query property to the given value.
3076    pub fn page_token(mut self, new_value: &str) -> ProjectLocationQueueTaskListCall<'a, C> {
3077        self._page_token = Some(new_value.to_string());
3078        self
3079    }
3080    /// 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.
3081    ///
3082    /// Sets the *page size* query property to the given value.
3083    pub fn page_size(mut self, new_value: i32) -> ProjectLocationQueueTaskListCall<'a, C> {
3084        self._page_size = Some(new_value);
3085        self
3086    }
3087    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3088    /// while executing the actual API request.
3089    ///
3090    /// ````text
3091    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3092    /// ````
3093    ///
3094    /// Sets the *delegate* property to the given value.
3095    pub fn delegate(
3096        mut self,
3097        new_value: &'a mut dyn common::Delegate,
3098    ) -> ProjectLocationQueueTaskListCall<'a, C> {
3099        self._delegate = Some(new_value);
3100        self
3101    }
3102
3103    /// Set any additional parameter of the query string used in the request.
3104    /// It should be used to set parameters which are not yet available through their own
3105    /// setters.
3106    ///
3107    /// Please note that this method must not be used to set any of the known parameters
3108    /// which have their own setter method. If done anyway, the request will fail.
3109    ///
3110    /// # Additional Parameters
3111    ///
3112    /// * *$.xgafv* (query-string) - V1 error format.
3113    /// * *access_token* (query-string) - OAuth access token.
3114    /// * *alt* (query-string) - Data format for response.
3115    /// * *callback* (query-string) - JSONP
3116    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3117    /// * *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.
3118    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3119    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3120    /// * *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.
3121    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3122    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3123    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskListCall<'a, C>
3124    where
3125        T: AsRef<str>,
3126    {
3127        self._additional_params
3128            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3129        self
3130    }
3131
3132    /// Identifies the authorization scope for the method you are building.
3133    ///
3134    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3135    /// [`Scope::CloudPlatform`].
3136    ///
3137    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3138    /// tokens for more than one scope.
3139    ///
3140    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3141    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3142    /// sufficient, a read-write scope will do as well.
3143    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskListCall<'a, C>
3144    where
3145        St: AsRef<str>,
3146    {
3147        self._scopes.insert(String::from(scope.as_ref()));
3148        self
3149    }
3150    /// Identifies the authorization scope(s) for the method you are building.
3151    ///
3152    /// See [`Self::add_scope()`] for details.
3153    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskListCall<'a, C>
3154    where
3155        I: IntoIterator<Item = St>,
3156        St: AsRef<str>,
3157    {
3158        self._scopes
3159            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3160        self
3161    }
3162
3163    /// Removes all scopes, and no default scope will be used either.
3164    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3165    /// for details).
3166    pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskListCall<'a, C> {
3167        self._scopes.clear();
3168        self
3169    }
3170}
3171
3172/// 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. 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.
3173///
3174/// A builder for the *locations.queues.tasks.run* method supported by a *project* resource.
3175/// It is not used directly, but through a [`ProjectMethods`] instance.
3176///
3177/// # Example
3178///
3179/// Instantiate a resource method builder
3180///
3181/// ```test_harness,no_run
3182/// # extern crate hyper;
3183/// # extern crate hyper_rustls;
3184/// # extern crate google_cloudtasks2 as cloudtasks2;
3185/// use cloudtasks2::api::RunTaskRequest;
3186/// # async fn dox() {
3187/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3188///
3189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3190/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3191/// #     .with_native_roots()
3192/// #     .unwrap()
3193/// #     .https_only()
3194/// #     .enable_http2()
3195/// #     .build();
3196///
3197/// # let executor = hyper_util::rt::TokioExecutor::new();
3198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3199/// #     secret,
3200/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3201/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3202/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3203/// #     ),
3204/// # ).build().await.unwrap();
3205///
3206/// # let client = hyper_util::client::legacy::Client::builder(
3207/// #     hyper_util::rt::TokioExecutor::new()
3208/// # )
3209/// # .build(
3210/// #     hyper_rustls::HttpsConnectorBuilder::new()
3211/// #         .with_native_roots()
3212/// #         .unwrap()
3213/// #         .https_or_http()
3214/// #         .enable_http2()
3215/// #         .build()
3216/// # );
3217/// # let mut hub = CloudTasks::new(client, auth);
3218/// // As the method needs a request, you would usually fill it with the desired information
3219/// // into the respective structure. Some of the parts shown here might not be applicable !
3220/// // Values shown here are possibly random and not representative !
3221/// let mut req = RunTaskRequest::default();
3222///
3223/// // You can configure optional parameters by calling the respective setters at will, and
3224/// // execute the final call using `doit()`.
3225/// // Values shown here are possibly random and not representative !
3226/// let result = hub.projects().locations_queues_tasks_run(req, "name")
3227///              .doit().await;
3228/// # }
3229/// ```
3230pub struct ProjectLocationQueueTaskRunCall<'a, C>
3231where
3232    C: 'a,
3233{
3234    hub: &'a CloudTasks<C>,
3235    _request: RunTaskRequest,
3236    _name: String,
3237    _delegate: Option<&'a mut dyn common::Delegate>,
3238    _additional_params: HashMap<String, String>,
3239    _scopes: BTreeSet<String>,
3240}
3241
3242impl<'a, C> common::CallBuilder for ProjectLocationQueueTaskRunCall<'a, C> {}
3243
3244impl<'a, C> ProjectLocationQueueTaskRunCall<'a, C>
3245where
3246    C: common::Connector,
3247{
3248    /// Perform the operation you have build so far.
3249    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3250        use std::borrow::Cow;
3251        use std::io::{Read, Seek};
3252
3253        use common::{url::Params, ToParts};
3254        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3255
3256        let mut dd = common::DefaultDelegate;
3257        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3258        dlg.begin(common::MethodInfo {
3259            id: "cloudtasks.projects.locations.queues.tasks.run",
3260            http_method: hyper::Method::POST,
3261        });
3262
3263        for &field in ["alt", "name"].iter() {
3264            if self._additional_params.contains_key(field) {
3265                dlg.finished(false);
3266                return Err(common::Error::FieldClash(field));
3267            }
3268        }
3269
3270        let mut params = Params::with_capacity(4 + self._additional_params.len());
3271        params.push("name", self._name);
3272
3273        params.extend(self._additional_params.iter());
3274
3275        params.push("alt", "json");
3276        let mut url = self.hub._base_url.clone() + "v2/{+name}:run";
3277        if self._scopes.is_empty() {
3278            self._scopes
3279                .insert(Scope::CloudPlatform.as_ref().to_string());
3280        }
3281
3282        #[allow(clippy::single_element_loop)]
3283        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3284            url = params.uri_replacement(url, param_name, find_this, true);
3285        }
3286        {
3287            let to_remove = ["name"];
3288            params.remove_params(&to_remove);
3289        }
3290
3291        let url = params.parse_with_url(&url);
3292
3293        let mut json_mime_type = mime::APPLICATION_JSON;
3294        let mut request_value_reader = {
3295            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3296            common::remove_json_null_values(&mut value);
3297            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3298            serde_json::to_writer(&mut dst, &value).unwrap();
3299            dst
3300        };
3301        let request_size = request_value_reader
3302            .seek(std::io::SeekFrom::End(0))
3303            .unwrap();
3304        request_value_reader
3305            .seek(std::io::SeekFrom::Start(0))
3306            .unwrap();
3307
3308        loop {
3309            let token = match self
3310                .hub
3311                .auth
3312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3313                .await
3314            {
3315                Ok(token) => token,
3316                Err(e) => match dlg.token(e) {
3317                    Ok(token) => token,
3318                    Err(e) => {
3319                        dlg.finished(false);
3320                        return Err(common::Error::MissingToken(e));
3321                    }
3322                },
3323            };
3324            request_value_reader
3325                .seek(std::io::SeekFrom::Start(0))
3326                .unwrap();
3327            let mut req_result = {
3328                let client = &self.hub.client;
3329                dlg.pre_request();
3330                let mut req_builder = hyper::Request::builder()
3331                    .method(hyper::Method::POST)
3332                    .uri(url.as_str())
3333                    .header(USER_AGENT, self.hub._user_agent.clone());
3334
3335                if let Some(token) = token.as_ref() {
3336                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3337                }
3338
3339                let request = req_builder
3340                    .header(CONTENT_TYPE, json_mime_type.to_string())
3341                    .header(CONTENT_LENGTH, request_size as u64)
3342                    .body(common::to_body(
3343                        request_value_reader.get_ref().clone().into(),
3344                    ));
3345
3346                client.request(request.unwrap()).await
3347            };
3348
3349            match req_result {
3350                Err(err) => {
3351                    if let common::Retry::After(d) = dlg.http_error(&err) {
3352                        sleep(d).await;
3353                        continue;
3354                    }
3355                    dlg.finished(false);
3356                    return Err(common::Error::HttpError(err));
3357                }
3358                Ok(res) => {
3359                    let (mut parts, body) = res.into_parts();
3360                    let mut body = common::Body::new(body);
3361                    if !parts.status.is_success() {
3362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3363                        let error = serde_json::from_str(&common::to_string(&bytes));
3364                        let response = common::to_response(parts, bytes.into());
3365
3366                        if let common::Retry::After(d) =
3367                            dlg.http_failure(&response, error.as_ref().ok())
3368                        {
3369                            sleep(d).await;
3370                            continue;
3371                        }
3372
3373                        dlg.finished(false);
3374
3375                        return Err(match error {
3376                            Ok(value) => common::Error::BadRequest(value),
3377                            _ => common::Error::Failure(response),
3378                        });
3379                    }
3380                    let response = {
3381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3382                        let encoded = common::to_string(&bytes);
3383                        match serde_json::from_str(&encoded) {
3384                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3385                            Err(error) => {
3386                                dlg.response_json_decode_error(&encoded, &error);
3387                                return Err(common::Error::JsonDecodeError(
3388                                    encoded.to_string(),
3389                                    error,
3390                                ));
3391                            }
3392                        }
3393                    };
3394
3395                    dlg.finished(true);
3396                    return Ok(response);
3397                }
3398            }
3399        }
3400    }
3401
3402    ///
3403    /// Sets the *request* property to the given value.
3404    ///
3405    /// Even though the property as already been set when instantiating this call,
3406    /// we provide this method for API completeness.
3407    pub fn request(mut self, new_value: RunTaskRequest) -> ProjectLocationQueueTaskRunCall<'a, C> {
3408        self._request = new_value;
3409        self
3410    }
3411    /// Required. The task name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
3412    ///
3413    /// Sets the *name* path property to the given value.
3414    ///
3415    /// Even though the property as already been set when instantiating this call,
3416    /// we provide this method for API completeness.
3417    pub fn name(mut self, new_value: &str) -> ProjectLocationQueueTaskRunCall<'a, C> {
3418        self._name = new_value.to_string();
3419        self
3420    }
3421    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3422    /// while executing the actual API request.
3423    ///
3424    /// ````text
3425    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3426    /// ````
3427    ///
3428    /// Sets the *delegate* property to the given value.
3429    pub fn delegate(
3430        mut self,
3431        new_value: &'a mut dyn common::Delegate,
3432    ) -> ProjectLocationQueueTaskRunCall<'a, C> {
3433        self._delegate = Some(new_value);
3434        self
3435    }
3436
3437    /// Set any additional parameter of the query string used in the request.
3438    /// It should be used to set parameters which are not yet available through their own
3439    /// setters.
3440    ///
3441    /// Please note that this method must not be used to set any of the known parameters
3442    /// which have their own setter method. If done anyway, the request will fail.
3443    ///
3444    /// # Additional Parameters
3445    ///
3446    /// * *$.xgafv* (query-string) - V1 error format.
3447    /// * *access_token* (query-string) - OAuth access token.
3448    /// * *alt* (query-string) - Data format for response.
3449    /// * *callback* (query-string) - JSONP
3450    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3451    /// * *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.
3452    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3453    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3454    /// * *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.
3455    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3456    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3457    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTaskRunCall<'a, C>
3458    where
3459        T: AsRef<str>,
3460    {
3461        self._additional_params
3462            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3463        self
3464    }
3465
3466    /// Identifies the authorization scope for the method you are building.
3467    ///
3468    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3469    /// [`Scope::CloudPlatform`].
3470    ///
3471    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3472    /// tokens for more than one scope.
3473    ///
3474    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3475    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3476    /// sufficient, a read-write scope will do as well.
3477    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTaskRunCall<'a, C>
3478    where
3479        St: AsRef<str>,
3480    {
3481        self._scopes.insert(String::from(scope.as_ref()));
3482        self
3483    }
3484    /// Identifies the authorization scope(s) for the method you are building.
3485    ///
3486    /// See [`Self::add_scope()`] for details.
3487    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueTaskRunCall<'a, C>
3488    where
3489        I: IntoIterator<Item = St>,
3490        St: AsRef<str>,
3491    {
3492        self._scopes
3493            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3494        self
3495    }
3496
3497    /// Removes all scopes, and no default scope will be used either.
3498    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3499    /// for details).
3500    pub fn clear_scopes(mut self) -> ProjectLocationQueueTaskRunCall<'a, C> {
3501        self._scopes.clear();
3502        self
3503    }
3504}
3505
3506/// 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.
3507///
3508/// A builder for the *locations.queues.create* method supported by a *project* resource.
3509/// It is not used directly, but through a [`ProjectMethods`] instance.
3510///
3511/// # Example
3512///
3513/// Instantiate a resource method builder
3514///
3515/// ```test_harness,no_run
3516/// # extern crate hyper;
3517/// # extern crate hyper_rustls;
3518/// # extern crate google_cloudtasks2 as cloudtasks2;
3519/// use cloudtasks2::api::Queue;
3520/// # async fn dox() {
3521/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3522///
3523/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3524/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3525/// #     .with_native_roots()
3526/// #     .unwrap()
3527/// #     .https_only()
3528/// #     .enable_http2()
3529/// #     .build();
3530///
3531/// # let executor = hyper_util::rt::TokioExecutor::new();
3532/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3533/// #     secret,
3534/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3535/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3536/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3537/// #     ),
3538/// # ).build().await.unwrap();
3539///
3540/// # let client = hyper_util::client::legacy::Client::builder(
3541/// #     hyper_util::rt::TokioExecutor::new()
3542/// # )
3543/// # .build(
3544/// #     hyper_rustls::HttpsConnectorBuilder::new()
3545/// #         .with_native_roots()
3546/// #         .unwrap()
3547/// #         .https_or_http()
3548/// #         .enable_http2()
3549/// #         .build()
3550/// # );
3551/// # let mut hub = CloudTasks::new(client, auth);
3552/// // As the method needs a request, you would usually fill it with the desired information
3553/// // into the respective structure. Some of the parts shown here might not be applicable !
3554/// // Values shown here are possibly random and not representative !
3555/// let mut req = Queue::default();
3556///
3557/// // You can configure optional parameters by calling the respective setters at will, and
3558/// // execute the final call using `doit()`.
3559/// // Values shown here are possibly random and not representative !
3560/// let result = hub.projects().locations_queues_create(req, "parent")
3561///              .doit().await;
3562/// # }
3563/// ```
3564pub struct ProjectLocationQueueCreateCall<'a, C>
3565where
3566    C: 'a,
3567{
3568    hub: &'a CloudTasks<C>,
3569    _request: Queue,
3570    _parent: String,
3571    _delegate: Option<&'a mut dyn common::Delegate>,
3572    _additional_params: HashMap<String, String>,
3573    _scopes: BTreeSet<String>,
3574}
3575
3576impl<'a, C> common::CallBuilder for ProjectLocationQueueCreateCall<'a, C> {}
3577
3578impl<'a, C> ProjectLocationQueueCreateCall<'a, C>
3579where
3580    C: common::Connector,
3581{
3582    /// Perform the operation you have build so far.
3583    pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
3584        use std::borrow::Cow;
3585        use std::io::{Read, Seek};
3586
3587        use common::{url::Params, ToParts};
3588        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3589
3590        let mut dd = common::DefaultDelegate;
3591        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3592        dlg.begin(common::MethodInfo {
3593            id: "cloudtasks.projects.locations.queues.create",
3594            http_method: hyper::Method::POST,
3595        });
3596
3597        for &field in ["alt", "parent"].iter() {
3598            if self._additional_params.contains_key(field) {
3599                dlg.finished(false);
3600                return Err(common::Error::FieldClash(field));
3601            }
3602        }
3603
3604        let mut params = Params::with_capacity(4 + self._additional_params.len());
3605        params.push("parent", self._parent);
3606
3607        params.extend(self._additional_params.iter());
3608
3609        params.push("alt", "json");
3610        let mut url = self.hub._base_url.clone() + "v2/{+parent}/queues";
3611        if self._scopes.is_empty() {
3612            self._scopes
3613                .insert(Scope::CloudPlatform.as_ref().to_string());
3614        }
3615
3616        #[allow(clippy::single_element_loop)]
3617        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3618            url = params.uri_replacement(url, param_name, find_this, true);
3619        }
3620        {
3621            let to_remove = ["parent"];
3622            params.remove_params(&to_remove);
3623        }
3624
3625        let url = params.parse_with_url(&url);
3626
3627        let mut json_mime_type = mime::APPLICATION_JSON;
3628        let mut request_value_reader = {
3629            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3630            common::remove_json_null_values(&mut value);
3631            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3632            serde_json::to_writer(&mut dst, &value).unwrap();
3633            dst
3634        };
3635        let request_size = request_value_reader
3636            .seek(std::io::SeekFrom::End(0))
3637            .unwrap();
3638        request_value_reader
3639            .seek(std::io::SeekFrom::Start(0))
3640            .unwrap();
3641
3642        loop {
3643            let token = match self
3644                .hub
3645                .auth
3646                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3647                .await
3648            {
3649                Ok(token) => token,
3650                Err(e) => match dlg.token(e) {
3651                    Ok(token) => token,
3652                    Err(e) => {
3653                        dlg.finished(false);
3654                        return Err(common::Error::MissingToken(e));
3655                    }
3656                },
3657            };
3658            request_value_reader
3659                .seek(std::io::SeekFrom::Start(0))
3660                .unwrap();
3661            let mut req_result = {
3662                let client = &self.hub.client;
3663                dlg.pre_request();
3664                let mut req_builder = hyper::Request::builder()
3665                    .method(hyper::Method::POST)
3666                    .uri(url.as_str())
3667                    .header(USER_AGENT, self.hub._user_agent.clone());
3668
3669                if let Some(token) = token.as_ref() {
3670                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3671                }
3672
3673                let request = req_builder
3674                    .header(CONTENT_TYPE, json_mime_type.to_string())
3675                    .header(CONTENT_LENGTH, request_size as u64)
3676                    .body(common::to_body(
3677                        request_value_reader.get_ref().clone().into(),
3678                    ));
3679
3680                client.request(request.unwrap()).await
3681            };
3682
3683            match req_result {
3684                Err(err) => {
3685                    if let common::Retry::After(d) = dlg.http_error(&err) {
3686                        sleep(d).await;
3687                        continue;
3688                    }
3689                    dlg.finished(false);
3690                    return Err(common::Error::HttpError(err));
3691                }
3692                Ok(res) => {
3693                    let (mut parts, body) = res.into_parts();
3694                    let mut body = common::Body::new(body);
3695                    if !parts.status.is_success() {
3696                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3697                        let error = serde_json::from_str(&common::to_string(&bytes));
3698                        let response = common::to_response(parts, bytes.into());
3699
3700                        if let common::Retry::After(d) =
3701                            dlg.http_failure(&response, error.as_ref().ok())
3702                        {
3703                            sleep(d).await;
3704                            continue;
3705                        }
3706
3707                        dlg.finished(false);
3708
3709                        return Err(match error {
3710                            Ok(value) => common::Error::BadRequest(value),
3711                            _ => common::Error::Failure(response),
3712                        });
3713                    }
3714                    let response = {
3715                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3716                        let encoded = common::to_string(&bytes);
3717                        match serde_json::from_str(&encoded) {
3718                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3719                            Err(error) => {
3720                                dlg.response_json_decode_error(&encoded, &error);
3721                                return Err(common::Error::JsonDecodeError(
3722                                    encoded.to_string(),
3723                                    error,
3724                                ));
3725                            }
3726                        }
3727                    };
3728
3729                    dlg.finished(true);
3730                    return Ok(response);
3731                }
3732            }
3733        }
3734    }
3735
3736    ///
3737    /// Sets the *request* property to the given value.
3738    ///
3739    /// Even though the property as already been set when instantiating this call,
3740    /// we provide this method for API completeness.
3741    pub fn request(mut self, new_value: Queue) -> ProjectLocationQueueCreateCall<'a, C> {
3742        self._request = new_value;
3743        self
3744    }
3745    /// 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.
3746    ///
3747    /// Sets the *parent* path property to the given value.
3748    ///
3749    /// Even though the property as already been set when instantiating this call,
3750    /// we provide this method for API completeness.
3751    pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueCreateCall<'a, C> {
3752        self._parent = new_value.to_string();
3753        self
3754    }
3755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3756    /// while executing the actual API request.
3757    ///
3758    /// ````text
3759    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3760    /// ````
3761    ///
3762    /// Sets the *delegate* property to the given value.
3763    pub fn delegate(
3764        mut self,
3765        new_value: &'a mut dyn common::Delegate,
3766    ) -> ProjectLocationQueueCreateCall<'a, C> {
3767        self._delegate = Some(new_value);
3768        self
3769    }
3770
3771    /// Set any additional parameter of the query string used in the request.
3772    /// It should be used to set parameters which are not yet available through their own
3773    /// setters.
3774    ///
3775    /// Please note that this method must not be used to set any of the known parameters
3776    /// which have their own setter method. If done anyway, the request will fail.
3777    ///
3778    /// # Additional Parameters
3779    ///
3780    /// * *$.xgafv* (query-string) - V1 error format.
3781    /// * *access_token* (query-string) - OAuth access token.
3782    /// * *alt* (query-string) - Data format for response.
3783    /// * *callback* (query-string) - JSONP
3784    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3785    /// * *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.
3786    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3787    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3788    /// * *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.
3789    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3790    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3791    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueCreateCall<'a, C>
3792    where
3793        T: AsRef<str>,
3794    {
3795        self._additional_params
3796            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3797        self
3798    }
3799
3800    /// Identifies the authorization scope for the method you are building.
3801    ///
3802    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3803    /// [`Scope::CloudPlatform`].
3804    ///
3805    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3806    /// tokens for more than one scope.
3807    ///
3808    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3809    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3810    /// sufficient, a read-write scope will do as well.
3811    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueCreateCall<'a, C>
3812    where
3813        St: AsRef<str>,
3814    {
3815        self._scopes.insert(String::from(scope.as_ref()));
3816        self
3817    }
3818    /// Identifies the authorization scope(s) for the method you are building.
3819    ///
3820    /// See [`Self::add_scope()`] for details.
3821    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueCreateCall<'a, C>
3822    where
3823        I: IntoIterator<Item = St>,
3824        St: AsRef<str>,
3825    {
3826        self._scopes
3827            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3828        self
3829    }
3830
3831    /// Removes all scopes, and no default scope will be used either.
3832    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3833    /// for details).
3834    pub fn clear_scopes(mut self) -> ProjectLocationQueueCreateCall<'a, C> {
3835        self._scopes.clear();
3836        self
3837    }
3838}
3839
3840/// 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.
3841///
3842/// A builder for the *locations.queues.delete* method supported by a *project* resource.
3843/// It is not used directly, but through a [`ProjectMethods`] instance.
3844///
3845/// # Example
3846///
3847/// Instantiate a resource method builder
3848///
3849/// ```test_harness,no_run
3850/// # extern crate hyper;
3851/// # extern crate hyper_rustls;
3852/// # extern crate google_cloudtasks2 as cloudtasks2;
3853/// # async fn dox() {
3854/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3855///
3856/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3857/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3858/// #     .with_native_roots()
3859/// #     .unwrap()
3860/// #     .https_only()
3861/// #     .enable_http2()
3862/// #     .build();
3863///
3864/// # let executor = hyper_util::rt::TokioExecutor::new();
3865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3866/// #     secret,
3867/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3868/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3869/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3870/// #     ),
3871/// # ).build().await.unwrap();
3872///
3873/// # let client = hyper_util::client::legacy::Client::builder(
3874/// #     hyper_util::rt::TokioExecutor::new()
3875/// # )
3876/// # .build(
3877/// #     hyper_rustls::HttpsConnectorBuilder::new()
3878/// #         .with_native_roots()
3879/// #         .unwrap()
3880/// #         .https_or_http()
3881/// #         .enable_http2()
3882/// #         .build()
3883/// # );
3884/// # let mut hub = CloudTasks::new(client, auth);
3885/// // You can configure optional parameters by calling the respective setters at will, and
3886/// // execute the final call using `doit()`.
3887/// // Values shown here are possibly random and not representative !
3888/// let result = hub.projects().locations_queues_delete("name")
3889///              .doit().await;
3890/// # }
3891/// ```
3892pub struct ProjectLocationQueueDeleteCall<'a, C>
3893where
3894    C: 'a,
3895{
3896    hub: &'a CloudTasks<C>,
3897    _name: String,
3898    _delegate: Option<&'a mut dyn common::Delegate>,
3899    _additional_params: HashMap<String, String>,
3900    _scopes: BTreeSet<String>,
3901}
3902
3903impl<'a, C> common::CallBuilder for ProjectLocationQueueDeleteCall<'a, C> {}
3904
3905impl<'a, C> ProjectLocationQueueDeleteCall<'a, C>
3906where
3907    C: common::Connector,
3908{
3909    /// Perform the operation you have build so far.
3910    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3911        use std::borrow::Cow;
3912        use std::io::{Read, Seek};
3913
3914        use common::{url::Params, ToParts};
3915        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3916
3917        let mut dd = common::DefaultDelegate;
3918        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3919        dlg.begin(common::MethodInfo {
3920            id: "cloudtasks.projects.locations.queues.delete",
3921            http_method: hyper::Method::DELETE,
3922        });
3923
3924        for &field in ["alt", "name"].iter() {
3925            if self._additional_params.contains_key(field) {
3926                dlg.finished(false);
3927                return Err(common::Error::FieldClash(field));
3928            }
3929        }
3930
3931        let mut params = Params::with_capacity(3 + self._additional_params.len());
3932        params.push("name", self._name);
3933
3934        params.extend(self._additional_params.iter());
3935
3936        params.push("alt", "json");
3937        let mut url = self.hub._base_url.clone() + "v2/{+name}";
3938        if self._scopes.is_empty() {
3939            self._scopes
3940                .insert(Scope::CloudPlatform.as_ref().to_string());
3941        }
3942
3943        #[allow(clippy::single_element_loop)]
3944        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3945            url = params.uri_replacement(url, param_name, find_this, true);
3946        }
3947        {
3948            let to_remove = ["name"];
3949            params.remove_params(&to_remove);
3950        }
3951
3952        let url = params.parse_with_url(&url);
3953
3954        loop {
3955            let token = match self
3956                .hub
3957                .auth
3958                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3959                .await
3960            {
3961                Ok(token) => token,
3962                Err(e) => match dlg.token(e) {
3963                    Ok(token) => token,
3964                    Err(e) => {
3965                        dlg.finished(false);
3966                        return Err(common::Error::MissingToken(e));
3967                    }
3968                },
3969            };
3970            let mut req_result = {
3971                let client = &self.hub.client;
3972                dlg.pre_request();
3973                let mut req_builder = hyper::Request::builder()
3974                    .method(hyper::Method::DELETE)
3975                    .uri(url.as_str())
3976                    .header(USER_AGENT, self.hub._user_agent.clone());
3977
3978                if let Some(token) = token.as_ref() {
3979                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3980                }
3981
3982                let request = req_builder
3983                    .header(CONTENT_LENGTH, 0_u64)
3984                    .body(common::to_body::<String>(None));
3985
3986                client.request(request.unwrap()).await
3987            };
3988
3989            match req_result {
3990                Err(err) => {
3991                    if let common::Retry::After(d) = dlg.http_error(&err) {
3992                        sleep(d).await;
3993                        continue;
3994                    }
3995                    dlg.finished(false);
3996                    return Err(common::Error::HttpError(err));
3997                }
3998                Ok(res) => {
3999                    let (mut parts, body) = res.into_parts();
4000                    let mut body = common::Body::new(body);
4001                    if !parts.status.is_success() {
4002                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4003                        let error = serde_json::from_str(&common::to_string(&bytes));
4004                        let response = common::to_response(parts, bytes.into());
4005
4006                        if let common::Retry::After(d) =
4007                            dlg.http_failure(&response, error.as_ref().ok())
4008                        {
4009                            sleep(d).await;
4010                            continue;
4011                        }
4012
4013                        dlg.finished(false);
4014
4015                        return Err(match error {
4016                            Ok(value) => common::Error::BadRequest(value),
4017                            _ => common::Error::Failure(response),
4018                        });
4019                    }
4020                    let response = {
4021                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4022                        let encoded = common::to_string(&bytes);
4023                        match serde_json::from_str(&encoded) {
4024                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4025                            Err(error) => {
4026                                dlg.response_json_decode_error(&encoded, &error);
4027                                return Err(common::Error::JsonDecodeError(
4028                                    encoded.to_string(),
4029                                    error,
4030                                ));
4031                            }
4032                        }
4033                    };
4034
4035                    dlg.finished(true);
4036                    return Ok(response);
4037                }
4038            }
4039        }
4040    }
4041
4042    /// Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
4043    ///
4044    /// Sets the *name* path property to the given value.
4045    ///
4046    /// Even though the property as already been set when instantiating this call,
4047    /// we provide this method for API completeness.
4048    pub fn name(mut self, new_value: &str) -> ProjectLocationQueueDeleteCall<'a, C> {
4049        self._name = new_value.to_string();
4050        self
4051    }
4052    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4053    /// while executing the actual API request.
4054    ///
4055    /// ````text
4056    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4057    /// ````
4058    ///
4059    /// Sets the *delegate* property to the given value.
4060    pub fn delegate(
4061        mut self,
4062        new_value: &'a mut dyn common::Delegate,
4063    ) -> ProjectLocationQueueDeleteCall<'a, C> {
4064        self._delegate = Some(new_value);
4065        self
4066    }
4067
4068    /// Set any additional parameter of the query string used in the request.
4069    /// It should be used to set parameters which are not yet available through their own
4070    /// setters.
4071    ///
4072    /// Please note that this method must not be used to set any of the known parameters
4073    /// which have their own setter method. If done anyway, the request will fail.
4074    ///
4075    /// # Additional Parameters
4076    ///
4077    /// * *$.xgafv* (query-string) - V1 error format.
4078    /// * *access_token* (query-string) - OAuth access token.
4079    /// * *alt* (query-string) - Data format for response.
4080    /// * *callback* (query-string) - JSONP
4081    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4082    /// * *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.
4083    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4084    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4085    /// * *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.
4086    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4087    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4088    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueDeleteCall<'a, C>
4089    where
4090        T: AsRef<str>,
4091    {
4092        self._additional_params
4093            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4094        self
4095    }
4096
4097    /// Identifies the authorization scope for the method you are building.
4098    ///
4099    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4100    /// [`Scope::CloudPlatform`].
4101    ///
4102    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4103    /// tokens for more than one scope.
4104    ///
4105    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4106    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4107    /// sufficient, a read-write scope will do as well.
4108    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueDeleteCall<'a, C>
4109    where
4110        St: AsRef<str>,
4111    {
4112        self._scopes.insert(String::from(scope.as_ref()));
4113        self
4114    }
4115    /// Identifies the authorization scope(s) for the method you are building.
4116    ///
4117    /// See [`Self::add_scope()`] for details.
4118    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueDeleteCall<'a, C>
4119    where
4120        I: IntoIterator<Item = St>,
4121        St: AsRef<str>,
4122    {
4123        self._scopes
4124            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4125        self
4126    }
4127
4128    /// Removes all scopes, and no default scope will be used either.
4129    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4130    /// for details).
4131    pub fn clear_scopes(mut self) -> ProjectLocationQueueDeleteCall<'a, C> {
4132        self._scopes.clear();
4133        self
4134    }
4135}
4136
4137/// Gets a queue.
4138///
4139/// A builder for the *locations.queues.get* method supported by a *project* resource.
4140/// It is not used directly, but through a [`ProjectMethods`] instance.
4141///
4142/// # Example
4143///
4144/// Instantiate a resource method builder
4145///
4146/// ```test_harness,no_run
4147/// # extern crate hyper;
4148/// # extern crate hyper_rustls;
4149/// # extern crate google_cloudtasks2 as cloudtasks2;
4150/// # async fn dox() {
4151/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4152///
4153/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4154/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4155/// #     .with_native_roots()
4156/// #     .unwrap()
4157/// #     .https_only()
4158/// #     .enable_http2()
4159/// #     .build();
4160///
4161/// # let executor = hyper_util::rt::TokioExecutor::new();
4162/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4163/// #     secret,
4164/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4165/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4166/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4167/// #     ),
4168/// # ).build().await.unwrap();
4169///
4170/// # let client = hyper_util::client::legacy::Client::builder(
4171/// #     hyper_util::rt::TokioExecutor::new()
4172/// # )
4173/// # .build(
4174/// #     hyper_rustls::HttpsConnectorBuilder::new()
4175/// #         .with_native_roots()
4176/// #         .unwrap()
4177/// #         .https_or_http()
4178/// #         .enable_http2()
4179/// #         .build()
4180/// # );
4181/// # let mut hub = CloudTasks::new(client, auth);
4182/// // You can configure optional parameters by calling the respective setters at will, and
4183/// // execute the final call using `doit()`.
4184/// // Values shown here are possibly random and not representative !
4185/// let result = hub.projects().locations_queues_get("name")
4186///              .doit().await;
4187/// # }
4188/// ```
4189pub struct ProjectLocationQueueGetCall<'a, C>
4190where
4191    C: 'a,
4192{
4193    hub: &'a CloudTasks<C>,
4194    _name: String,
4195    _delegate: Option<&'a mut dyn common::Delegate>,
4196    _additional_params: HashMap<String, String>,
4197    _scopes: BTreeSet<String>,
4198}
4199
4200impl<'a, C> common::CallBuilder for ProjectLocationQueueGetCall<'a, C> {}
4201
4202impl<'a, C> ProjectLocationQueueGetCall<'a, C>
4203where
4204    C: common::Connector,
4205{
4206    /// Perform the operation you have build so far.
4207    pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
4208        use std::borrow::Cow;
4209        use std::io::{Read, Seek};
4210
4211        use common::{url::Params, ToParts};
4212        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4213
4214        let mut dd = common::DefaultDelegate;
4215        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4216        dlg.begin(common::MethodInfo {
4217            id: "cloudtasks.projects.locations.queues.get",
4218            http_method: hyper::Method::GET,
4219        });
4220
4221        for &field in ["alt", "name"].iter() {
4222            if self._additional_params.contains_key(field) {
4223                dlg.finished(false);
4224                return Err(common::Error::FieldClash(field));
4225            }
4226        }
4227
4228        let mut params = Params::with_capacity(3 + self._additional_params.len());
4229        params.push("name", self._name);
4230
4231        params.extend(self._additional_params.iter());
4232
4233        params.push("alt", "json");
4234        let mut url = self.hub._base_url.clone() + "v2/{+name}";
4235        if self._scopes.is_empty() {
4236            self._scopes
4237                .insert(Scope::CloudPlatform.as_ref().to_string());
4238        }
4239
4240        #[allow(clippy::single_element_loop)]
4241        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4242            url = params.uri_replacement(url, param_name, find_this, true);
4243        }
4244        {
4245            let to_remove = ["name"];
4246            params.remove_params(&to_remove);
4247        }
4248
4249        let url = params.parse_with_url(&url);
4250
4251        loop {
4252            let token = match self
4253                .hub
4254                .auth
4255                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4256                .await
4257            {
4258                Ok(token) => token,
4259                Err(e) => match dlg.token(e) {
4260                    Ok(token) => token,
4261                    Err(e) => {
4262                        dlg.finished(false);
4263                        return Err(common::Error::MissingToken(e));
4264                    }
4265                },
4266            };
4267            let mut req_result = {
4268                let client = &self.hub.client;
4269                dlg.pre_request();
4270                let mut req_builder = hyper::Request::builder()
4271                    .method(hyper::Method::GET)
4272                    .uri(url.as_str())
4273                    .header(USER_AGENT, self.hub._user_agent.clone());
4274
4275                if let Some(token) = token.as_ref() {
4276                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4277                }
4278
4279                let request = req_builder
4280                    .header(CONTENT_LENGTH, 0_u64)
4281                    .body(common::to_body::<String>(None));
4282
4283                client.request(request.unwrap()).await
4284            };
4285
4286            match req_result {
4287                Err(err) => {
4288                    if let common::Retry::After(d) = dlg.http_error(&err) {
4289                        sleep(d).await;
4290                        continue;
4291                    }
4292                    dlg.finished(false);
4293                    return Err(common::Error::HttpError(err));
4294                }
4295                Ok(res) => {
4296                    let (mut parts, body) = res.into_parts();
4297                    let mut body = common::Body::new(body);
4298                    if !parts.status.is_success() {
4299                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4300                        let error = serde_json::from_str(&common::to_string(&bytes));
4301                        let response = common::to_response(parts, bytes.into());
4302
4303                        if let common::Retry::After(d) =
4304                            dlg.http_failure(&response, error.as_ref().ok())
4305                        {
4306                            sleep(d).await;
4307                            continue;
4308                        }
4309
4310                        dlg.finished(false);
4311
4312                        return Err(match error {
4313                            Ok(value) => common::Error::BadRequest(value),
4314                            _ => common::Error::Failure(response),
4315                        });
4316                    }
4317                    let response = {
4318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4319                        let encoded = common::to_string(&bytes);
4320                        match serde_json::from_str(&encoded) {
4321                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4322                            Err(error) => {
4323                                dlg.response_json_decode_error(&encoded, &error);
4324                                return Err(common::Error::JsonDecodeError(
4325                                    encoded.to_string(),
4326                                    error,
4327                                ));
4328                            }
4329                        }
4330                    };
4331
4332                    dlg.finished(true);
4333                    return Ok(response);
4334                }
4335            }
4336        }
4337    }
4338
4339    /// Required. The resource name of the queue. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
4340    ///
4341    /// Sets the *name* path property to the given value.
4342    ///
4343    /// Even though the property as already been set when instantiating this call,
4344    /// we provide this method for API completeness.
4345    pub fn name(mut self, new_value: &str) -> ProjectLocationQueueGetCall<'a, C> {
4346        self._name = new_value.to_string();
4347        self
4348    }
4349    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4350    /// while executing the actual API request.
4351    ///
4352    /// ````text
4353    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4354    /// ````
4355    ///
4356    /// Sets the *delegate* property to the given value.
4357    pub fn delegate(
4358        mut self,
4359        new_value: &'a mut dyn common::Delegate,
4360    ) -> ProjectLocationQueueGetCall<'a, C> {
4361        self._delegate = Some(new_value);
4362        self
4363    }
4364
4365    /// Set any additional parameter of the query string used in the request.
4366    /// It should be used to set parameters which are not yet available through their own
4367    /// setters.
4368    ///
4369    /// Please note that this method must not be used to set any of the known parameters
4370    /// which have their own setter method. If done anyway, the request will fail.
4371    ///
4372    /// # Additional Parameters
4373    ///
4374    /// * *$.xgafv* (query-string) - V1 error format.
4375    /// * *access_token* (query-string) - OAuth access token.
4376    /// * *alt* (query-string) - Data format for response.
4377    /// * *callback* (query-string) - JSONP
4378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4379    /// * *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.
4380    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4381    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4382    /// * *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.
4383    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4384    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4385    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueGetCall<'a, C>
4386    where
4387        T: AsRef<str>,
4388    {
4389        self._additional_params
4390            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4391        self
4392    }
4393
4394    /// Identifies the authorization scope for the method you are building.
4395    ///
4396    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4397    /// [`Scope::CloudPlatform`].
4398    ///
4399    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4400    /// tokens for more than one scope.
4401    ///
4402    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4403    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4404    /// sufficient, a read-write scope will do as well.
4405    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueGetCall<'a, C>
4406    where
4407        St: AsRef<str>,
4408    {
4409        self._scopes.insert(String::from(scope.as_ref()));
4410        self
4411    }
4412    /// Identifies the authorization scope(s) for the method you are building.
4413    ///
4414    /// See [`Self::add_scope()`] for details.
4415    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueGetCall<'a, C>
4416    where
4417        I: IntoIterator<Item = St>,
4418        St: AsRef<str>,
4419    {
4420        self._scopes
4421            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4422        self
4423    }
4424
4425    /// Removes all scopes, and no default scope will be used either.
4426    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4427    /// for details).
4428    pub fn clear_scopes(mut self) -> ProjectLocationQueueGetCall<'a, C> {
4429        self._scopes.clear();
4430        self
4431    }
4432}
4433
4434/// 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`
4435///
4436/// A builder for the *locations.queues.getIamPolicy* method supported by a *project* resource.
4437/// It is not used directly, but through a [`ProjectMethods`] instance.
4438///
4439/// # Example
4440///
4441/// Instantiate a resource method builder
4442///
4443/// ```test_harness,no_run
4444/// # extern crate hyper;
4445/// # extern crate hyper_rustls;
4446/// # extern crate google_cloudtasks2 as cloudtasks2;
4447/// use cloudtasks2::api::GetIamPolicyRequest;
4448/// # async fn dox() {
4449/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4450///
4451/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4452/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4453/// #     .with_native_roots()
4454/// #     .unwrap()
4455/// #     .https_only()
4456/// #     .enable_http2()
4457/// #     .build();
4458///
4459/// # let executor = hyper_util::rt::TokioExecutor::new();
4460/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4461/// #     secret,
4462/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4463/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4464/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4465/// #     ),
4466/// # ).build().await.unwrap();
4467///
4468/// # let client = hyper_util::client::legacy::Client::builder(
4469/// #     hyper_util::rt::TokioExecutor::new()
4470/// # )
4471/// # .build(
4472/// #     hyper_rustls::HttpsConnectorBuilder::new()
4473/// #         .with_native_roots()
4474/// #         .unwrap()
4475/// #         .https_or_http()
4476/// #         .enable_http2()
4477/// #         .build()
4478/// # );
4479/// # let mut hub = CloudTasks::new(client, auth);
4480/// // As the method needs a request, you would usually fill it with the desired information
4481/// // into the respective structure. Some of the parts shown here might not be applicable !
4482/// // Values shown here are possibly random and not representative !
4483/// let mut req = GetIamPolicyRequest::default();
4484///
4485/// // You can configure optional parameters by calling the respective setters at will, and
4486/// // execute the final call using `doit()`.
4487/// // Values shown here are possibly random and not representative !
4488/// let result = hub.projects().locations_queues_get_iam_policy(req, "resource")
4489///              .doit().await;
4490/// # }
4491/// ```
4492pub struct ProjectLocationQueueGetIamPolicyCall<'a, C>
4493where
4494    C: 'a,
4495{
4496    hub: &'a CloudTasks<C>,
4497    _request: GetIamPolicyRequest,
4498    _resource: String,
4499    _delegate: Option<&'a mut dyn common::Delegate>,
4500    _additional_params: HashMap<String, String>,
4501    _scopes: BTreeSet<String>,
4502}
4503
4504impl<'a, C> common::CallBuilder for ProjectLocationQueueGetIamPolicyCall<'a, C> {}
4505
4506impl<'a, C> ProjectLocationQueueGetIamPolicyCall<'a, C>
4507where
4508    C: common::Connector,
4509{
4510    /// Perform the operation you have build so far.
4511    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4512        use std::borrow::Cow;
4513        use std::io::{Read, Seek};
4514
4515        use common::{url::Params, ToParts};
4516        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4517
4518        let mut dd = common::DefaultDelegate;
4519        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4520        dlg.begin(common::MethodInfo {
4521            id: "cloudtasks.projects.locations.queues.getIamPolicy",
4522            http_method: hyper::Method::POST,
4523        });
4524
4525        for &field in ["alt", "resource"].iter() {
4526            if self._additional_params.contains_key(field) {
4527                dlg.finished(false);
4528                return Err(common::Error::FieldClash(field));
4529            }
4530        }
4531
4532        let mut params = Params::with_capacity(4 + self._additional_params.len());
4533        params.push("resource", self._resource);
4534
4535        params.extend(self._additional_params.iter());
4536
4537        params.push("alt", "json");
4538        let mut url = self.hub._base_url.clone() + "v2/{+resource}:getIamPolicy";
4539        if self._scopes.is_empty() {
4540            self._scopes
4541                .insert(Scope::CloudPlatform.as_ref().to_string());
4542        }
4543
4544        #[allow(clippy::single_element_loop)]
4545        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4546            url = params.uri_replacement(url, param_name, find_this, true);
4547        }
4548        {
4549            let to_remove = ["resource"];
4550            params.remove_params(&to_remove);
4551        }
4552
4553        let url = params.parse_with_url(&url);
4554
4555        let mut json_mime_type = mime::APPLICATION_JSON;
4556        let mut request_value_reader = {
4557            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4558            common::remove_json_null_values(&mut value);
4559            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4560            serde_json::to_writer(&mut dst, &value).unwrap();
4561            dst
4562        };
4563        let request_size = request_value_reader
4564            .seek(std::io::SeekFrom::End(0))
4565            .unwrap();
4566        request_value_reader
4567            .seek(std::io::SeekFrom::Start(0))
4568            .unwrap();
4569
4570        loop {
4571            let token = match self
4572                .hub
4573                .auth
4574                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4575                .await
4576            {
4577                Ok(token) => token,
4578                Err(e) => match dlg.token(e) {
4579                    Ok(token) => token,
4580                    Err(e) => {
4581                        dlg.finished(false);
4582                        return Err(common::Error::MissingToken(e));
4583                    }
4584                },
4585            };
4586            request_value_reader
4587                .seek(std::io::SeekFrom::Start(0))
4588                .unwrap();
4589            let mut req_result = {
4590                let client = &self.hub.client;
4591                dlg.pre_request();
4592                let mut req_builder = hyper::Request::builder()
4593                    .method(hyper::Method::POST)
4594                    .uri(url.as_str())
4595                    .header(USER_AGENT, self.hub._user_agent.clone());
4596
4597                if let Some(token) = token.as_ref() {
4598                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4599                }
4600
4601                let request = req_builder
4602                    .header(CONTENT_TYPE, json_mime_type.to_string())
4603                    .header(CONTENT_LENGTH, request_size as u64)
4604                    .body(common::to_body(
4605                        request_value_reader.get_ref().clone().into(),
4606                    ));
4607
4608                client.request(request.unwrap()).await
4609            };
4610
4611            match req_result {
4612                Err(err) => {
4613                    if let common::Retry::After(d) = dlg.http_error(&err) {
4614                        sleep(d).await;
4615                        continue;
4616                    }
4617                    dlg.finished(false);
4618                    return Err(common::Error::HttpError(err));
4619                }
4620                Ok(res) => {
4621                    let (mut parts, body) = res.into_parts();
4622                    let mut body = common::Body::new(body);
4623                    if !parts.status.is_success() {
4624                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4625                        let error = serde_json::from_str(&common::to_string(&bytes));
4626                        let response = common::to_response(parts, bytes.into());
4627
4628                        if let common::Retry::After(d) =
4629                            dlg.http_failure(&response, error.as_ref().ok())
4630                        {
4631                            sleep(d).await;
4632                            continue;
4633                        }
4634
4635                        dlg.finished(false);
4636
4637                        return Err(match error {
4638                            Ok(value) => common::Error::BadRequest(value),
4639                            _ => common::Error::Failure(response),
4640                        });
4641                    }
4642                    let response = {
4643                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4644                        let encoded = common::to_string(&bytes);
4645                        match serde_json::from_str(&encoded) {
4646                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4647                            Err(error) => {
4648                                dlg.response_json_decode_error(&encoded, &error);
4649                                return Err(common::Error::JsonDecodeError(
4650                                    encoded.to_string(),
4651                                    error,
4652                                ));
4653                            }
4654                        }
4655                    };
4656
4657                    dlg.finished(true);
4658                    return Ok(response);
4659                }
4660            }
4661        }
4662    }
4663
4664    ///
4665    /// Sets the *request* property to the given value.
4666    ///
4667    /// Even though the property as already been set when instantiating this call,
4668    /// we provide this method for API completeness.
4669    pub fn request(
4670        mut self,
4671        new_value: GetIamPolicyRequest,
4672    ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
4673        self._request = new_value;
4674        self
4675    }
4676    /// 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.
4677    ///
4678    /// Sets the *resource* path property to the given value.
4679    ///
4680    /// Even though the property as already been set when instantiating this call,
4681    /// we provide this method for API completeness.
4682    pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
4683        self._resource = new_value.to_string();
4684        self
4685    }
4686    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4687    /// while executing the actual API request.
4688    ///
4689    /// ````text
4690    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4691    /// ````
4692    ///
4693    /// Sets the *delegate* property to the given value.
4694    pub fn delegate(
4695        mut self,
4696        new_value: &'a mut dyn common::Delegate,
4697    ) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
4698        self._delegate = Some(new_value);
4699        self
4700    }
4701
4702    /// Set any additional parameter of the query string used in the request.
4703    /// It should be used to set parameters which are not yet available through their own
4704    /// setters.
4705    ///
4706    /// Please note that this method must not be used to set any of the known parameters
4707    /// which have their own setter method. If done anyway, the request will fail.
4708    ///
4709    /// # Additional Parameters
4710    ///
4711    /// * *$.xgafv* (query-string) - V1 error format.
4712    /// * *access_token* (query-string) - OAuth access token.
4713    /// * *alt* (query-string) - Data format for response.
4714    /// * *callback* (query-string) - JSONP
4715    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4716    /// * *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.
4717    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4718    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4719    /// * *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.
4720    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4721    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4722    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
4723    where
4724        T: AsRef<str>,
4725    {
4726        self._additional_params
4727            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4728        self
4729    }
4730
4731    /// Identifies the authorization scope for the method you are building.
4732    ///
4733    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4734    /// [`Scope::CloudPlatform`].
4735    ///
4736    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4737    /// tokens for more than one scope.
4738    ///
4739    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4740    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4741    /// sufficient, a read-write scope will do as well.
4742    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
4743    where
4744        St: AsRef<str>,
4745    {
4746        self._scopes.insert(String::from(scope.as_ref()));
4747        self
4748    }
4749    /// Identifies the authorization scope(s) for the method you are building.
4750    ///
4751    /// See [`Self::add_scope()`] for details.
4752    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueGetIamPolicyCall<'a, C>
4753    where
4754        I: IntoIterator<Item = St>,
4755        St: AsRef<str>,
4756    {
4757        self._scopes
4758            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4759        self
4760    }
4761
4762    /// Removes all scopes, and no default scope will be used either.
4763    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4764    /// for details).
4765    pub fn clear_scopes(mut self) -> ProjectLocationQueueGetIamPolicyCall<'a, C> {
4766        self._scopes.clear();
4767        self
4768    }
4769}
4770
4771/// Lists queues. Queues are returned in lexicographical order.
4772///
4773/// A builder for the *locations.queues.list* method supported by a *project* resource.
4774/// It is not used directly, but through a [`ProjectMethods`] instance.
4775///
4776/// # Example
4777///
4778/// Instantiate a resource method builder
4779///
4780/// ```test_harness,no_run
4781/// # extern crate hyper;
4782/// # extern crate hyper_rustls;
4783/// # extern crate google_cloudtasks2 as cloudtasks2;
4784/// # async fn dox() {
4785/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4786///
4787/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4788/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4789/// #     .with_native_roots()
4790/// #     .unwrap()
4791/// #     .https_only()
4792/// #     .enable_http2()
4793/// #     .build();
4794///
4795/// # let executor = hyper_util::rt::TokioExecutor::new();
4796/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4797/// #     secret,
4798/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4799/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4800/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4801/// #     ),
4802/// # ).build().await.unwrap();
4803///
4804/// # let client = hyper_util::client::legacy::Client::builder(
4805/// #     hyper_util::rt::TokioExecutor::new()
4806/// # )
4807/// # .build(
4808/// #     hyper_rustls::HttpsConnectorBuilder::new()
4809/// #         .with_native_roots()
4810/// #         .unwrap()
4811/// #         .https_or_http()
4812/// #         .enable_http2()
4813/// #         .build()
4814/// # );
4815/// # let mut hub = CloudTasks::new(client, auth);
4816/// // You can configure optional parameters by calling the respective setters at will, and
4817/// // execute the final call using `doit()`.
4818/// // Values shown here are possibly random and not representative !
4819/// let result = hub.projects().locations_queues_list("parent")
4820///              .page_token("ipsum")
4821///              .page_size(-88)
4822///              .filter("amet")
4823///              .doit().await;
4824/// # }
4825/// ```
4826pub struct ProjectLocationQueueListCall<'a, C>
4827where
4828    C: 'a,
4829{
4830    hub: &'a CloudTasks<C>,
4831    _parent: String,
4832    _page_token: Option<String>,
4833    _page_size: Option<i32>,
4834    _filter: Option<String>,
4835    _delegate: Option<&'a mut dyn common::Delegate>,
4836    _additional_params: HashMap<String, String>,
4837    _scopes: BTreeSet<String>,
4838}
4839
4840impl<'a, C> common::CallBuilder for ProjectLocationQueueListCall<'a, C> {}
4841
4842impl<'a, C> ProjectLocationQueueListCall<'a, C>
4843where
4844    C: common::Connector,
4845{
4846    /// Perform the operation you have build so far.
4847    pub async fn doit(mut self) -> common::Result<(common::Response, ListQueuesResponse)> {
4848        use std::borrow::Cow;
4849        use std::io::{Read, Seek};
4850
4851        use common::{url::Params, ToParts};
4852        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4853
4854        let mut dd = common::DefaultDelegate;
4855        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4856        dlg.begin(common::MethodInfo {
4857            id: "cloudtasks.projects.locations.queues.list",
4858            http_method: hyper::Method::GET,
4859        });
4860
4861        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
4862            if self._additional_params.contains_key(field) {
4863                dlg.finished(false);
4864                return Err(common::Error::FieldClash(field));
4865            }
4866        }
4867
4868        let mut params = Params::with_capacity(6 + self._additional_params.len());
4869        params.push("parent", self._parent);
4870        if let Some(value) = self._page_token.as_ref() {
4871            params.push("pageToken", value);
4872        }
4873        if let Some(value) = self._page_size.as_ref() {
4874            params.push("pageSize", value.to_string());
4875        }
4876        if let Some(value) = self._filter.as_ref() {
4877            params.push("filter", value);
4878        }
4879
4880        params.extend(self._additional_params.iter());
4881
4882        params.push("alt", "json");
4883        let mut url = self.hub._base_url.clone() + "v2/{+parent}/queues";
4884        if self._scopes.is_empty() {
4885            self._scopes
4886                .insert(Scope::CloudPlatform.as_ref().to_string());
4887        }
4888
4889        #[allow(clippy::single_element_loop)]
4890        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4891            url = params.uri_replacement(url, param_name, find_this, true);
4892        }
4893        {
4894            let to_remove = ["parent"];
4895            params.remove_params(&to_remove);
4896        }
4897
4898        let url = params.parse_with_url(&url);
4899
4900        loop {
4901            let token = match self
4902                .hub
4903                .auth
4904                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4905                .await
4906            {
4907                Ok(token) => token,
4908                Err(e) => match dlg.token(e) {
4909                    Ok(token) => token,
4910                    Err(e) => {
4911                        dlg.finished(false);
4912                        return Err(common::Error::MissingToken(e));
4913                    }
4914                },
4915            };
4916            let mut req_result = {
4917                let client = &self.hub.client;
4918                dlg.pre_request();
4919                let mut req_builder = hyper::Request::builder()
4920                    .method(hyper::Method::GET)
4921                    .uri(url.as_str())
4922                    .header(USER_AGENT, self.hub._user_agent.clone());
4923
4924                if let Some(token) = token.as_ref() {
4925                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4926                }
4927
4928                let request = req_builder
4929                    .header(CONTENT_LENGTH, 0_u64)
4930                    .body(common::to_body::<String>(None));
4931
4932                client.request(request.unwrap()).await
4933            };
4934
4935            match req_result {
4936                Err(err) => {
4937                    if let common::Retry::After(d) = dlg.http_error(&err) {
4938                        sleep(d).await;
4939                        continue;
4940                    }
4941                    dlg.finished(false);
4942                    return Err(common::Error::HttpError(err));
4943                }
4944                Ok(res) => {
4945                    let (mut parts, body) = res.into_parts();
4946                    let mut body = common::Body::new(body);
4947                    if !parts.status.is_success() {
4948                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4949                        let error = serde_json::from_str(&common::to_string(&bytes));
4950                        let response = common::to_response(parts, bytes.into());
4951
4952                        if let common::Retry::After(d) =
4953                            dlg.http_failure(&response, error.as_ref().ok())
4954                        {
4955                            sleep(d).await;
4956                            continue;
4957                        }
4958
4959                        dlg.finished(false);
4960
4961                        return Err(match error {
4962                            Ok(value) => common::Error::BadRequest(value),
4963                            _ => common::Error::Failure(response),
4964                        });
4965                    }
4966                    let response = {
4967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4968                        let encoded = common::to_string(&bytes);
4969                        match serde_json::from_str(&encoded) {
4970                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4971                            Err(error) => {
4972                                dlg.response_json_decode_error(&encoded, &error);
4973                                return Err(common::Error::JsonDecodeError(
4974                                    encoded.to_string(),
4975                                    error,
4976                                ));
4977                            }
4978                        }
4979                    };
4980
4981                    dlg.finished(true);
4982                    return Ok(response);
4983                }
4984            }
4985        }
4986    }
4987
4988    /// Required. The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`
4989    ///
4990    /// Sets the *parent* path property to the given value.
4991    ///
4992    /// Even though the property as already been set when instantiating this call,
4993    /// we provide this method for API completeness.
4994    pub fn parent(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
4995        self._parent = new_value.to_string();
4996        self
4997    }
4998    /// 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.
4999    ///
5000    /// Sets the *page token* query property to the given value.
5001    pub fn page_token(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
5002        self._page_token = Some(new_value.to_string());
5003        self
5004    }
5005    /// 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.
5006    ///
5007    /// Sets the *page size* query property to the given value.
5008    pub fn page_size(mut self, new_value: i32) -> ProjectLocationQueueListCall<'a, C> {
5009        self._page_size = Some(new_value);
5010        self
5011    }
5012    /// `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 "state: PAUSED". Note that using filters might cause fewer queues than the requested page_size to be returned.
5013    ///
5014    /// Sets the *filter* query property to the given value.
5015    pub fn filter(mut self, new_value: &str) -> ProjectLocationQueueListCall<'a, C> {
5016        self._filter = Some(new_value.to_string());
5017        self
5018    }
5019    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5020    /// while executing the actual API request.
5021    ///
5022    /// ````text
5023    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5024    /// ````
5025    ///
5026    /// Sets the *delegate* property to the given value.
5027    pub fn delegate(
5028        mut self,
5029        new_value: &'a mut dyn common::Delegate,
5030    ) -> ProjectLocationQueueListCall<'a, C> {
5031        self._delegate = Some(new_value);
5032        self
5033    }
5034
5035    /// Set any additional parameter of the query string used in the request.
5036    /// It should be used to set parameters which are not yet available through their own
5037    /// setters.
5038    ///
5039    /// Please note that this method must not be used to set any of the known parameters
5040    /// which have their own setter method. If done anyway, the request will fail.
5041    ///
5042    /// # Additional Parameters
5043    ///
5044    /// * *$.xgafv* (query-string) - V1 error format.
5045    /// * *access_token* (query-string) - OAuth access token.
5046    /// * *alt* (query-string) - Data format for response.
5047    /// * *callback* (query-string) - JSONP
5048    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5049    /// * *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.
5050    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5051    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5052    /// * *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.
5053    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5054    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5055    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueListCall<'a, C>
5056    where
5057        T: AsRef<str>,
5058    {
5059        self._additional_params
5060            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5061        self
5062    }
5063
5064    /// Identifies the authorization scope for the method you are building.
5065    ///
5066    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5067    /// [`Scope::CloudPlatform`].
5068    ///
5069    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5070    /// tokens for more than one scope.
5071    ///
5072    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5073    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5074    /// sufficient, a read-write scope will do as well.
5075    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueListCall<'a, C>
5076    where
5077        St: AsRef<str>,
5078    {
5079        self._scopes.insert(String::from(scope.as_ref()));
5080        self
5081    }
5082    /// Identifies the authorization scope(s) for the method you are building.
5083    ///
5084    /// See [`Self::add_scope()`] for details.
5085    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueListCall<'a, C>
5086    where
5087        I: IntoIterator<Item = St>,
5088        St: AsRef<str>,
5089    {
5090        self._scopes
5091            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5092        self
5093    }
5094
5095    /// Removes all scopes, and no default scope will be used either.
5096    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5097    /// for details).
5098    pub fn clear_scopes(mut self) -> ProjectLocationQueueListCall<'a, C> {
5099        self._scopes.clear();
5100        self
5101    }
5102}
5103
5104/// 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.
5105///
5106/// A builder for the *locations.queues.patch* method supported by a *project* resource.
5107/// It is not used directly, but through a [`ProjectMethods`] instance.
5108///
5109/// # Example
5110///
5111/// Instantiate a resource method builder
5112///
5113/// ```test_harness,no_run
5114/// # extern crate hyper;
5115/// # extern crate hyper_rustls;
5116/// # extern crate google_cloudtasks2 as cloudtasks2;
5117/// use cloudtasks2::api::Queue;
5118/// # async fn dox() {
5119/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5120///
5121/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5122/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5123/// #     .with_native_roots()
5124/// #     .unwrap()
5125/// #     .https_only()
5126/// #     .enable_http2()
5127/// #     .build();
5128///
5129/// # let executor = hyper_util::rt::TokioExecutor::new();
5130/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5131/// #     secret,
5132/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5133/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5134/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5135/// #     ),
5136/// # ).build().await.unwrap();
5137///
5138/// # let client = hyper_util::client::legacy::Client::builder(
5139/// #     hyper_util::rt::TokioExecutor::new()
5140/// # )
5141/// # .build(
5142/// #     hyper_rustls::HttpsConnectorBuilder::new()
5143/// #         .with_native_roots()
5144/// #         .unwrap()
5145/// #         .https_or_http()
5146/// #         .enable_http2()
5147/// #         .build()
5148/// # );
5149/// # let mut hub = CloudTasks::new(client, auth);
5150/// // As the method needs a request, you would usually fill it with the desired information
5151/// // into the respective structure. Some of the parts shown here might not be applicable !
5152/// // Values shown here are possibly random and not representative !
5153/// let mut req = Queue::default();
5154///
5155/// // You can configure optional parameters by calling the respective setters at will, and
5156/// // execute the final call using `doit()`.
5157/// // Values shown here are possibly random and not representative !
5158/// let result = hub.projects().locations_queues_patch(req, "name")
5159///              .update_mask(FieldMask::new::<&str>(&[]))
5160///              .doit().await;
5161/// # }
5162/// ```
5163pub struct ProjectLocationQueuePatchCall<'a, C>
5164where
5165    C: 'a,
5166{
5167    hub: &'a CloudTasks<C>,
5168    _request: Queue,
5169    _name: String,
5170    _update_mask: Option<common::FieldMask>,
5171    _delegate: Option<&'a mut dyn common::Delegate>,
5172    _additional_params: HashMap<String, String>,
5173    _scopes: BTreeSet<String>,
5174}
5175
5176impl<'a, C> common::CallBuilder for ProjectLocationQueuePatchCall<'a, C> {}
5177
5178impl<'a, C> ProjectLocationQueuePatchCall<'a, C>
5179where
5180    C: common::Connector,
5181{
5182    /// Perform the operation you have build so far.
5183    pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
5184        use std::borrow::Cow;
5185        use std::io::{Read, Seek};
5186
5187        use common::{url::Params, ToParts};
5188        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5189
5190        let mut dd = common::DefaultDelegate;
5191        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5192        dlg.begin(common::MethodInfo {
5193            id: "cloudtasks.projects.locations.queues.patch",
5194            http_method: hyper::Method::PATCH,
5195        });
5196
5197        for &field in ["alt", "name", "updateMask"].iter() {
5198            if self._additional_params.contains_key(field) {
5199                dlg.finished(false);
5200                return Err(common::Error::FieldClash(field));
5201            }
5202        }
5203
5204        let mut params = Params::with_capacity(5 + self._additional_params.len());
5205        params.push("name", self._name);
5206        if let Some(value) = self._update_mask.as_ref() {
5207            params.push("updateMask", value.to_string());
5208        }
5209
5210        params.extend(self._additional_params.iter());
5211
5212        params.push("alt", "json");
5213        let mut url = self.hub._base_url.clone() + "v2/{+name}";
5214        if self._scopes.is_empty() {
5215            self._scopes
5216                .insert(Scope::CloudPlatform.as_ref().to_string());
5217        }
5218
5219        #[allow(clippy::single_element_loop)]
5220        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5221            url = params.uri_replacement(url, param_name, find_this, true);
5222        }
5223        {
5224            let to_remove = ["name"];
5225            params.remove_params(&to_remove);
5226        }
5227
5228        let url = params.parse_with_url(&url);
5229
5230        let mut json_mime_type = mime::APPLICATION_JSON;
5231        let mut request_value_reader = {
5232            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5233            common::remove_json_null_values(&mut value);
5234            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5235            serde_json::to_writer(&mut dst, &value).unwrap();
5236            dst
5237        };
5238        let request_size = request_value_reader
5239            .seek(std::io::SeekFrom::End(0))
5240            .unwrap();
5241        request_value_reader
5242            .seek(std::io::SeekFrom::Start(0))
5243            .unwrap();
5244
5245        loop {
5246            let token = match self
5247                .hub
5248                .auth
5249                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5250                .await
5251            {
5252                Ok(token) => token,
5253                Err(e) => match dlg.token(e) {
5254                    Ok(token) => token,
5255                    Err(e) => {
5256                        dlg.finished(false);
5257                        return Err(common::Error::MissingToken(e));
5258                    }
5259                },
5260            };
5261            request_value_reader
5262                .seek(std::io::SeekFrom::Start(0))
5263                .unwrap();
5264            let mut req_result = {
5265                let client = &self.hub.client;
5266                dlg.pre_request();
5267                let mut req_builder = hyper::Request::builder()
5268                    .method(hyper::Method::PATCH)
5269                    .uri(url.as_str())
5270                    .header(USER_AGENT, self.hub._user_agent.clone());
5271
5272                if let Some(token) = token.as_ref() {
5273                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5274                }
5275
5276                let request = req_builder
5277                    .header(CONTENT_TYPE, json_mime_type.to_string())
5278                    .header(CONTENT_LENGTH, request_size as u64)
5279                    .body(common::to_body(
5280                        request_value_reader.get_ref().clone().into(),
5281                    ));
5282
5283                client.request(request.unwrap()).await
5284            };
5285
5286            match req_result {
5287                Err(err) => {
5288                    if let common::Retry::After(d) = dlg.http_error(&err) {
5289                        sleep(d).await;
5290                        continue;
5291                    }
5292                    dlg.finished(false);
5293                    return Err(common::Error::HttpError(err));
5294                }
5295                Ok(res) => {
5296                    let (mut parts, body) = res.into_parts();
5297                    let mut body = common::Body::new(body);
5298                    if !parts.status.is_success() {
5299                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5300                        let error = serde_json::from_str(&common::to_string(&bytes));
5301                        let response = common::to_response(parts, bytes.into());
5302
5303                        if let common::Retry::After(d) =
5304                            dlg.http_failure(&response, error.as_ref().ok())
5305                        {
5306                            sleep(d).await;
5307                            continue;
5308                        }
5309
5310                        dlg.finished(false);
5311
5312                        return Err(match error {
5313                            Ok(value) => common::Error::BadRequest(value),
5314                            _ => common::Error::Failure(response),
5315                        });
5316                    }
5317                    let response = {
5318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5319                        let encoded = common::to_string(&bytes);
5320                        match serde_json::from_str(&encoded) {
5321                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5322                            Err(error) => {
5323                                dlg.response_json_decode_error(&encoded, &error);
5324                                return Err(common::Error::JsonDecodeError(
5325                                    encoded.to_string(),
5326                                    error,
5327                                ));
5328                            }
5329                        }
5330                    };
5331
5332                    dlg.finished(true);
5333                    return Ok(response);
5334                }
5335            }
5336        }
5337    }
5338
5339    ///
5340    /// Sets the *request* property to the given value.
5341    ///
5342    /// Even though the property as already been set when instantiating this call,
5343    /// we provide this method for API completeness.
5344    pub fn request(mut self, new_value: Queue) -> ProjectLocationQueuePatchCall<'a, C> {
5345        self._request = new_value;
5346        self
5347    }
5348    /// 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.
5349    ///
5350    /// Sets the *name* path property to the given value.
5351    ///
5352    /// Even though the property as already been set when instantiating this call,
5353    /// we provide this method for API completeness.
5354    pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePatchCall<'a, C> {
5355        self._name = new_value.to_string();
5356        self
5357    }
5358    /// A mask used to specify which fields of the queue are being updated. If empty, then all fields will be updated.
5359    ///
5360    /// Sets the *update mask* query property to the given value.
5361    pub fn update_mask(
5362        mut self,
5363        new_value: common::FieldMask,
5364    ) -> ProjectLocationQueuePatchCall<'a, C> {
5365        self._update_mask = Some(new_value);
5366        self
5367    }
5368    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5369    /// while executing the actual API request.
5370    ///
5371    /// ````text
5372    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5373    /// ````
5374    ///
5375    /// Sets the *delegate* property to the given value.
5376    pub fn delegate(
5377        mut self,
5378        new_value: &'a mut dyn common::Delegate,
5379    ) -> ProjectLocationQueuePatchCall<'a, C> {
5380        self._delegate = Some(new_value);
5381        self
5382    }
5383
5384    /// Set any additional parameter of the query string used in the request.
5385    /// It should be used to set parameters which are not yet available through their own
5386    /// setters.
5387    ///
5388    /// Please note that this method must not be used to set any of the known parameters
5389    /// which have their own setter method. If done anyway, the request will fail.
5390    ///
5391    /// # Additional Parameters
5392    ///
5393    /// * *$.xgafv* (query-string) - V1 error format.
5394    /// * *access_token* (query-string) - OAuth access token.
5395    /// * *alt* (query-string) - Data format for response.
5396    /// * *callback* (query-string) - JSONP
5397    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5398    /// * *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.
5399    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5400    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5401    /// * *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.
5402    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5403    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5404    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePatchCall<'a, C>
5405    where
5406        T: AsRef<str>,
5407    {
5408        self._additional_params
5409            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5410        self
5411    }
5412
5413    /// Identifies the authorization scope for the method you are building.
5414    ///
5415    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5416    /// [`Scope::CloudPlatform`].
5417    ///
5418    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5419    /// tokens for more than one scope.
5420    ///
5421    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5422    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5423    /// sufficient, a read-write scope will do as well.
5424    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePatchCall<'a, C>
5425    where
5426        St: AsRef<str>,
5427    {
5428        self._scopes.insert(String::from(scope.as_ref()));
5429        self
5430    }
5431    /// Identifies the authorization scope(s) for the method you are building.
5432    ///
5433    /// See [`Self::add_scope()`] for details.
5434    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePatchCall<'a, C>
5435    where
5436        I: IntoIterator<Item = St>,
5437        St: AsRef<str>,
5438    {
5439        self._scopes
5440            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5441        self
5442    }
5443
5444    /// Removes all scopes, and no default scope will be used either.
5445    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5446    /// for details).
5447    pub fn clear_scopes(mut self) -> ProjectLocationQueuePatchCall<'a, C> {
5448        self._scopes.clear();
5449        self
5450    }
5451}
5452
5453/// 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.
5454///
5455/// A builder for the *locations.queues.pause* method supported by a *project* resource.
5456/// It is not used directly, but through a [`ProjectMethods`] instance.
5457///
5458/// # Example
5459///
5460/// Instantiate a resource method builder
5461///
5462/// ```test_harness,no_run
5463/// # extern crate hyper;
5464/// # extern crate hyper_rustls;
5465/// # extern crate google_cloudtasks2 as cloudtasks2;
5466/// use cloudtasks2::api::PauseQueueRequest;
5467/// # async fn dox() {
5468/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5469///
5470/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5471/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5472/// #     .with_native_roots()
5473/// #     .unwrap()
5474/// #     .https_only()
5475/// #     .enable_http2()
5476/// #     .build();
5477///
5478/// # let executor = hyper_util::rt::TokioExecutor::new();
5479/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5480/// #     secret,
5481/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5482/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5483/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5484/// #     ),
5485/// # ).build().await.unwrap();
5486///
5487/// # let client = hyper_util::client::legacy::Client::builder(
5488/// #     hyper_util::rt::TokioExecutor::new()
5489/// # )
5490/// # .build(
5491/// #     hyper_rustls::HttpsConnectorBuilder::new()
5492/// #         .with_native_roots()
5493/// #         .unwrap()
5494/// #         .https_or_http()
5495/// #         .enable_http2()
5496/// #         .build()
5497/// # );
5498/// # let mut hub = CloudTasks::new(client, auth);
5499/// // As the method needs a request, you would usually fill it with the desired information
5500/// // into the respective structure. Some of the parts shown here might not be applicable !
5501/// // Values shown here are possibly random and not representative !
5502/// let mut req = PauseQueueRequest::default();
5503///
5504/// // You can configure optional parameters by calling the respective setters at will, and
5505/// // execute the final call using `doit()`.
5506/// // Values shown here are possibly random and not representative !
5507/// let result = hub.projects().locations_queues_pause(req, "name")
5508///              .doit().await;
5509/// # }
5510/// ```
5511pub struct ProjectLocationQueuePauseCall<'a, C>
5512where
5513    C: 'a,
5514{
5515    hub: &'a CloudTasks<C>,
5516    _request: PauseQueueRequest,
5517    _name: String,
5518    _delegate: Option<&'a mut dyn common::Delegate>,
5519    _additional_params: HashMap<String, String>,
5520    _scopes: BTreeSet<String>,
5521}
5522
5523impl<'a, C> common::CallBuilder for ProjectLocationQueuePauseCall<'a, C> {}
5524
5525impl<'a, C> ProjectLocationQueuePauseCall<'a, C>
5526where
5527    C: common::Connector,
5528{
5529    /// Perform the operation you have build so far.
5530    pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
5531        use std::borrow::Cow;
5532        use std::io::{Read, Seek};
5533
5534        use common::{url::Params, ToParts};
5535        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5536
5537        let mut dd = common::DefaultDelegate;
5538        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5539        dlg.begin(common::MethodInfo {
5540            id: "cloudtasks.projects.locations.queues.pause",
5541            http_method: hyper::Method::POST,
5542        });
5543
5544        for &field in ["alt", "name"].iter() {
5545            if self._additional_params.contains_key(field) {
5546                dlg.finished(false);
5547                return Err(common::Error::FieldClash(field));
5548            }
5549        }
5550
5551        let mut params = Params::with_capacity(4 + self._additional_params.len());
5552        params.push("name", self._name);
5553
5554        params.extend(self._additional_params.iter());
5555
5556        params.push("alt", "json");
5557        let mut url = self.hub._base_url.clone() + "v2/{+name}:pause";
5558        if self._scopes.is_empty() {
5559            self._scopes
5560                .insert(Scope::CloudPlatform.as_ref().to_string());
5561        }
5562
5563        #[allow(clippy::single_element_loop)]
5564        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5565            url = params.uri_replacement(url, param_name, find_this, true);
5566        }
5567        {
5568            let to_remove = ["name"];
5569            params.remove_params(&to_remove);
5570        }
5571
5572        let url = params.parse_with_url(&url);
5573
5574        let mut json_mime_type = mime::APPLICATION_JSON;
5575        let mut request_value_reader = {
5576            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5577            common::remove_json_null_values(&mut value);
5578            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5579            serde_json::to_writer(&mut dst, &value).unwrap();
5580            dst
5581        };
5582        let request_size = request_value_reader
5583            .seek(std::io::SeekFrom::End(0))
5584            .unwrap();
5585        request_value_reader
5586            .seek(std::io::SeekFrom::Start(0))
5587            .unwrap();
5588
5589        loop {
5590            let token = match self
5591                .hub
5592                .auth
5593                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5594                .await
5595            {
5596                Ok(token) => token,
5597                Err(e) => match dlg.token(e) {
5598                    Ok(token) => token,
5599                    Err(e) => {
5600                        dlg.finished(false);
5601                        return Err(common::Error::MissingToken(e));
5602                    }
5603                },
5604            };
5605            request_value_reader
5606                .seek(std::io::SeekFrom::Start(0))
5607                .unwrap();
5608            let mut req_result = {
5609                let client = &self.hub.client;
5610                dlg.pre_request();
5611                let mut req_builder = hyper::Request::builder()
5612                    .method(hyper::Method::POST)
5613                    .uri(url.as_str())
5614                    .header(USER_AGENT, self.hub._user_agent.clone());
5615
5616                if let Some(token) = token.as_ref() {
5617                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5618                }
5619
5620                let request = req_builder
5621                    .header(CONTENT_TYPE, json_mime_type.to_string())
5622                    .header(CONTENT_LENGTH, request_size as u64)
5623                    .body(common::to_body(
5624                        request_value_reader.get_ref().clone().into(),
5625                    ));
5626
5627                client.request(request.unwrap()).await
5628            };
5629
5630            match req_result {
5631                Err(err) => {
5632                    if let common::Retry::After(d) = dlg.http_error(&err) {
5633                        sleep(d).await;
5634                        continue;
5635                    }
5636                    dlg.finished(false);
5637                    return Err(common::Error::HttpError(err));
5638                }
5639                Ok(res) => {
5640                    let (mut parts, body) = res.into_parts();
5641                    let mut body = common::Body::new(body);
5642                    if !parts.status.is_success() {
5643                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5644                        let error = serde_json::from_str(&common::to_string(&bytes));
5645                        let response = common::to_response(parts, bytes.into());
5646
5647                        if let common::Retry::After(d) =
5648                            dlg.http_failure(&response, error.as_ref().ok())
5649                        {
5650                            sleep(d).await;
5651                            continue;
5652                        }
5653
5654                        dlg.finished(false);
5655
5656                        return Err(match error {
5657                            Ok(value) => common::Error::BadRequest(value),
5658                            _ => common::Error::Failure(response),
5659                        });
5660                    }
5661                    let response = {
5662                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5663                        let encoded = common::to_string(&bytes);
5664                        match serde_json::from_str(&encoded) {
5665                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5666                            Err(error) => {
5667                                dlg.response_json_decode_error(&encoded, &error);
5668                                return Err(common::Error::JsonDecodeError(
5669                                    encoded.to_string(),
5670                                    error,
5671                                ));
5672                            }
5673                        }
5674                    };
5675
5676                    dlg.finished(true);
5677                    return Ok(response);
5678                }
5679            }
5680        }
5681    }
5682
5683    ///
5684    /// Sets the *request* property to the given value.
5685    ///
5686    /// Even though the property as already been set when instantiating this call,
5687    /// we provide this method for API completeness.
5688    pub fn request(mut self, new_value: PauseQueueRequest) -> ProjectLocationQueuePauseCall<'a, C> {
5689        self._request = new_value;
5690        self
5691    }
5692    /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
5693    ///
5694    /// Sets the *name* path property to the given value.
5695    ///
5696    /// Even though the property as already been set when instantiating this call,
5697    /// we provide this method for API completeness.
5698    pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePauseCall<'a, C> {
5699        self._name = new_value.to_string();
5700        self
5701    }
5702    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5703    /// while executing the actual API request.
5704    ///
5705    /// ````text
5706    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5707    /// ````
5708    ///
5709    /// Sets the *delegate* property to the given value.
5710    pub fn delegate(
5711        mut self,
5712        new_value: &'a mut dyn common::Delegate,
5713    ) -> ProjectLocationQueuePauseCall<'a, C> {
5714        self._delegate = Some(new_value);
5715        self
5716    }
5717
5718    /// Set any additional parameter of the query string used in the request.
5719    /// It should be used to set parameters which are not yet available through their own
5720    /// setters.
5721    ///
5722    /// Please note that this method must not be used to set any of the known parameters
5723    /// which have their own setter method. If done anyway, the request will fail.
5724    ///
5725    /// # Additional Parameters
5726    ///
5727    /// * *$.xgafv* (query-string) - V1 error format.
5728    /// * *access_token* (query-string) - OAuth access token.
5729    /// * *alt* (query-string) - Data format for response.
5730    /// * *callback* (query-string) - JSONP
5731    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5732    /// * *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.
5733    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5734    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5735    /// * *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.
5736    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5737    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5738    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePauseCall<'a, C>
5739    where
5740        T: AsRef<str>,
5741    {
5742        self._additional_params
5743            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5744        self
5745    }
5746
5747    /// Identifies the authorization scope for the method you are building.
5748    ///
5749    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5750    /// [`Scope::CloudPlatform`].
5751    ///
5752    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5753    /// tokens for more than one scope.
5754    ///
5755    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5756    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5757    /// sufficient, a read-write scope will do as well.
5758    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePauseCall<'a, C>
5759    where
5760        St: AsRef<str>,
5761    {
5762        self._scopes.insert(String::from(scope.as_ref()));
5763        self
5764    }
5765    /// Identifies the authorization scope(s) for the method you are building.
5766    ///
5767    /// See [`Self::add_scope()`] for details.
5768    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePauseCall<'a, C>
5769    where
5770        I: IntoIterator<Item = St>,
5771        St: AsRef<str>,
5772    {
5773        self._scopes
5774            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5775        self
5776    }
5777
5778    /// Removes all scopes, and no default scope will be used either.
5779    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5780    /// for details).
5781    pub fn clear_scopes(mut self) -> ProjectLocationQueuePauseCall<'a, C> {
5782        self._scopes.clear();
5783        self
5784    }
5785}
5786
5787/// 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.
5788///
5789/// A builder for the *locations.queues.purge* method supported by a *project* resource.
5790/// It is not used directly, but through a [`ProjectMethods`] instance.
5791///
5792/// # Example
5793///
5794/// Instantiate a resource method builder
5795///
5796/// ```test_harness,no_run
5797/// # extern crate hyper;
5798/// # extern crate hyper_rustls;
5799/// # extern crate google_cloudtasks2 as cloudtasks2;
5800/// use cloudtasks2::api::PurgeQueueRequest;
5801/// # async fn dox() {
5802/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5803///
5804/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5805/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5806/// #     .with_native_roots()
5807/// #     .unwrap()
5808/// #     .https_only()
5809/// #     .enable_http2()
5810/// #     .build();
5811///
5812/// # let executor = hyper_util::rt::TokioExecutor::new();
5813/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5814/// #     secret,
5815/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5816/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5817/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5818/// #     ),
5819/// # ).build().await.unwrap();
5820///
5821/// # let client = hyper_util::client::legacy::Client::builder(
5822/// #     hyper_util::rt::TokioExecutor::new()
5823/// # )
5824/// # .build(
5825/// #     hyper_rustls::HttpsConnectorBuilder::new()
5826/// #         .with_native_roots()
5827/// #         .unwrap()
5828/// #         .https_or_http()
5829/// #         .enable_http2()
5830/// #         .build()
5831/// # );
5832/// # let mut hub = CloudTasks::new(client, auth);
5833/// // As the method needs a request, you would usually fill it with the desired information
5834/// // into the respective structure. Some of the parts shown here might not be applicable !
5835/// // Values shown here are possibly random and not representative !
5836/// let mut req = PurgeQueueRequest::default();
5837///
5838/// // You can configure optional parameters by calling the respective setters at will, and
5839/// // execute the final call using `doit()`.
5840/// // Values shown here are possibly random and not representative !
5841/// let result = hub.projects().locations_queues_purge(req, "name")
5842///              .doit().await;
5843/// # }
5844/// ```
5845pub struct ProjectLocationQueuePurgeCall<'a, C>
5846where
5847    C: 'a,
5848{
5849    hub: &'a CloudTasks<C>,
5850    _request: PurgeQueueRequest,
5851    _name: String,
5852    _delegate: Option<&'a mut dyn common::Delegate>,
5853    _additional_params: HashMap<String, String>,
5854    _scopes: BTreeSet<String>,
5855}
5856
5857impl<'a, C> common::CallBuilder for ProjectLocationQueuePurgeCall<'a, C> {}
5858
5859impl<'a, C> ProjectLocationQueuePurgeCall<'a, C>
5860where
5861    C: common::Connector,
5862{
5863    /// Perform the operation you have build so far.
5864    pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
5865        use std::borrow::Cow;
5866        use std::io::{Read, Seek};
5867
5868        use common::{url::Params, ToParts};
5869        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5870
5871        let mut dd = common::DefaultDelegate;
5872        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5873        dlg.begin(common::MethodInfo {
5874            id: "cloudtasks.projects.locations.queues.purge",
5875            http_method: hyper::Method::POST,
5876        });
5877
5878        for &field in ["alt", "name"].iter() {
5879            if self._additional_params.contains_key(field) {
5880                dlg.finished(false);
5881                return Err(common::Error::FieldClash(field));
5882            }
5883        }
5884
5885        let mut params = Params::with_capacity(4 + self._additional_params.len());
5886        params.push("name", self._name);
5887
5888        params.extend(self._additional_params.iter());
5889
5890        params.push("alt", "json");
5891        let mut url = self.hub._base_url.clone() + "v2/{+name}:purge";
5892        if self._scopes.is_empty() {
5893            self._scopes
5894                .insert(Scope::CloudPlatform.as_ref().to_string());
5895        }
5896
5897        #[allow(clippy::single_element_loop)]
5898        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5899            url = params.uri_replacement(url, param_name, find_this, true);
5900        }
5901        {
5902            let to_remove = ["name"];
5903            params.remove_params(&to_remove);
5904        }
5905
5906        let url = params.parse_with_url(&url);
5907
5908        let mut json_mime_type = mime::APPLICATION_JSON;
5909        let mut request_value_reader = {
5910            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5911            common::remove_json_null_values(&mut value);
5912            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5913            serde_json::to_writer(&mut dst, &value).unwrap();
5914            dst
5915        };
5916        let request_size = request_value_reader
5917            .seek(std::io::SeekFrom::End(0))
5918            .unwrap();
5919        request_value_reader
5920            .seek(std::io::SeekFrom::Start(0))
5921            .unwrap();
5922
5923        loop {
5924            let token = match self
5925                .hub
5926                .auth
5927                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5928                .await
5929            {
5930                Ok(token) => token,
5931                Err(e) => match dlg.token(e) {
5932                    Ok(token) => token,
5933                    Err(e) => {
5934                        dlg.finished(false);
5935                        return Err(common::Error::MissingToken(e));
5936                    }
5937                },
5938            };
5939            request_value_reader
5940                .seek(std::io::SeekFrom::Start(0))
5941                .unwrap();
5942            let mut req_result = {
5943                let client = &self.hub.client;
5944                dlg.pre_request();
5945                let mut req_builder = hyper::Request::builder()
5946                    .method(hyper::Method::POST)
5947                    .uri(url.as_str())
5948                    .header(USER_AGENT, self.hub._user_agent.clone());
5949
5950                if let Some(token) = token.as_ref() {
5951                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5952                }
5953
5954                let request = req_builder
5955                    .header(CONTENT_TYPE, json_mime_type.to_string())
5956                    .header(CONTENT_LENGTH, request_size as u64)
5957                    .body(common::to_body(
5958                        request_value_reader.get_ref().clone().into(),
5959                    ));
5960
5961                client.request(request.unwrap()).await
5962            };
5963
5964            match req_result {
5965                Err(err) => {
5966                    if let common::Retry::After(d) = dlg.http_error(&err) {
5967                        sleep(d).await;
5968                        continue;
5969                    }
5970                    dlg.finished(false);
5971                    return Err(common::Error::HttpError(err));
5972                }
5973                Ok(res) => {
5974                    let (mut parts, body) = res.into_parts();
5975                    let mut body = common::Body::new(body);
5976                    if !parts.status.is_success() {
5977                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5978                        let error = serde_json::from_str(&common::to_string(&bytes));
5979                        let response = common::to_response(parts, bytes.into());
5980
5981                        if let common::Retry::After(d) =
5982                            dlg.http_failure(&response, error.as_ref().ok())
5983                        {
5984                            sleep(d).await;
5985                            continue;
5986                        }
5987
5988                        dlg.finished(false);
5989
5990                        return Err(match error {
5991                            Ok(value) => common::Error::BadRequest(value),
5992                            _ => common::Error::Failure(response),
5993                        });
5994                    }
5995                    let response = {
5996                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5997                        let encoded = common::to_string(&bytes);
5998                        match serde_json::from_str(&encoded) {
5999                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6000                            Err(error) => {
6001                                dlg.response_json_decode_error(&encoded, &error);
6002                                return Err(common::Error::JsonDecodeError(
6003                                    encoded.to_string(),
6004                                    error,
6005                                ));
6006                            }
6007                        }
6008                    };
6009
6010                    dlg.finished(true);
6011                    return Ok(response);
6012                }
6013            }
6014        }
6015    }
6016
6017    ///
6018    /// Sets the *request* property to the given value.
6019    ///
6020    /// Even though the property as already been set when instantiating this call,
6021    /// we provide this method for API completeness.
6022    pub fn request(mut self, new_value: PurgeQueueRequest) -> ProjectLocationQueuePurgeCall<'a, C> {
6023        self._request = new_value;
6024        self
6025    }
6026    /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
6027    ///
6028    /// Sets the *name* path property to the given value.
6029    ///
6030    /// Even though the property as already been set when instantiating this call,
6031    /// we provide this method for API completeness.
6032    pub fn name(mut self, new_value: &str) -> ProjectLocationQueuePurgeCall<'a, C> {
6033        self._name = new_value.to_string();
6034        self
6035    }
6036    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6037    /// while executing the actual API request.
6038    ///
6039    /// ````text
6040    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6041    /// ````
6042    ///
6043    /// Sets the *delegate* property to the given value.
6044    pub fn delegate(
6045        mut self,
6046        new_value: &'a mut dyn common::Delegate,
6047    ) -> ProjectLocationQueuePurgeCall<'a, C> {
6048        self._delegate = Some(new_value);
6049        self
6050    }
6051
6052    /// Set any additional parameter of the query string used in the request.
6053    /// It should be used to set parameters which are not yet available through their own
6054    /// setters.
6055    ///
6056    /// Please note that this method must not be used to set any of the known parameters
6057    /// which have their own setter method. If done anyway, the request will fail.
6058    ///
6059    /// # Additional Parameters
6060    ///
6061    /// * *$.xgafv* (query-string) - V1 error format.
6062    /// * *access_token* (query-string) - OAuth access token.
6063    /// * *alt* (query-string) - Data format for response.
6064    /// * *callback* (query-string) - JSONP
6065    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6066    /// * *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.
6067    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6068    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6069    /// * *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.
6070    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6071    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6072    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueuePurgeCall<'a, C>
6073    where
6074        T: AsRef<str>,
6075    {
6076        self._additional_params
6077            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6078        self
6079    }
6080
6081    /// Identifies the authorization scope for the method you are building.
6082    ///
6083    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6084    /// [`Scope::CloudPlatform`].
6085    ///
6086    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6087    /// tokens for more than one scope.
6088    ///
6089    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6090    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6091    /// sufficient, a read-write scope will do as well.
6092    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueuePurgeCall<'a, C>
6093    where
6094        St: AsRef<str>,
6095    {
6096        self._scopes.insert(String::from(scope.as_ref()));
6097        self
6098    }
6099    /// Identifies the authorization scope(s) for the method you are building.
6100    ///
6101    /// See [`Self::add_scope()`] for details.
6102    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueuePurgeCall<'a, C>
6103    where
6104        I: IntoIterator<Item = St>,
6105        St: AsRef<str>,
6106    {
6107        self._scopes
6108            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6109        self
6110    }
6111
6112    /// Removes all scopes, and no default scope will be used either.
6113    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6114    /// for details).
6115    pub fn clear_scopes(mut self) -> ProjectLocationQueuePurgeCall<'a, C> {
6116        self._scopes.clear();
6117        self
6118    }
6119}
6120
6121/// 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).
6122///
6123/// A builder for the *locations.queues.resume* method supported by a *project* resource.
6124/// It is not used directly, but through a [`ProjectMethods`] instance.
6125///
6126/// # Example
6127///
6128/// Instantiate a resource method builder
6129///
6130/// ```test_harness,no_run
6131/// # extern crate hyper;
6132/// # extern crate hyper_rustls;
6133/// # extern crate google_cloudtasks2 as cloudtasks2;
6134/// use cloudtasks2::api::ResumeQueueRequest;
6135/// # async fn dox() {
6136/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6137///
6138/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6139/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6140/// #     .with_native_roots()
6141/// #     .unwrap()
6142/// #     .https_only()
6143/// #     .enable_http2()
6144/// #     .build();
6145///
6146/// # let executor = hyper_util::rt::TokioExecutor::new();
6147/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6148/// #     secret,
6149/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6150/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6151/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6152/// #     ),
6153/// # ).build().await.unwrap();
6154///
6155/// # let client = hyper_util::client::legacy::Client::builder(
6156/// #     hyper_util::rt::TokioExecutor::new()
6157/// # )
6158/// # .build(
6159/// #     hyper_rustls::HttpsConnectorBuilder::new()
6160/// #         .with_native_roots()
6161/// #         .unwrap()
6162/// #         .https_or_http()
6163/// #         .enable_http2()
6164/// #         .build()
6165/// # );
6166/// # let mut hub = CloudTasks::new(client, auth);
6167/// // As the method needs a request, you would usually fill it with the desired information
6168/// // into the respective structure. Some of the parts shown here might not be applicable !
6169/// // Values shown here are possibly random and not representative !
6170/// let mut req = ResumeQueueRequest::default();
6171///
6172/// // You can configure optional parameters by calling the respective setters at will, and
6173/// // execute the final call using `doit()`.
6174/// // Values shown here are possibly random and not representative !
6175/// let result = hub.projects().locations_queues_resume(req, "name")
6176///              .doit().await;
6177/// # }
6178/// ```
6179pub struct ProjectLocationQueueResumeCall<'a, C>
6180where
6181    C: 'a,
6182{
6183    hub: &'a CloudTasks<C>,
6184    _request: ResumeQueueRequest,
6185    _name: String,
6186    _delegate: Option<&'a mut dyn common::Delegate>,
6187    _additional_params: HashMap<String, String>,
6188    _scopes: BTreeSet<String>,
6189}
6190
6191impl<'a, C> common::CallBuilder for ProjectLocationQueueResumeCall<'a, C> {}
6192
6193impl<'a, C> ProjectLocationQueueResumeCall<'a, C>
6194where
6195    C: common::Connector,
6196{
6197    /// Perform the operation you have build so far.
6198    pub async fn doit(mut self) -> common::Result<(common::Response, Queue)> {
6199        use std::borrow::Cow;
6200        use std::io::{Read, Seek};
6201
6202        use common::{url::Params, ToParts};
6203        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6204
6205        let mut dd = common::DefaultDelegate;
6206        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6207        dlg.begin(common::MethodInfo {
6208            id: "cloudtasks.projects.locations.queues.resume",
6209            http_method: hyper::Method::POST,
6210        });
6211
6212        for &field in ["alt", "name"].iter() {
6213            if self._additional_params.contains_key(field) {
6214                dlg.finished(false);
6215                return Err(common::Error::FieldClash(field));
6216            }
6217        }
6218
6219        let mut params = Params::with_capacity(4 + self._additional_params.len());
6220        params.push("name", self._name);
6221
6222        params.extend(self._additional_params.iter());
6223
6224        params.push("alt", "json");
6225        let mut url = self.hub._base_url.clone() + "v2/{+name}:resume";
6226        if self._scopes.is_empty() {
6227            self._scopes
6228                .insert(Scope::CloudPlatform.as_ref().to_string());
6229        }
6230
6231        #[allow(clippy::single_element_loop)]
6232        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6233            url = params.uri_replacement(url, param_name, find_this, true);
6234        }
6235        {
6236            let to_remove = ["name"];
6237            params.remove_params(&to_remove);
6238        }
6239
6240        let url = params.parse_with_url(&url);
6241
6242        let mut json_mime_type = mime::APPLICATION_JSON;
6243        let mut request_value_reader = {
6244            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6245            common::remove_json_null_values(&mut value);
6246            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6247            serde_json::to_writer(&mut dst, &value).unwrap();
6248            dst
6249        };
6250        let request_size = request_value_reader
6251            .seek(std::io::SeekFrom::End(0))
6252            .unwrap();
6253        request_value_reader
6254            .seek(std::io::SeekFrom::Start(0))
6255            .unwrap();
6256
6257        loop {
6258            let token = match self
6259                .hub
6260                .auth
6261                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6262                .await
6263            {
6264                Ok(token) => token,
6265                Err(e) => match dlg.token(e) {
6266                    Ok(token) => token,
6267                    Err(e) => {
6268                        dlg.finished(false);
6269                        return Err(common::Error::MissingToken(e));
6270                    }
6271                },
6272            };
6273            request_value_reader
6274                .seek(std::io::SeekFrom::Start(0))
6275                .unwrap();
6276            let mut req_result = {
6277                let client = &self.hub.client;
6278                dlg.pre_request();
6279                let mut req_builder = hyper::Request::builder()
6280                    .method(hyper::Method::POST)
6281                    .uri(url.as_str())
6282                    .header(USER_AGENT, self.hub._user_agent.clone());
6283
6284                if let Some(token) = token.as_ref() {
6285                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6286                }
6287
6288                let request = req_builder
6289                    .header(CONTENT_TYPE, json_mime_type.to_string())
6290                    .header(CONTENT_LENGTH, request_size as u64)
6291                    .body(common::to_body(
6292                        request_value_reader.get_ref().clone().into(),
6293                    ));
6294
6295                client.request(request.unwrap()).await
6296            };
6297
6298            match req_result {
6299                Err(err) => {
6300                    if let common::Retry::After(d) = dlg.http_error(&err) {
6301                        sleep(d).await;
6302                        continue;
6303                    }
6304                    dlg.finished(false);
6305                    return Err(common::Error::HttpError(err));
6306                }
6307                Ok(res) => {
6308                    let (mut parts, body) = res.into_parts();
6309                    let mut body = common::Body::new(body);
6310                    if !parts.status.is_success() {
6311                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6312                        let error = serde_json::from_str(&common::to_string(&bytes));
6313                        let response = common::to_response(parts, bytes.into());
6314
6315                        if let common::Retry::After(d) =
6316                            dlg.http_failure(&response, error.as_ref().ok())
6317                        {
6318                            sleep(d).await;
6319                            continue;
6320                        }
6321
6322                        dlg.finished(false);
6323
6324                        return Err(match error {
6325                            Ok(value) => common::Error::BadRequest(value),
6326                            _ => common::Error::Failure(response),
6327                        });
6328                    }
6329                    let response = {
6330                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6331                        let encoded = common::to_string(&bytes);
6332                        match serde_json::from_str(&encoded) {
6333                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6334                            Err(error) => {
6335                                dlg.response_json_decode_error(&encoded, &error);
6336                                return Err(common::Error::JsonDecodeError(
6337                                    encoded.to_string(),
6338                                    error,
6339                                ));
6340                            }
6341                        }
6342                    };
6343
6344                    dlg.finished(true);
6345                    return Ok(response);
6346                }
6347            }
6348        }
6349    }
6350
6351    ///
6352    /// Sets the *request* property to the given value.
6353    ///
6354    /// Even though the property as already been set when instantiating this call,
6355    /// we provide this method for API completeness.
6356    pub fn request(
6357        mut self,
6358        new_value: ResumeQueueRequest,
6359    ) -> ProjectLocationQueueResumeCall<'a, C> {
6360        self._request = new_value;
6361        self
6362    }
6363    /// Required. The queue name. For example: `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
6364    ///
6365    /// Sets the *name* path property to the given value.
6366    ///
6367    /// Even though the property as already been set when instantiating this call,
6368    /// we provide this method for API completeness.
6369    pub fn name(mut self, new_value: &str) -> ProjectLocationQueueResumeCall<'a, C> {
6370        self._name = new_value.to_string();
6371        self
6372    }
6373    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6374    /// while executing the actual API request.
6375    ///
6376    /// ````text
6377    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6378    /// ````
6379    ///
6380    /// Sets the *delegate* property to the given value.
6381    pub fn delegate(
6382        mut self,
6383        new_value: &'a mut dyn common::Delegate,
6384    ) -> ProjectLocationQueueResumeCall<'a, C> {
6385        self._delegate = Some(new_value);
6386        self
6387    }
6388
6389    /// Set any additional parameter of the query string used in the request.
6390    /// It should be used to set parameters which are not yet available through their own
6391    /// setters.
6392    ///
6393    /// Please note that this method must not be used to set any of the known parameters
6394    /// which have their own setter method. If done anyway, the request will fail.
6395    ///
6396    /// # Additional Parameters
6397    ///
6398    /// * *$.xgafv* (query-string) - V1 error format.
6399    /// * *access_token* (query-string) - OAuth access token.
6400    /// * *alt* (query-string) - Data format for response.
6401    /// * *callback* (query-string) - JSONP
6402    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6403    /// * *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.
6404    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6405    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6406    /// * *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.
6407    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6408    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6409    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueResumeCall<'a, C>
6410    where
6411        T: AsRef<str>,
6412    {
6413        self._additional_params
6414            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6415        self
6416    }
6417
6418    /// Identifies the authorization scope for the method you are building.
6419    ///
6420    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6421    /// [`Scope::CloudPlatform`].
6422    ///
6423    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6424    /// tokens for more than one scope.
6425    ///
6426    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6427    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6428    /// sufficient, a read-write scope will do as well.
6429    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueResumeCall<'a, C>
6430    where
6431        St: AsRef<str>,
6432    {
6433        self._scopes.insert(String::from(scope.as_ref()));
6434        self
6435    }
6436    /// Identifies the authorization scope(s) for the method you are building.
6437    ///
6438    /// See [`Self::add_scope()`] for details.
6439    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueResumeCall<'a, C>
6440    where
6441        I: IntoIterator<Item = St>,
6442        St: AsRef<str>,
6443    {
6444        self._scopes
6445            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6446        self
6447    }
6448
6449    /// Removes all scopes, and no default scope will be used either.
6450    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6451    /// for details).
6452    pub fn clear_scopes(mut self) -> ProjectLocationQueueResumeCall<'a, C> {
6453        self._scopes.clear();
6454        self
6455    }
6456}
6457
6458/// 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`
6459///
6460/// A builder for the *locations.queues.setIamPolicy* method supported by a *project* resource.
6461/// It is not used directly, but through a [`ProjectMethods`] instance.
6462///
6463/// # Example
6464///
6465/// Instantiate a resource method builder
6466///
6467/// ```test_harness,no_run
6468/// # extern crate hyper;
6469/// # extern crate hyper_rustls;
6470/// # extern crate google_cloudtasks2 as cloudtasks2;
6471/// use cloudtasks2::api::SetIamPolicyRequest;
6472/// # async fn dox() {
6473/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6474///
6475/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6476/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6477/// #     .with_native_roots()
6478/// #     .unwrap()
6479/// #     .https_only()
6480/// #     .enable_http2()
6481/// #     .build();
6482///
6483/// # let executor = hyper_util::rt::TokioExecutor::new();
6484/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6485/// #     secret,
6486/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6487/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6488/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6489/// #     ),
6490/// # ).build().await.unwrap();
6491///
6492/// # let client = hyper_util::client::legacy::Client::builder(
6493/// #     hyper_util::rt::TokioExecutor::new()
6494/// # )
6495/// # .build(
6496/// #     hyper_rustls::HttpsConnectorBuilder::new()
6497/// #         .with_native_roots()
6498/// #         .unwrap()
6499/// #         .https_or_http()
6500/// #         .enable_http2()
6501/// #         .build()
6502/// # );
6503/// # let mut hub = CloudTasks::new(client, auth);
6504/// // As the method needs a request, you would usually fill it with the desired information
6505/// // into the respective structure. Some of the parts shown here might not be applicable !
6506/// // Values shown here are possibly random and not representative !
6507/// let mut req = SetIamPolicyRequest::default();
6508///
6509/// // You can configure optional parameters by calling the respective setters at will, and
6510/// // execute the final call using `doit()`.
6511/// // Values shown here are possibly random and not representative !
6512/// let result = hub.projects().locations_queues_set_iam_policy(req, "resource")
6513///              .doit().await;
6514/// # }
6515/// ```
6516pub struct ProjectLocationQueueSetIamPolicyCall<'a, C>
6517where
6518    C: 'a,
6519{
6520    hub: &'a CloudTasks<C>,
6521    _request: SetIamPolicyRequest,
6522    _resource: String,
6523    _delegate: Option<&'a mut dyn common::Delegate>,
6524    _additional_params: HashMap<String, String>,
6525    _scopes: BTreeSet<String>,
6526}
6527
6528impl<'a, C> common::CallBuilder for ProjectLocationQueueSetIamPolicyCall<'a, C> {}
6529
6530impl<'a, C> ProjectLocationQueueSetIamPolicyCall<'a, C>
6531where
6532    C: common::Connector,
6533{
6534    /// Perform the operation you have build so far.
6535    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6536        use std::borrow::Cow;
6537        use std::io::{Read, Seek};
6538
6539        use common::{url::Params, ToParts};
6540        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6541
6542        let mut dd = common::DefaultDelegate;
6543        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6544        dlg.begin(common::MethodInfo {
6545            id: "cloudtasks.projects.locations.queues.setIamPolicy",
6546            http_method: hyper::Method::POST,
6547        });
6548
6549        for &field in ["alt", "resource"].iter() {
6550            if self._additional_params.contains_key(field) {
6551                dlg.finished(false);
6552                return Err(common::Error::FieldClash(field));
6553            }
6554        }
6555
6556        let mut params = Params::with_capacity(4 + self._additional_params.len());
6557        params.push("resource", self._resource);
6558
6559        params.extend(self._additional_params.iter());
6560
6561        params.push("alt", "json");
6562        let mut url = self.hub._base_url.clone() + "v2/{+resource}:setIamPolicy";
6563        if self._scopes.is_empty() {
6564            self._scopes
6565                .insert(Scope::CloudPlatform.as_ref().to_string());
6566        }
6567
6568        #[allow(clippy::single_element_loop)]
6569        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6570            url = params.uri_replacement(url, param_name, find_this, true);
6571        }
6572        {
6573            let to_remove = ["resource"];
6574            params.remove_params(&to_remove);
6575        }
6576
6577        let url = params.parse_with_url(&url);
6578
6579        let mut json_mime_type = mime::APPLICATION_JSON;
6580        let mut request_value_reader = {
6581            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6582            common::remove_json_null_values(&mut value);
6583            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6584            serde_json::to_writer(&mut dst, &value).unwrap();
6585            dst
6586        };
6587        let request_size = request_value_reader
6588            .seek(std::io::SeekFrom::End(0))
6589            .unwrap();
6590        request_value_reader
6591            .seek(std::io::SeekFrom::Start(0))
6592            .unwrap();
6593
6594        loop {
6595            let token = match self
6596                .hub
6597                .auth
6598                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6599                .await
6600            {
6601                Ok(token) => token,
6602                Err(e) => match dlg.token(e) {
6603                    Ok(token) => token,
6604                    Err(e) => {
6605                        dlg.finished(false);
6606                        return Err(common::Error::MissingToken(e));
6607                    }
6608                },
6609            };
6610            request_value_reader
6611                .seek(std::io::SeekFrom::Start(0))
6612                .unwrap();
6613            let mut req_result = {
6614                let client = &self.hub.client;
6615                dlg.pre_request();
6616                let mut req_builder = hyper::Request::builder()
6617                    .method(hyper::Method::POST)
6618                    .uri(url.as_str())
6619                    .header(USER_AGENT, self.hub._user_agent.clone());
6620
6621                if let Some(token) = token.as_ref() {
6622                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6623                }
6624
6625                let request = req_builder
6626                    .header(CONTENT_TYPE, json_mime_type.to_string())
6627                    .header(CONTENT_LENGTH, request_size as u64)
6628                    .body(common::to_body(
6629                        request_value_reader.get_ref().clone().into(),
6630                    ));
6631
6632                client.request(request.unwrap()).await
6633            };
6634
6635            match req_result {
6636                Err(err) => {
6637                    if let common::Retry::After(d) = dlg.http_error(&err) {
6638                        sleep(d).await;
6639                        continue;
6640                    }
6641                    dlg.finished(false);
6642                    return Err(common::Error::HttpError(err));
6643                }
6644                Ok(res) => {
6645                    let (mut parts, body) = res.into_parts();
6646                    let mut body = common::Body::new(body);
6647                    if !parts.status.is_success() {
6648                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6649                        let error = serde_json::from_str(&common::to_string(&bytes));
6650                        let response = common::to_response(parts, bytes.into());
6651
6652                        if let common::Retry::After(d) =
6653                            dlg.http_failure(&response, error.as_ref().ok())
6654                        {
6655                            sleep(d).await;
6656                            continue;
6657                        }
6658
6659                        dlg.finished(false);
6660
6661                        return Err(match error {
6662                            Ok(value) => common::Error::BadRequest(value),
6663                            _ => common::Error::Failure(response),
6664                        });
6665                    }
6666                    let response = {
6667                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6668                        let encoded = common::to_string(&bytes);
6669                        match serde_json::from_str(&encoded) {
6670                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6671                            Err(error) => {
6672                                dlg.response_json_decode_error(&encoded, &error);
6673                                return Err(common::Error::JsonDecodeError(
6674                                    encoded.to_string(),
6675                                    error,
6676                                ));
6677                            }
6678                        }
6679                    };
6680
6681                    dlg.finished(true);
6682                    return Ok(response);
6683                }
6684            }
6685        }
6686    }
6687
6688    ///
6689    /// Sets the *request* property to the given value.
6690    ///
6691    /// Even though the property as already been set when instantiating this call,
6692    /// we provide this method for API completeness.
6693    pub fn request(
6694        mut self,
6695        new_value: SetIamPolicyRequest,
6696    ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
6697        self._request = new_value;
6698        self
6699    }
6700    /// 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.
6701    ///
6702    /// Sets the *resource* path property to the given value.
6703    ///
6704    /// Even though the property as already been set when instantiating this call,
6705    /// we provide this method for API completeness.
6706    pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
6707        self._resource = new_value.to_string();
6708        self
6709    }
6710    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6711    /// while executing the actual API request.
6712    ///
6713    /// ````text
6714    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6715    /// ````
6716    ///
6717    /// Sets the *delegate* property to the given value.
6718    pub fn delegate(
6719        mut self,
6720        new_value: &'a mut dyn common::Delegate,
6721    ) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
6722        self._delegate = Some(new_value);
6723        self
6724    }
6725
6726    /// Set any additional parameter of the query string used in the request.
6727    /// It should be used to set parameters which are not yet available through their own
6728    /// setters.
6729    ///
6730    /// Please note that this method must not be used to set any of the known parameters
6731    /// which have their own setter method. If done anyway, the request will fail.
6732    ///
6733    /// # Additional Parameters
6734    ///
6735    /// * *$.xgafv* (query-string) - V1 error format.
6736    /// * *access_token* (query-string) - OAuth access token.
6737    /// * *alt* (query-string) - Data format for response.
6738    /// * *callback* (query-string) - JSONP
6739    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6740    /// * *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.
6741    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6742    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6743    /// * *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.
6744    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6745    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6746    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
6747    where
6748        T: AsRef<str>,
6749    {
6750        self._additional_params
6751            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6752        self
6753    }
6754
6755    /// Identifies the authorization scope for the method you are building.
6756    ///
6757    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6758    /// [`Scope::CloudPlatform`].
6759    ///
6760    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6761    /// tokens for more than one scope.
6762    ///
6763    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6764    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6765    /// sufficient, a read-write scope will do as well.
6766    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
6767    where
6768        St: AsRef<str>,
6769    {
6770        self._scopes.insert(String::from(scope.as_ref()));
6771        self
6772    }
6773    /// Identifies the authorization scope(s) for the method you are building.
6774    ///
6775    /// See [`Self::add_scope()`] for details.
6776    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationQueueSetIamPolicyCall<'a, C>
6777    where
6778        I: IntoIterator<Item = St>,
6779        St: AsRef<str>,
6780    {
6781        self._scopes
6782            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6783        self
6784    }
6785
6786    /// Removes all scopes, and no default scope will be used either.
6787    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6788    /// for details).
6789    pub fn clear_scopes(mut self) -> ProjectLocationQueueSetIamPolicyCall<'a, C> {
6790        self._scopes.clear();
6791        self
6792    }
6793}
6794
6795/// 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.
6796///
6797/// A builder for the *locations.queues.testIamPermissions* method supported by a *project* resource.
6798/// It is not used directly, but through a [`ProjectMethods`] instance.
6799///
6800/// # Example
6801///
6802/// Instantiate a resource method builder
6803///
6804/// ```test_harness,no_run
6805/// # extern crate hyper;
6806/// # extern crate hyper_rustls;
6807/// # extern crate google_cloudtasks2 as cloudtasks2;
6808/// use cloudtasks2::api::TestIamPermissionsRequest;
6809/// # async fn dox() {
6810/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6811///
6812/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6813/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6814/// #     .with_native_roots()
6815/// #     .unwrap()
6816/// #     .https_only()
6817/// #     .enable_http2()
6818/// #     .build();
6819///
6820/// # let executor = hyper_util::rt::TokioExecutor::new();
6821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6822/// #     secret,
6823/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6824/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6825/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6826/// #     ),
6827/// # ).build().await.unwrap();
6828///
6829/// # let client = hyper_util::client::legacy::Client::builder(
6830/// #     hyper_util::rt::TokioExecutor::new()
6831/// # )
6832/// # .build(
6833/// #     hyper_rustls::HttpsConnectorBuilder::new()
6834/// #         .with_native_roots()
6835/// #         .unwrap()
6836/// #         .https_or_http()
6837/// #         .enable_http2()
6838/// #         .build()
6839/// # );
6840/// # let mut hub = CloudTasks::new(client, auth);
6841/// // As the method needs a request, you would usually fill it with the desired information
6842/// // into the respective structure. Some of the parts shown here might not be applicable !
6843/// // Values shown here are possibly random and not representative !
6844/// let mut req = TestIamPermissionsRequest::default();
6845///
6846/// // You can configure optional parameters by calling the respective setters at will, and
6847/// // execute the final call using `doit()`.
6848/// // Values shown here are possibly random and not representative !
6849/// let result = hub.projects().locations_queues_test_iam_permissions(req, "resource")
6850///              .doit().await;
6851/// # }
6852/// ```
6853pub struct ProjectLocationQueueTestIamPermissionCall<'a, C>
6854where
6855    C: 'a,
6856{
6857    hub: &'a CloudTasks<C>,
6858    _request: TestIamPermissionsRequest,
6859    _resource: String,
6860    _delegate: Option<&'a mut dyn common::Delegate>,
6861    _additional_params: HashMap<String, String>,
6862    _scopes: BTreeSet<String>,
6863}
6864
6865impl<'a, C> common::CallBuilder for ProjectLocationQueueTestIamPermissionCall<'a, C> {}
6866
6867impl<'a, C> ProjectLocationQueueTestIamPermissionCall<'a, C>
6868where
6869    C: common::Connector,
6870{
6871    /// Perform the operation you have build so far.
6872    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
6873        use std::borrow::Cow;
6874        use std::io::{Read, Seek};
6875
6876        use common::{url::Params, ToParts};
6877        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6878
6879        let mut dd = common::DefaultDelegate;
6880        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6881        dlg.begin(common::MethodInfo {
6882            id: "cloudtasks.projects.locations.queues.testIamPermissions",
6883            http_method: hyper::Method::POST,
6884        });
6885
6886        for &field in ["alt", "resource"].iter() {
6887            if self._additional_params.contains_key(field) {
6888                dlg.finished(false);
6889                return Err(common::Error::FieldClash(field));
6890            }
6891        }
6892
6893        let mut params = Params::with_capacity(4 + self._additional_params.len());
6894        params.push("resource", self._resource);
6895
6896        params.extend(self._additional_params.iter());
6897
6898        params.push("alt", "json");
6899        let mut url = self.hub._base_url.clone() + "v2/{+resource}:testIamPermissions";
6900        if self._scopes.is_empty() {
6901            self._scopes
6902                .insert(Scope::CloudPlatform.as_ref().to_string());
6903        }
6904
6905        #[allow(clippy::single_element_loop)]
6906        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6907            url = params.uri_replacement(url, param_name, find_this, true);
6908        }
6909        {
6910            let to_remove = ["resource"];
6911            params.remove_params(&to_remove);
6912        }
6913
6914        let url = params.parse_with_url(&url);
6915
6916        let mut json_mime_type = mime::APPLICATION_JSON;
6917        let mut request_value_reader = {
6918            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6919            common::remove_json_null_values(&mut value);
6920            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6921            serde_json::to_writer(&mut dst, &value).unwrap();
6922            dst
6923        };
6924        let request_size = request_value_reader
6925            .seek(std::io::SeekFrom::End(0))
6926            .unwrap();
6927        request_value_reader
6928            .seek(std::io::SeekFrom::Start(0))
6929            .unwrap();
6930
6931        loop {
6932            let token = match self
6933                .hub
6934                .auth
6935                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6936                .await
6937            {
6938                Ok(token) => token,
6939                Err(e) => match dlg.token(e) {
6940                    Ok(token) => token,
6941                    Err(e) => {
6942                        dlg.finished(false);
6943                        return Err(common::Error::MissingToken(e));
6944                    }
6945                },
6946            };
6947            request_value_reader
6948                .seek(std::io::SeekFrom::Start(0))
6949                .unwrap();
6950            let mut req_result = {
6951                let client = &self.hub.client;
6952                dlg.pre_request();
6953                let mut req_builder = hyper::Request::builder()
6954                    .method(hyper::Method::POST)
6955                    .uri(url.as_str())
6956                    .header(USER_AGENT, self.hub._user_agent.clone());
6957
6958                if let Some(token) = token.as_ref() {
6959                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6960                }
6961
6962                let request = req_builder
6963                    .header(CONTENT_TYPE, json_mime_type.to_string())
6964                    .header(CONTENT_LENGTH, request_size as u64)
6965                    .body(common::to_body(
6966                        request_value_reader.get_ref().clone().into(),
6967                    ));
6968
6969                client.request(request.unwrap()).await
6970            };
6971
6972            match req_result {
6973                Err(err) => {
6974                    if let common::Retry::After(d) = dlg.http_error(&err) {
6975                        sleep(d).await;
6976                        continue;
6977                    }
6978                    dlg.finished(false);
6979                    return Err(common::Error::HttpError(err));
6980                }
6981                Ok(res) => {
6982                    let (mut parts, body) = res.into_parts();
6983                    let mut body = common::Body::new(body);
6984                    if !parts.status.is_success() {
6985                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6986                        let error = serde_json::from_str(&common::to_string(&bytes));
6987                        let response = common::to_response(parts, bytes.into());
6988
6989                        if let common::Retry::After(d) =
6990                            dlg.http_failure(&response, error.as_ref().ok())
6991                        {
6992                            sleep(d).await;
6993                            continue;
6994                        }
6995
6996                        dlg.finished(false);
6997
6998                        return Err(match error {
6999                            Ok(value) => common::Error::BadRequest(value),
7000                            _ => common::Error::Failure(response),
7001                        });
7002                    }
7003                    let response = {
7004                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7005                        let encoded = common::to_string(&bytes);
7006                        match serde_json::from_str(&encoded) {
7007                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7008                            Err(error) => {
7009                                dlg.response_json_decode_error(&encoded, &error);
7010                                return Err(common::Error::JsonDecodeError(
7011                                    encoded.to_string(),
7012                                    error,
7013                                ));
7014                            }
7015                        }
7016                    };
7017
7018                    dlg.finished(true);
7019                    return Ok(response);
7020                }
7021            }
7022        }
7023    }
7024
7025    ///
7026    /// Sets the *request* property to the given value.
7027    ///
7028    /// Even though the property as already been set when instantiating this call,
7029    /// we provide this method for API completeness.
7030    pub fn request(
7031        mut self,
7032        new_value: TestIamPermissionsRequest,
7033    ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
7034        self._request = new_value;
7035        self
7036    }
7037    /// 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.
7038    ///
7039    /// Sets the *resource* path property to the given value.
7040    ///
7041    /// Even though the property as already been set when instantiating this call,
7042    /// we provide this method for API completeness.
7043    pub fn resource(mut self, new_value: &str) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
7044        self._resource = new_value.to_string();
7045        self
7046    }
7047    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7048    /// while executing the actual API request.
7049    ///
7050    /// ````text
7051    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7052    /// ````
7053    ///
7054    /// Sets the *delegate* property to the given value.
7055    pub fn delegate(
7056        mut self,
7057        new_value: &'a mut dyn common::Delegate,
7058    ) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
7059        self._delegate = Some(new_value);
7060        self
7061    }
7062
7063    /// Set any additional parameter of the query string used in the request.
7064    /// It should be used to set parameters which are not yet available through their own
7065    /// setters.
7066    ///
7067    /// Please note that this method must not be used to set any of the known parameters
7068    /// which have their own setter method. If done anyway, the request will fail.
7069    ///
7070    /// # Additional Parameters
7071    ///
7072    /// * *$.xgafv* (query-string) - V1 error format.
7073    /// * *access_token* (query-string) - OAuth access token.
7074    /// * *alt* (query-string) - Data format for response.
7075    /// * *callback* (query-string) - JSONP
7076    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7077    /// * *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.
7078    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7079    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7080    /// * *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.
7081    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7082    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7083    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
7084    where
7085        T: AsRef<str>,
7086    {
7087        self._additional_params
7088            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7089        self
7090    }
7091
7092    /// Identifies the authorization scope for the method you are building.
7093    ///
7094    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7095    /// [`Scope::CloudPlatform`].
7096    ///
7097    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7098    /// tokens for more than one scope.
7099    ///
7100    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7101    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7102    /// sufficient, a read-write scope will do as well.
7103    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
7104    where
7105        St: AsRef<str>,
7106    {
7107        self._scopes.insert(String::from(scope.as_ref()));
7108        self
7109    }
7110    /// Identifies the authorization scope(s) for the method you are building.
7111    ///
7112    /// See [`Self::add_scope()`] for details.
7113    pub fn add_scopes<I, St>(
7114        mut self,
7115        scopes: I,
7116    ) -> ProjectLocationQueueTestIamPermissionCall<'a, C>
7117    where
7118        I: IntoIterator<Item = St>,
7119        St: AsRef<str>,
7120    {
7121        self._scopes
7122            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7123        self
7124    }
7125
7126    /// Removes all scopes, and no default scope will be used either.
7127    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7128    /// for details).
7129    pub fn clear_scopes(mut self) -> ProjectLocationQueueTestIamPermissionCall<'a, C> {
7130        self._scopes.clear();
7131        self
7132    }
7133}
7134
7135/// Gets information about a location.
7136///
7137/// A builder for the *locations.get* method supported by a *project* resource.
7138/// It is not used directly, but through a [`ProjectMethods`] instance.
7139///
7140/// # Example
7141///
7142/// Instantiate a resource method builder
7143///
7144/// ```test_harness,no_run
7145/// # extern crate hyper;
7146/// # extern crate hyper_rustls;
7147/// # extern crate google_cloudtasks2 as cloudtasks2;
7148/// # async fn dox() {
7149/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7150///
7151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7152/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7153/// #     .with_native_roots()
7154/// #     .unwrap()
7155/// #     .https_only()
7156/// #     .enable_http2()
7157/// #     .build();
7158///
7159/// # let executor = hyper_util::rt::TokioExecutor::new();
7160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7161/// #     secret,
7162/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7163/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7164/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7165/// #     ),
7166/// # ).build().await.unwrap();
7167///
7168/// # let client = hyper_util::client::legacy::Client::builder(
7169/// #     hyper_util::rt::TokioExecutor::new()
7170/// # )
7171/// # .build(
7172/// #     hyper_rustls::HttpsConnectorBuilder::new()
7173/// #         .with_native_roots()
7174/// #         .unwrap()
7175/// #         .https_or_http()
7176/// #         .enable_http2()
7177/// #         .build()
7178/// # );
7179/// # let mut hub = CloudTasks::new(client, auth);
7180/// // You can configure optional parameters by calling the respective setters at will, and
7181/// // execute the final call using `doit()`.
7182/// // Values shown here are possibly random and not representative !
7183/// let result = hub.projects().locations_get("name")
7184///              .doit().await;
7185/// # }
7186/// ```
7187pub struct ProjectLocationGetCall<'a, C>
7188where
7189    C: 'a,
7190{
7191    hub: &'a CloudTasks<C>,
7192    _name: String,
7193    _delegate: Option<&'a mut dyn common::Delegate>,
7194    _additional_params: HashMap<String, String>,
7195    _scopes: BTreeSet<String>,
7196}
7197
7198impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
7199
7200impl<'a, C> ProjectLocationGetCall<'a, C>
7201where
7202    C: common::Connector,
7203{
7204    /// Perform the operation you have build so far.
7205    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
7206        use std::borrow::Cow;
7207        use std::io::{Read, Seek};
7208
7209        use common::{url::Params, ToParts};
7210        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7211
7212        let mut dd = common::DefaultDelegate;
7213        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7214        dlg.begin(common::MethodInfo {
7215            id: "cloudtasks.projects.locations.get",
7216            http_method: hyper::Method::GET,
7217        });
7218
7219        for &field in ["alt", "name"].iter() {
7220            if self._additional_params.contains_key(field) {
7221                dlg.finished(false);
7222                return Err(common::Error::FieldClash(field));
7223            }
7224        }
7225
7226        let mut params = Params::with_capacity(3 + self._additional_params.len());
7227        params.push("name", self._name);
7228
7229        params.extend(self._additional_params.iter());
7230
7231        params.push("alt", "json");
7232        let mut url = self.hub._base_url.clone() + "v2/{+name}";
7233        if self._scopes.is_empty() {
7234            self._scopes
7235                .insert(Scope::CloudPlatform.as_ref().to_string());
7236        }
7237
7238        #[allow(clippy::single_element_loop)]
7239        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7240            url = params.uri_replacement(url, param_name, find_this, true);
7241        }
7242        {
7243            let to_remove = ["name"];
7244            params.remove_params(&to_remove);
7245        }
7246
7247        let url = params.parse_with_url(&url);
7248
7249        loop {
7250            let token = match self
7251                .hub
7252                .auth
7253                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7254                .await
7255            {
7256                Ok(token) => token,
7257                Err(e) => match dlg.token(e) {
7258                    Ok(token) => token,
7259                    Err(e) => {
7260                        dlg.finished(false);
7261                        return Err(common::Error::MissingToken(e));
7262                    }
7263                },
7264            };
7265            let mut req_result = {
7266                let client = &self.hub.client;
7267                dlg.pre_request();
7268                let mut req_builder = hyper::Request::builder()
7269                    .method(hyper::Method::GET)
7270                    .uri(url.as_str())
7271                    .header(USER_AGENT, self.hub._user_agent.clone());
7272
7273                if let Some(token) = token.as_ref() {
7274                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7275                }
7276
7277                let request = req_builder
7278                    .header(CONTENT_LENGTH, 0_u64)
7279                    .body(common::to_body::<String>(None));
7280
7281                client.request(request.unwrap()).await
7282            };
7283
7284            match req_result {
7285                Err(err) => {
7286                    if let common::Retry::After(d) = dlg.http_error(&err) {
7287                        sleep(d).await;
7288                        continue;
7289                    }
7290                    dlg.finished(false);
7291                    return Err(common::Error::HttpError(err));
7292                }
7293                Ok(res) => {
7294                    let (mut parts, body) = res.into_parts();
7295                    let mut body = common::Body::new(body);
7296                    if !parts.status.is_success() {
7297                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7298                        let error = serde_json::from_str(&common::to_string(&bytes));
7299                        let response = common::to_response(parts, bytes.into());
7300
7301                        if let common::Retry::After(d) =
7302                            dlg.http_failure(&response, error.as_ref().ok())
7303                        {
7304                            sleep(d).await;
7305                            continue;
7306                        }
7307
7308                        dlg.finished(false);
7309
7310                        return Err(match error {
7311                            Ok(value) => common::Error::BadRequest(value),
7312                            _ => common::Error::Failure(response),
7313                        });
7314                    }
7315                    let response = {
7316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7317                        let encoded = common::to_string(&bytes);
7318                        match serde_json::from_str(&encoded) {
7319                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7320                            Err(error) => {
7321                                dlg.response_json_decode_error(&encoded, &error);
7322                                return Err(common::Error::JsonDecodeError(
7323                                    encoded.to_string(),
7324                                    error,
7325                                ));
7326                            }
7327                        }
7328                    };
7329
7330                    dlg.finished(true);
7331                    return Ok(response);
7332                }
7333            }
7334        }
7335    }
7336
7337    /// Resource name for the location.
7338    ///
7339    /// Sets the *name* path property to the given value.
7340    ///
7341    /// Even though the property as already been set when instantiating this call,
7342    /// we provide this method for API completeness.
7343    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
7344        self._name = new_value.to_string();
7345        self
7346    }
7347    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7348    /// while executing the actual API request.
7349    ///
7350    /// ````text
7351    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7352    /// ````
7353    ///
7354    /// Sets the *delegate* property to the given value.
7355    pub fn delegate(
7356        mut self,
7357        new_value: &'a mut dyn common::Delegate,
7358    ) -> ProjectLocationGetCall<'a, C> {
7359        self._delegate = Some(new_value);
7360        self
7361    }
7362
7363    /// Set any additional parameter of the query string used in the request.
7364    /// It should be used to set parameters which are not yet available through their own
7365    /// setters.
7366    ///
7367    /// Please note that this method must not be used to set any of the known parameters
7368    /// which have their own setter method. If done anyway, the request will fail.
7369    ///
7370    /// # Additional Parameters
7371    ///
7372    /// * *$.xgafv* (query-string) - V1 error format.
7373    /// * *access_token* (query-string) - OAuth access token.
7374    /// * *alt* (query-string) - Data format for response.
7375    /// * *callback* (query-string) - JSONP
7376    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7377    /// * *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.
7378    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7379    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7380    /// * *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.
7381    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7382    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7383    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
7384    where
7385        T: AsRef<str>,
7386    {
7387        self._additional_params
7388            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7389        self
7390    }
7391
7392    /// Identifies the authorization scope for the method you are building.
7393    ///
7394    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7395    /// [`Scope::CloudPlatform`].
7396    ///
7397    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7398    /// tokens for more than one scope.
7399    ///
7400    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7401    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7402    /// sufficient, a read-write scope will do as well.
7403    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
7404    where
7405        St: AsRef<str>,
7406    {
7407        self._scopes.insert(String::from(scope.as_ref()));
7408        self
7409    }
7410    /// Identifies the authorization scope(s) for the method you are building.
7411    ///
7412    /// See [`Self::add_scope()`] for details.
7413    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
7414    where
7415        I: IntoIterator<Item = St>,
7416        St: AsRef<str>,
7417    {
7418        self._scopes
7419            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7420        self
7421    }
7422
7423    /// Removes all scopes, and no default scope will be used either.
7424    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7425    /// for details).
7426    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
7427        self._scopes.clear();
7428        self
7429    }
7430}
7431
7432/// Gets the CMEK config. Gets the Customer Managed Encryption Key configured with the Cloud Tasks lcoation. By default there is no kms_key configured.
7433///
7434/// A builder for the *locations.getCmekConfig* method supported by a *project* resource.
7435/// It is not used directly, but through a [`ProjectMethods`] instance.
7436///
7437/// # Example
7438///
7439/// Instantiate a resource method builder
7440///
7441/// ```test_harness,no_run
7442/// # extern crate hyper;
7443/// # extern crate hyper_rustls;
7444/// # extern crate google_cloudtasks2 as cloudtasks2;
7445/// # async fn dox() {
7446/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7447///
7448/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7449/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7450/// #     .with_native_roots()
7451/// #     .unwrap()
7452/// #     .https_only()
7453/// #     .enable_http2()
7454/// #     .build();
7455///
7456/// # let executor = hyper_util::rt::TokioExecutor::new();
7457/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7458/// #     secret,
7459/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7460/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7461/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7462/// #     ),
7463/// # ).build().await.unwrap();
7464///
7465/// # let client = hyper_util::client::legacy::Client::builder(
7466/// #     hyper_util::rt::TokioExecutor::new()
7467/// # )
7468/// # .build(
7469/// #     hyper_rustls::HttpsConnectorBuilder::new()
7470/// #         .with_native_roots()
7471/// #         .unwrap()
7472/// #         .https_or_http()
7473/// #         .enable_http2()
7474/// #         .build()
7475/// # );
7476/// # let mut hub = CloudTasks::new(client, auth);
7477/// // You can configure optional parameters by calling the respective setters at will, and
7478/// // execute the final call using `doit()`.
7479/// // Values shown here are possibly random and not representative !
7480/// let result = hub.projects().locations_get_cmek_config("name")
7481///              .doit().await;
7482/// # }
7483/// ```
7484pub struct ProjectLocationGetCmekConfigCall<'a, C>
7485where
7486    C: 'a,
7487{
7488    hub: &'a CloudTasks<C>,
7489    _name: String,
7490    _delegate: Option<&'a mut dyn common::Delegate>,
7491    _additional_params: HashMap<String, String>,
7492    _scopes: BTreeSet<String>,
7493}
7494
7495impl<'a, C> common::CallBuilder for ProjectLocationGetCmekConfigCall<'a, C> {}
7496
7497impl<'a, C> ProjectLocationGetCmekConfigCall<'a, C>
7498where
7499    C: common::Connector,
7500{
7501    /// Perform the operation you have build so far.
7502    pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
7503        use std::borrow::Cow;
7504        use std::io::{Read, Seek};
7505
7506        use common::{url::Params, ToParts};
7507        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7508
7509        let mut dd = common::DefaultDelegate;
7510        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7511        dlg.begin(common::MethodInfo {
7512            id: "cloudtasks.projects.locations.getCmekConfig",
7513            http_method: hyper::Method::GET,
7514        });
7515
7516        for &field in ["alt", "name"].iter() {
7517            if self._additional_params.contains_key(field) {
7518                dlg.finished(false);
7519                return Err(common::Error::FieldClash(field));
7520            }
7521        }
7522
7523        let mut params = Params::with_capacity(3 + self._additional_params.len());
7524        params.push("name", self._name);
7525
7526        params.extend(self._additional_params.iter());
7527
7528        params.push("alt", "json");
7529        let mut url = self.hub._base_url.clone() + "v2/{+name}";
7530        if self._scopes.is_empty() {
7531            self._scopes
7532                .insert(Scope::CloudPlatform.as_ref().to_string());
7533        }
7534
7535        #[allow(clippy::single_element_loop)]
7536        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7537            url = params.uri_replacement(url, param_name, find_this, true);
7538        }
7539        {
7540            let to_remove = ["name"];
7541            params.remove_params(&to_remove);
7542        }
7543
7544        let url = params.parse_with_url(&url);
7545
7546        loop {
7547            let token = match self
7548                .hub
7549                .auth
7550                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7551                .await
7552            {
7553                Ok(token) => token,
7554                Err(e) => match dlg.token(e) {
7555                    Ok(token) => token,
7556                    Err(e) => {
7557                        dlg.finished(false);
7558                        return Err(common::Error::MissingToken(e));
7559                    }
7560                },
7561            };
7562            let mut req_result = {
7563                let client = &self.hub.client;
7564                dlg.pre_request();
7565                let mut req_builder = hyper::Request::builder()
7566                    .method(hyper::Method::GET)
7567                    .uri(url.as_str())
7568                    .header(USER_AGENT, self.hub._user_agent.clone());
7569
7570                if let Some(token) = token.as_ref() {
7571                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7572                }
7573
7574                let request = req_builder
7575                    .header(CONTENT_LENGTH, 0_u64)
7576                    .body(common::to_body::<String>(None));
7577
7578                client.request(request.unwrap()).await
7579            };
7580
7581            match req_result {
7582                Err(err) => {
7583                    if let common::Retry::After(d) = dlg.http_error(&err) {
7584                        sleep(d).await;
7585                        continue;
7586                    }
7587                    dlg.finished(false);
7588                    return Err(common::Error::HttpError(err));
7589                }
7590                Ok(res) => {
7591                    let (mut parts, body) = res.into_parts();
7592                    let mut body = common::Body::new(body);
7593                    if !parts.status.is_success() {
7594                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7595                        let error = serde_json::from_str(&common::to_string(&bytes));
7596                        let response = common::to_response(parts, bytes.into());
7597
7598                        if let common::Retry::After(d) =
7599                            dlg.http_failure(&response, error.as_ref().ok())
7600                        {
7601                            sleep(d).await;
7602                            continue;
7603                        }
7604
7605                        dlg.finished(false);
7606
7607                        return Err(match error {
7608                            Ok(value) => common::Error::BadRequest(value),
7609                            _ => common::Error::Failure(response),
7610                        });
7611                    }
7612                    let response = {
7613                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7614                        let encoded = common::to_string(&bytes);
7615                        match serde_json::from_str(&encoded) {
7616                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7617                            Err(error) => {
7618                                dlg.response_json_decode_error(&encoded, &error);
7619                                return Err(common::Error::JsonDecodeError(
7620                                    encoded.to_string(),
7621                                    error,
7622                                ));
7623                            }
7624                        }
7625                    };
7626
7627                    dlg.finished(true);
7628                    return Ok(response);
7629                }
7630            }
7631        }
7632    }
7633
7634    /// Required. The config. For example: projects/PROJECT_ID/locations/LOCATION_ID/CmekConfig`
7635    ///
7636    /// Sets the *name* path property to the given value.
7637    ///
7638    /// Even though the property as already been set when instantiating this call,
7639    /// we provide this method for API completeness.
7640    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCmekConfigCall<'a, C> {
7641        self._name = new_value.to_string();
7642        self
7643    }
7644    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7645    /// while executing the actual API request.
7646    ///
7647    /// ````text
7648    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7649    /// ````
7650    ///
7651    /// Sets the *delegate* property to the given value.
7652    pub fn delegate(
7653        mut self,
7654        new_value: &'a mut dyn common::Delegate,
7655    ) -> ProjectLocationGetCmekConfigCall<'a, C> {
7656        self._delegate = Some(new_value);
7657        self
7658    }
7659
7660    /// Set any additional parameter of the query string used in the request.
7661    /// It should be used to set parameters which are not yet available through their own
7662    /// setters.
7663    ///
7664    /// Please note that this method must not be used to set any of the known parameters
7665    /// which have their own setter method. If done anyway, the request will fail.
7666    ///
7667    /// # Additional Parameters
7668    ///
7669    /// * *$.xgafv* (query-string) - V1 error format.
7670    /// * *access_token* (query-string) - OAuth access token.
7671    /// * *alt* (query-string) - Data format for response.
7672    /// * *callback* (query-string) - JSONP
7673    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7674    /// * *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.
7675    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7676    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7677    /// * *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.
7678    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7679    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7680    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCmekConfigCall<'a, C>
7681    where
7682        T: AsRef<str>,
7683    {
7684        self._additional_params
7685            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7686        self
7687    }
7688
7689    /// Identifies the authorization scope for the method you are building.
7690    ///
7691    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7692    /// [`Scope::CloudPlatform`].
7693    ///
7694    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7695    /// tokens for more than one scope.
7696    ///
7697    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7698    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7699    /// sufficient, a read-write scope will do as well.
7700    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCmekConfigCall<'a, C>
7701    where
7702        St: AsRef<str>,
7703    {
7704        self._scopes.insert(String::from(scope.as_ref()));
7705        self
7706    }
7707    /// Identifies the authorization scope(s) for the method you are building.
7708    ///
7709    /// See [`Self::add_scope()`] for details.
7710    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCmekConfigCall<'a, C>
7711    where
7712        I: IntoIterator<Item = St>,
7713        St: AsRef<str>,
7714    {
7715        self._scopes
7716            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7717        self
7718    }
7719
7720    /// Removes all scopes, and no default scope will be used either.
7721    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7722    /// for details).
7723    pub fn clear_scopes(mut self) -> ProjectLocationGetCmekConfigCall<'a, C> {
7724        self._scopes.clear();
7725        self
7726    }
7727}
7728
7729/// Lists information about the supported locations for this service.
7730///
7731/// A builder for the *locations.list* method supported by a *project* resource.
7732/// It is not used directly, but through a [`ProjectMethods`] instance.
7733///
7734/// # Example
7735///
7736/// Instantiate a resource method builder
7737///
7738/// ```test_harness,no_run
7739/// # extern crate hyper;
7740/// # extern crate hyper_rustls;
7741/// # extern crate google_cloudtasks2 as cloudtasks2;
7742/// # async fn dox() {
7743/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7744///
7745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7746/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7747/// #     .with_native_roots()
7748/// #     .unwrap()
7749/// #     .https_only()
7750/// #     .enable_http2()
7751/// #     .build();
7752///
7753/// # let executor = hyper_util::rt::TokioExecutor::new();
7754/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7755/// #     secret,
7756/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7757/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7758/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7759/// #     ),
7760/// # ).build().await.unwrap();
7761///
7762/// # let client = hyper_util::client::legacy::Client::builder(
7763/// #     hyper_util::rt::TokioExecutor::new()
7764/// # )
7765/// # .build(
7766/// #     hyper_rustls::HttpsConnectorBuilder::new()
7767/// #         .with_native_roots()
7768/// #         .unwrap()
7769/// #         .https_or_http()
7770/// #         .enable_http2()
7771/// #         .build()
7772/// # );
7773/// # let mut hub = CloudTasks::new(client, auth);
7774/// // You can configure optional parameters by calling the respective setters at will, and
7775/// // execute the final call using `doit()`.
7776/// // Values shown here are possibly random and not representative !
7777/// let result = hub.projects().locations_list("name")
7778///              .page_token("est")
7779///              .page_size(-62)
7780///              .filter("ea")
7781///              .add_extra_location_types("dolor")
7782///              .doit().await;
7783/// # }
7784/// ```
7785pub struct ProjectLocationListCall<'a, C>
7786where
7787    C: 'a,
7788{
7789    hub: &'a CloudTasks<C>,
7790    _name: String,
7791    _page_token: Option<String>,
7792    _page_size: Option<i32>,
7793    _filter: Option<String>,
7794    _extra_location_types: Vec<String>,
7795    _delegate: Option<&'a mut dyn common::Delegate>,
7796    _additional_params: HashMap<String, String>,
7797    _scopes: BTreeSet<String>,
7798}
7799
7800impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
7801
7802impl<'a, C> ProjectLocationListCall<'a, C>
7803where
7804    C: common::Connector,
7805{
7806    /// Perform the operation you have build so far.
7807    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
7808        use std::borrow::Cow;
7809        use std::io::{Read, Seek};
7810
7811        use common::{url::Params, ToParts};
7812        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7813
7814        let mut dd = common::DefaultDelegate;
7815        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7816        dlg.begin(common::MethodInfo {
7817            id: "cloudtasks.projects.locations.list",
7818            http_method: hyper::Method::GET,
7819        });
7820
7821        for &field in [
7822            "alt",
7823            "name",
7824            "pageToken",
7825            "pageSize",
7826            "filter",
7827            "extraLocationTypes",
7828        ]
7829        .iter()
7830        {
7831            if self._additional_params.contains_key(field) {
7832                dlg.finished(false);
7833                return Err(common::Error::FieldClash(field));
7834            }
7835        }
7836
7837        let mut params = Params::with_capacity(7 + self._additional_params.len());
7838        params.push("name", self._name);
7839        if let Some(value) = self._page_token.as_ref() {
7840            params.push("pageToken", value);
7841        }
7842        if let Some(value) = self._page_size.as_ref() {
7843            params.push("pageSize", value.to_string());
7844        }
7845        if let Some(value) = self._filter.as_ref() {
7846            params.push("filter", value);
7847        }
7848        if !self._extra_location_types.is_empty() {
7849            for f in self._extra_location_types.iter() {
7850                params.push("extraLocationTypes", f);
7851            }
7852        }
7853
7854        params.extend(self._additional_params.iter());
7855
7856        params.push("alt", "json");
7857        let mut url = self.hub._base_url.clone() + "v2/{+name}/locations";
7858        if self._scopes.is_empty() {
7859            self._scopes
7860                .insert(Scope::CloudPlatform.as_ref().to_string());
7861        }
7862
7863        #[allow(clippy::single_element_loop)]
7864        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7865            url = params.uri_replacement(url, param_name, find_this, true);
7866        }
7867        {
7868            let to_remove = ["name"];
7869            params.remove_params(&to_remove);
7870        }
7871
7872        let url = params.parse_with_url(&url);
7873
7874        loop {
7875            let token = match self
7876                .hub
7877                .auth
7878                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7879                .await
7880            {
7881                Ok(token) => token,
7882                Err(e) => match dlg.token(e) {
7883                    Ok(token) => token,
7884                    Err(e) => {
7885                        dlg.finished(false);
7886                        return Err(common::Error::MissingToken(e));
7887                    }
7888                },
7889            };
7890            let mut req_result = {
7891                let client = &self.hub.client;
7892                dlg.pre_request();
7893                let mut req_builder = hyper::Request::builder()
7894                    .method(hyper::Method::GET)
7895                    .uri(url.as_str())
7896                    .header(USER_AGENT, self.hub._user_agent.clone());
7897
7898                if let Some(token) = token.as_ref() {
7899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7900                }
7901
7902                let request = req_builder
7903                    .header(CONTENT_LENGTH, 0_u64)
7904                    .body(common::to_body::<String>(None));
7905
7906                client.request(request.unwrap()).await
7907            };
7908
7909            match req_result {
7910                Err(err) => {
7911                    if let common::Retry::After(d) = dlg.http_error(&err) {
7912                        sleep(d).await;
7913                        continue;
7914                    }
7915                    dlg.finished(false);
7916                    return Err(common::Error::HttpError(err));
7917                }
7918                Ok(res) => {
7919                    let (mut parts, body) = res.into_parts();
7920                    let mut body = common::Body::new(body);
7921                    if !parts.status.is_success() {
7922                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7923                        let error = serde_json::from_str(&common::to_string(&bytes));
7924                        let response = common::to_response(parts, bytes.into());
7925
7926                        if let common::Retry::After(d) =
7927                            dlg.http_failure(&response, error.as_ref().ok())
7928                        {
7929                            sleep(d).await;
7930                            continue;
7931                        }
7932
7933                        dlg.finished(false);
7934
7935                        return Err(match error {
7936                            Ok(value) => common::Error::BadRequest(value),
7937                            _ => common::Error::Failure(response),
7938                        });
7939                    }
7940                    let response = {
7941                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7942                        let encoded = common::to_string(&bytes);
7943                        match serde_json::from_str(&encoded) {
7944                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7945                            Err(error) => {
7946                                dlg.response_json_decode_error(&encoded, &error);
7947                                return Err(common::Error::JsonDecodeError(
7948                                    encoded.to_string(),
7949                                    error,
7950                                ));
7951                            }
7952                        }
7953                    };
7954
7955                    dlg.finished(true);
7956                    return Ok(response);
7957                }
7958            }
7959        }
7960    }
7961
7962    /// The resource that owns the locations collection, if applicable.
7963    ///
7964    /// Sets the *name* path property to the given value.
7965    ///
7966    /// Even though the property as already been set when instantiating this call,
7967    /// we provide this method for API completeness.
7968    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7969        self._name = new_value.to_string();
7970        self
7971    }
7972    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
7973    ///
7974    /// Sets the *page token* query property to the given value.
7975    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7976        self._page_token = Some(new_value.to_string());
7977        self
7978    }
7979    /// The maximum number of results to return. If not set, the service selects a default.
7980    ///
7981    /// Sets the *page size* query property to the given value.
7982    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
7983        self._page_size = Some(new_value);
7984        self
7985    }
7986    /// 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).
7987    ///
7988    /// Sets the *filter* query property to the given value.
7989    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7990        self._filter = Some(new_value.to_string());
7991        self
7992    }
7993    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
7994    ///
7995    /// Append the given value to the *extra location types* query property.
7996    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7997    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7998        self._extra_location_types.push(new_value.to_string());
7999        self
8000    }
8001    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8002    /// while executing the actual API request.
8003    ///
8004    /// ````text
8005    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8006    /// ````
8007    ///
8008    /// Sets the *delegate* property to the given value.
8009    pub fn delegate(
8010        mut self,
8011        new_value: &'a mut dyn common::Delegate,
8012    ) -> ProjectLocationListCall<'a, C> {
8013        self._delegate = Some(new_value);
8014        self
8015    }
8016
8017    /// Set any additional parameter of the query string used in the request.
8018    /// It should be used to set parameters which are not yet available through their own
8019    /// setters.
8020    ///
8021    /// Please note that this method must not be used to set any of the known parameters
8022    /// which have their own setter method. If done anyway, the request will fail.
8023    ///
8024    /// # Additional Parameters
8025    ///
8026    /// * *$.xgafv* (query-string) - V1 error format.
8027    /// * *access_token* (query-string) - OAuth access token.
8028    /// * *alt* (query-string) - Data format for response.
8029    /// * *callback* (query-string) - JSONP
8030    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8031    /// * *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.
8032    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8033    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8034    /// * *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.
8035    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8036    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8037    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
8038    where
8039        T: AsRef<str>,
8040    {
8041        self._additional_params
8042            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8043        self
8044    }
8045
8046    /// Identifies the authorization scope for the method you are building.
8047    ///
8048    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8049    /// [`Scope::CloudPlatform`].
8050    ///
8051    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8052    /// tokens for more than one scope.
8053    ///
8054    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8055    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8056    /// sufficient, a read-write scope will do as well.
8057    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
8058    where
8059        St: AsRef<str>,
8060    {
8061        self._scopes.insert(String::from(scope.as_ref()));
8062        self
8063    }
8064    /// Identifies the authorization scope(s) for the method you are building.
8065    ///
8066    /// See [`Self::add_scope()`] for details.
8067    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
8068    where
8069        I: IntoIterator<Item = St>,
8070        St: AsRef<str>,
8071    {
8072        self._scopes
8073            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8074        self
8075    }
8076
8077    /// Removes all scopes, and no default scope will be used either.
8078    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8079    /// for details).
8080    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
8081        self._scopes.clear();
8082        self
8083    }
8084}
8085
8086/// 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.
8087///
8088/// A builder for the *locations.updateCmekConfig* method supported by a *project* resource.
8089/// It is not used directly, but through a [`ProjectMethods`] instance.
8090///
8091/// # Example
8092///
8093/// Instantiate a resource method builder
8094///
8095/// ```test_harness,no_run
8096/// # extern crate hyper;
8097/// # extern crate hyper_rustls;
8098/// # extern crate google_cloudtasks2 as cloudtasks2;
8099/// use cloudtasks2::api::CmekConfig;
8100/// # async fn dox() {
8101/// # use cloudtasks2::{CloudTasks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8102///
8103/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8104/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8105/// #     .with_native_roots()
8106/// #     .unwrap()
8107/// #     .https_only()
8108/// #     .enable_http2()
8109/// #     .build();
8110///
8111/// # let executor = hyper_util::rt::TokioExecutor::new();
8112/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8113/// #     secret,
8114/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8115/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8116/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8117/// #     ),
8118/// # ).build().await.unwrap();
8119///
8120/// # let client = hyper_util::client::legacy::Client::builder(
8121/// #     hyper_util::rt::TokioExecutor::new()
8122/// # )
8123/// # .build(
8124/// #     hyper_rustls::HttpsConnectorBuilder::new()
8125/// #         .with_native_roots()
8126/// #         .unwrap()
8127/// #         .https_or_http()
8128/// #         .enable_http2()
8129/// #         .build()
8130/// # );
8131/// # let mut hub = CloudTasks::new(client, auth);
8132/// // As the method needs a request, you would usually fill it with the desired information
8133/// // into the respective structure. Some of the parts shown here might not be applicable !
8134/// // Values shown here are possibly random and not representative !
8135/// let mut req = CmekConfig::default();
8136///
8137/// // You can configure optional parameters by calling the respective setters at will, and
8138/// // execute the final call using `doit()`.
8139/// // Values shown here are possibly random and not representative !
8140/// let result = hub.projects().locations_update_cmek_config(req, "name")
8141///              .update_mask(FieldMask::new::<&str>(&[]))
8142///              .doit().await;
8143/// # }
8144/// ```
8145pub struct ProjectLocationUpdateCmekConfigCall<'a, C>
8146where
8147    C: 'a,
8148{
8149    hub: &'a CloudTasks<C>,
8150    _request: CmekConfig,
8151    _name: String,
8152    _update_mask: Option<common::FieldMask>,
8153    _delegate: Option<&'a mut dyn common::Delegate>,
8154    _additional_params: HashMap<String, String>,
8155    _scopes: BTreeSet<String>,
8156}
8157
8158impl<'a, C> common::CallBuilder for ProjectLocationUpdateCmekConfigCall<'a, C> {}
8159
8160impl<'a, C> ProjectLocationUpdateCmekConfigCall<'a, C>
8161where
8162    C: common::Connector,
8163{
8164    /// Perform the operation you have build so far.
8165    pub async fn doit(mut self) -> common::Result<(common::Response, CmekConfig)> {
8166        use std::borrow::Cow;
8167        use std::io::{Read, Seek};
8168
8169        use common::{url::Params, ToParts};
8170        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8171
8172        let mut dd = common::DefaultDelegate;
8173        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8174        dlg.begin(common::MethodInfo {
8175            id: "cloudtasks.projects.locations.updateCmekConfig",
8176            http_method: hyper::Method::PATCH,
8177        });
8178
8179        for &field in ["alt", "name", "updateMask"].iter() {
8180            if self._additional_params.contains_key(field) {
8181                dlg.finished(false);
8182                return Err(common::Error::FieldClash(field));
8183            }
8184        }
8185
8186        let mut params = Params::with_capacity(5 + self._additional_params.len());
8187        params.push("name", self._name);
8188        if let Some(value) = self._update_mask.as_ref() {
8189            params.push("updateMask", value.to_string());
8190        }
8191
8192        params.extend(self._additional_params.iter());
8193
8194        params.push("alt", "json");
8195        let mut url = self.hub._base_url.clone() + "v2/{+name}";
8196        if self._scopes.is_empty() {
8197            self._scopes
8198                .insert(Scope::CloudPlatform.as_ref().to_string());
8199        }
8200
8201        #[allow(clippy::single_element_loop)]
8202        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8203            url = params.uri_replacement(url, param_name, find_this, true);
8204        }
8205        {
8206            let to_remove = ["name"];
8207            params.remove_params(&to_remove);
8208        }
8209
8210        let url = params.parse_with_url(&url);
8211
8212        let mut json_mime_type = mime::APPLICATION_JSON;
8213        let mut request_value_reader = {
8214            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8215            common::remove_json_null_values(&mut value);
8216            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8217            serde_json::to_writer(&mut dst, &value).unwrap();
8218            dst
8219        };
8220        let request_size = request_value_reader
8221            .seek(std::io::SeekFrom::End(0))
8222            .unwrap();
8223        request_value_reader
8224            .seek(std::io::SeekFrom::Start(0))
8225            .unwrap();
8226
8227        loop {
8228            let token = match self
8229                .hub
8230                .auth
8231                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8232                .await
8233            {
8234                Ok(token) => token,
8235                Err(e) => match dlg.token(e) {
8236                    Ok(token) => token,
8237                    Err(e) => {
8238                        dlg.finished(false);
8239                        return Err(common::Error::MissingToken(e));
8240                    }
8241                },
8242            };
8243            request_value_reader
8244                .seek(std::io::SeekFrom::Start(0))
8245                .unwrap();
8246            let mut req_result = {
8247                let client = &self.hub.client;
8248                dlg.pre_request();
8249                let mut req_builder = hyper::Request::builder()
8250                    .method(hyper::Method::PATCH)
8251                    .uri(url.as_str())
8252                    .header(USER_AGENT, self.hub._user_agent.clone());
8253
8254                if let Some(token) = token.as_ref() {
8255                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8256                }
8257
8258                let request = req_builder
8259                    .header(CONTENT_TYPE, json_mime_type.to_string())
8260                    .header(CONTENT_LENGTH, request_size as u64)
8261                    .body(common::to_body(
8262                        request_value_reader.get_ref().clone().into(),
8263                    ));
8264
8265                client.request(request.unwrap()).await
8266            };
8267
8268            match req_result {
8269                Err(err) => {
8270                    if let common::Retry::After(d) = dlg.http_error(&err) {
8271                        sleep(d).await;
8272                        continue;
8273                    }
8274                    dlg.finished(false);
8275                    return Err(common::Error::HttpError(err));
8276                }
8277                Ok(res) => {
8278                    let (mut parts, body) = res.into_parts();
8279                    let mut body = common::Body::new(body);
8280                    if !parts.status.is_success() {
8281                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8282                        let error = serde_json::from_str(&common::to_string(&bytes));
8283                        let response = common::to_response(parts, bytes.into());
8284
8285                        if let common::Retry::After(d) =
8286                            dlg.http_failure(&response, error.as_ref().ok())
8287                        {
8288                            sleep(d).await;
8289                            continue;
8290                        }
8291
8292                        dlg.finished(false);
8293
8294                        return Err(match error {
8295                            Ok(value) => common::Error::BadRequest(value),
8296                            _ => common::Error::Failure(response),
8297                        });
8298                    }
8299                    let response = {
8300                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8301                        let encoded = common::to_string(&bytes);
8302                        match serde_json::from_str(&encoded) {
8303                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8304                            Err(error) => {
8305                                dlg.response_json_decode_error(&encoded, &error);
8306                                return Err(common::Error::JsonDecodeError(
8307                                    encoded.to_string(),
8308                                    error,
8309                                ));
8310                            }
8311                        }
8312                    };
8313
8314                    dlg.finished(true);
8315                    return Ok(response);
8316                }
8317            }
8318        }
8319    }
8320
8321    ///
8322    /// Sets the *request* property to the given value.
8323    ///
8324    /// Even though the property as already been set when instantiating this call,
8325    /// we provide this method for API completeness.
8326    pub fn request(mut self, new_value: CmekConfig) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
8327        self._request = new_value;
8328        self
8329    }
8330    /// 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`
8331    ///
8332    /// Sets the *name* path property to the given value.
8333    ///
8334    /// Even though the property as already been set when instantiating this call,
8335    /// we provide this method for API completeness.
8336    pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
8337        self._name = new_value.to_string();
8338        self
8339    }
8340    /// List of fields to be updated in this request.
8341    ///
8342    /// Sets the *update mask* query property to the given value.
8343    pub fn update_mask(
8344        mut self,
8345        new_value: common::FieldMask,
8346    ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
8347        self._update_mask = Some(new_value);
8348        self
8349    }
8350    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8351    /// while executing the actual API request.
8352    ///
8353    /// ````text
8354    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8355    /// ````
8356    ///
8357    /// Sets the *delegate* property to the given value.
8358    pub fn delegate(
8359        mut self,
8360        new_value: &'a mut dyn common::Delegate,
8361    ) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
8362        self._delegate = Some(new_value);
8363        self
8364    }
8365
8366    /// Set any additional parameter of the query string used in the request.
8367    /// It should be used to set parameters which are not yet available through their own
8368    /// setters.
8369    ///
8370    /// Please note that this method must not be used to set any of the known parameters
8371    /// which have their own setter method. If done anyway, the request will fail.
8372    ///
8373    /// # Additional Parameters
8374    ///
8375    /// * *$.xgafv* (query-string) - V1 error format.
8376    /// * *access_token* (query-string) - OAuth access token.
8377    /// * *alt* (query-string) - Data format for response.
8378    /// * *callback* (query-string) - JSONP
8379    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8380    /// * *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.
8381    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8382    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8383    /// * *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.
8384    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8385    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8386    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateCmekConfigCall<'a, C>
8387    where
8388        T: AsRef<str>,
8389    {
8390        self._additional_params
8391            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8392        self
8393    }
8394
8395    /// Identifies the authorization scope for the method you are building.
8396    ///
8397    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8398    /// [`Scope::CloudPlatform`].
8399    ///
8400    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8401    /// tokens for more than one scope.
8402    ///
8403    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8404    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8405    /// sufficient, a read-write scope will do as well.
8406    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateCmekConfigCall<'a, C>
8407    where
8408        St: AsRef<str>,
8409    {
8410        self._scopes.insert(String::from(scope.as_ref()));
8411        self
8412    }
8413    /// Identifies the authorization scope(s) for the method you are building.
8414    ///
8415    /// See [`Self::add_scope()`] for details.
8416    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateCmekConfigCall<'a, C>
8417    where
8418        I: IntoIterator<Item = St>,
8419        St: AsRef<str>,
8420    {
8421        self._scopes
8422            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8423        self
8424    }
8425
8426    /// Removes all scopes, and no default scope will be used either.
8427    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8428    /// for details).
8429    pub fn clear_scopes(mut self) -> ProjectLocationUpdateCmekConfigCall<'a, C> {
8430        self._scopes.clear();
8431        self
8432    }
8433}