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