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