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