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