google_manager1_beta2/
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    /// View and manage your applications deployed on Google App Engine
17    AppengineAdmin,
18
19    /// View and manage your data across Google Cloud Platform services
20    CloudPlatform,
21
22    /// View your data across Google Cloud Platform services
23    CloudPlatformReadOnly,
24
25    /// View and manage your Google Compute Engine resources
26    Compute,
27
28    /// Manage your data in Google Cloud Storage
29    DevstorageReadWrite,
30
31    /// View and manage your Google Cloud Platform management resources and deployment status information
32    NdevCloudman,
33
34    /// View your Google Cloud Platform management resources and deployment status information
35    NdevCloudmanReadonly,
36}
37
38impl AsRef<str> for Scope {
39    fn as_ref(&self) -> &str {
40        match *self {
41            Scope::AppengineAdmin => "https://www.googleapis.com/auth/appengine.admin",
42            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
43            Scope::CloudPlatformReadOnly => {
44                "https://www.googleapis.com/auth/cloud-platform.read-only"
45            }
46            Scope::Compute => "https://www.googleapis.com/auth/compute",
47            Scope::DevstorageReadWrite => "https://www.googleapis.com/auth/devstorage.read_write",
48            Scope::NdevCloudman => "https://www.googleapis.com/auth/ndev.cloudman",
49            Scope::NdevCloudmanReadonly => "https://www.googleapis.com/auth/ndev.cloudman.readonly",
50        }
51    }
52}
53
54#[allow(clippy::derivable_impls)]
55impl Default for Scope {
56    fn default() -> Scope {
57        Scope::NdevCloudmanReadonly
58    }
59}
60
61// ########
62// HUB ###
63// ######
64
65/// Central instance to access all Manager related resource activities
66///
67/// # Examples
68///
69/// Instantiate a new hub
70///
71/// ```test_harness,no_run
72/// extern crate hyper;
73/// extern crate hyper_rustls;
74/// extern crate google_manager1_beta2 as manager1_beta2;
75/// use manager1_beta2::{Result, Error};
76/// # async fn dox() {
77/// use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
78///
79/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
80/// // `client_secret`, among other things.
81/// let secret: yup_oauth2::ApplicationSecret = Default::default();
82/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
83/// // unless you replace  `None` with the desired Flow.
84/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
85/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
86/// // retrieve them from storage.
87/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
88///     secret,
89///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
90/// ).build().await.unwrap();
91///
92/// let client = hyper_util::client::legacy::Client::builder(
93///     hyper_util::rt::TokioExecutor::new()
94/// )
95/// .build(
96///     hyper_rustls::HttpsConnectorBuilder::new()
97///         .with_native_roots()
98///         .unwrap()
99///         .https_or_http()
100///         .enable_http1()
101///         .build()
102/// );
103/// let mut hub = Manager::new(client, auth);
104/// // You can configure optional parameters by calling the respective setters at will, and
105/// // execute the final call using `doit()`.
106/// // Values shown here are possibly random and not representative !
107/// let result = hub.deployments().list("projectId", "region")
108///              .page_token("amet.")
109///              .max_results(-20)
110///              .doit().await;
111///
112/// match result {
113///     Err(e) => match e {
114///         // The Error enum provides details about what exactly happened.
115///         // You can also just use its `Debug`, `Display` or `Error` traits
116///          Error::HttpError(_)
117///         |Error::Io(_)
118///         |Error::MissingAPIKey
119///         |Error::MissingToken(_)
120///         |Error::Cancelled
121///         |Error::UploadSizeLimitExceeded(_, _)
122///         |Error::Failure(_)
123///         |Error::BadRequest(_)
124///         |Error::FieldClash(_)
125///         |Error::JsonDecodeError(_, _) => println!("{}", e),
126///     },
127///     Ok(res) => println!("Success: {:?}", res),
128/// }
129/// # }
130/// ```
131#[derive(Clone)]
132pub struct Manager<C> {
133    pub client: common::Client<C>,
134    pub auth: Box<dyn common::GetToken>,
135    _user_agent: String,
136    _base_url: String,
137    _root_url: String,
138}
139
140impl<C> common::Hub for Manager<C> {}
141
142impl<'a, C> Manager<C> {
143    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Manager<C> {
144        Manager {
145            client,
146            auth: Box::new(auth),
147            _user_agent: "google-api-rust-client/6.0.0".to_string(),
148            _base_url: "https://www.googleapis.com/manager/v1beta2/projects/".to_string(),
149            _root_url: "https://www.googleapis.com/".to_string(),
150        }
151    }
152
153    pub fn deployments(&'a self) -> DeploymentMethods<'a, C> {
154        DeploymentMethods { hub: self }
155    }
156    pub fn templates(&'a self) -> TemplateMethods<'a, C> {
157        TemplateMethods { hub: self }
158    }
159
160    /// Set the user-agent header field to use in all requests to the server.
161    /// It defaults to `google-api-rust-client/6.0.0`.
162    ///
163    /// Returns the previously set user-agent.
164    pub fn user_agent(&mut self, agent_name: String) -> String {
165        std::mem::replace(&mut self._user_agent, agent_name)
166    }
167
168    /// Set the base url to use in all requests to the server.
169    /// It defaults to `https://www.googleapis.com/manager/v1beta2/projects/`.
170    ///
171    /// Returns the previously set base url.
172    pub fn base_url(&mut self, new_base_url: String) -> String {
173        std::mem::replace(&mut self._base_url, new_base_url)
174    }
175
176    /// Set the root url to use in all requests to the server.
177    /// It defaults to `https://www.googleapis.com/`.
178    ///
179    /// Returns the previously set root url.
180    pub fn root_url(&mut self, new_root_url: String) -> String {
181        std::mem::replace(&mut self._root_url, new_root_url)
182    }
183}
184
185// ############
186// SCHEMAS ###
187// ##########
188/// A Compute Engine network accessConfig. Identical to the accessConfig on corresponding Compute Engine resource.
189///
190/// This type is not used in any activity, and only used as *part* of another schema.
191///
192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
193#[serde_with::serde_as]
194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
195pub struct AccessConfig {
196    /// Name of this access configuration.
197    pub name: Option<String>,
198    /// An external IP address associated with this instance.
199    #[serde(rename = "natIp")]
200    pub nat_ip: Option<String>,
201    /// Type of this access configuration file. (Currently only ONE_TO_ONE_NAT is legal.)
202    #[serde(rename = "type")]
203    pub type_: Option<String>,
204}
205
206impl common::Part for AccessConfig {}
207
208/// An Action encapsulates a set of commands as a single runnable module with additional information needed during run-time.
209///
210/// This type is not used in any activity, and only used as *part* of another schema.
211///
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct Action {
216    /// A list of commands to run sequentially for this action.
217    pub commands: Option<Vec<String>>,
218    /// The timeout in milliseconds for this action to run.
219    #[serde(rename = "timeoutMs")]
220    pub timeout_ms: Option<i32>,
221}
222
223impl common::Part for Action {}
224
225/// An allowed port resource.
226///
227/// This type is not used in any activity, and only used as *part* of another schema.
228///
229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
230#[serde_with::serde_as]
231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
232pub struct AllowedRule {
233    /// ?tcp?, ?udp? or ?icmp?
234    #[serde(rename = "IPProtocol")]
235    pub ip_protocol: Option<String>,
236    /// List of ports or port ranges (Example inputs include: ["22"], [?33?, "12345-12349"].
237    pub ports: Option<Vec<String>>,
238}
239
240impl common::Part for AllowedRule {}
241
242/// There is no detailed description.
243///
244/// This type is not used in any activity, and only used as *part* of another schema.
245///
246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
247#[serde_with::serde_as]
248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
249pub struct AutoscalingModule {
250    /// no description provided
251    #[serde(rename = "coolDownPeriodSec")]
252    pub cool_down_period_sec: Option<i32>,
253    /// no description provided
254    pub description: Option<String>,
255    /// no description provided
256    #[serde(rename = "maxNumReplicas")]
257    pub max_num_replicas: Option<i32>,
258    /// no description provided
259    #[serde(rename = "minNumReplicas")]
260    pub min_num_replicas: Option<i32>,
261    /// no description provided
262    #[serde(rename = "signalType")]
263    pub signal_type: Option<String>,
264    /// no description provided
265    #[serde(rename = "targetModule")]
266    pub target_module: Option<String>,
267    /// target_utilization should be in range [0,1].
268    #[serde(rename = "targetUtilization")]
269    pub target_utilization: Option<f64>,
270}
271
272impl common::Part for AutoscalingModule {}
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 AutoscalingModuleStatus {
282    /// [Output Only] The URL of the corresponding Autoscaling configuration.
283    #[serde(rename = "autoscalingConfigUrl")]
284    pub autoscaling_config_url: Option<String>,
285}
286
287impl common::Part for AutoscalingModuleStatus {}
288
289/// [Output Only] The current state of a replica or module.
290///
291/// This type is not used in any activity, and only used as *part* of another schema.
292///
293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
294#[serde_with::serde_as]
295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
296pub struct DeployState {
297    /// [Output Only] Human readable details about the current state.
298    pub details: Option<String>,
299    /// [Output Only] The status of the deployment. Possible values include:
300    /// - UNKNOWN
301    /// - DEPLOYING
302    /// - DEPLOYED
303    /// - DEPLOYMENT_FAILED
304    /// - DELETING
305    /// - DELETED
306    /// - DELETE_FAILED
307    pub status: Option<String>,
308}
309
310impl common::Part for DeployState {}
311
312/// A deployment represents a physical instantiation of a Template.
313///
314/// # Activities
315///
316/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
317/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
318///
319/// * [delete deployments](DeploymentDeleteCall) (none)
320/// * [get deployments](DeploymentGetCall) (response)
321/// * [insert deployments](DeploymentInsertCall) (request|response)
322/// * [list deployments](DeploymentListCall) (none)
323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
324#[serde_with::serde_as]
325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
326pub struct Deployment {
327    /// [Output Only] The time when this deployment was created.
328    #[serde(rename = "creationDate")]
329    pub creation_date: Option<String>,
330    /// A user-supplied description of this Deployment.
331    pub description: Option<String>,
332    /// [Output Only] List of status for the modules in this deployment.
333    pub modules: Option<HashMap<String, ModuleStatus>>,
334    /// Name of this deployment. The name must conform to the following regular expression: [a-zA-Z0-9-_]{1,64}
335    pub name: Option<String>,
336    /// The set of parameter overrides to apply to the corresponding Template before deploying.
337    pub overrides: Option<Vec<ParamOverride>>,
338    /// [Output Only] Current status of this deployment.
339    pub state: Option<DeployState>,
340    /// The name of the Template on which this deployment is based.
341    #[serde(rename = "templateName")]
342    pub template_name: Option<String>,
343}
344
345impl common::RequestValue for Deployment {}
346impl common::Resource for Deployment {}
347impl common::ResponseResult for Deployment {}
348
349/// There is no detailed description.
350///
351/// # Activities
352///
353/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
354/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
355///
356/// * [list deployments](DeploymentListCall) (response)
357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
358#[serde_with::serde_as]
359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
360pub struct DeploymentsListResponse {
361    /// no description provided
362    #[serde(rename = "nextPageToken")]
363    pub next_page_token: Option<String>,
364    /// no description provided
365    pub resources: Option<Vec<Deployment>>,
366}
367
368impl common::ResponseResult for DeploymentsListResponse {}
369
370/// How to attach a disk to a Replica.
371///
372/// This type is not used in any activity, and only used as *part* of another schema.
373///
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct DiskAttachment {
378    /// The device name of this disk.
379    #[serde(rename = "deviceName")]
380    pub device_name: Option<String>,
381    /// A zero-based index to assign to this disk, where 0 is reserved for the boot disk. If not specified, this is assigned by the server.
382    pub index: Option<u32>,
383}
384
385impl common::Part for DiskAttachment {}
386
387/// An environment variable.
388///
389/// This type is not used in any activity, and only used as *part* of another schema.
390///
391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
392#[serde_with::serde_as]
393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
394pub struct EnvVariable {
395    /// Whether this variable is hidden or visible.
396    pub hidden: Option<bool>,
397    /// Value of the environment variable.
398    pub value: Option<String>,
399}
400
401impl common::Part for EnvVariable {}
402
403/// A pre-existing persistent disk that will be attached to every Replica in the Pool.
404///
405/// This type is not used in any activity, and only used as *part* of another schema.
406///
407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
408#[serde_with::serde_as]
409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
410pub struct ExistingDisk {
411    /// Optional. How the disk will be attached to the Replica.
412    pub attachment: Option<DiskAttachment>,
413    /// The fully-qualified URL of the Persistent Disk resource. It must be in the same zone as the Pool.
414    pub source: Option<String>,
415}
416
417impl common::Part for ExistingDisk {}
418
419/// A Firewall resource
420///
421/// This type is not used in any activity, and only used as *part* of another schema.
422///
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct FirewallModule {
427    /// The allowed ports or port ranges.
428    pub allowed: Option<Vec<AllowedRule>>,
429    /// The description of the firewall (optional)
430    pub description: Option<String>,
431    /// The NetworkModule to which this firewall should apply. If not specified, or if specified as 'default', this firewall will be applied to the 'default' network.
432    pub network: Option<String>,
433    /// Source IP ranges to apply this firewall to, see the GCE Spec for details on syntax
434    #[serde(rename = "sourceRanges")]
435    pub source_ranges: Option<Vec<String>>,
436    /// Source Tags to apply this firewall to, see the GCE Spec for details on syntax
437    #[serde(rename = "sourceTags")]
438    pub source_tags: Option<Vec<String>>,
439    /// Target Tags to apply this firewall to, see the GCE Spec for details on syntax
440    #[serde(rename = "targetTags")]
441    pub target_tags: Option<Vec<String>>,
442}
443
444impl common::Part for FirewallModule {}
445
446/// There is no detailed description.
447///
448/// This type is not used in any activity, and only used as *part* of another schema.
449///
450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
451#[serde_with::serde_as]
452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
453pub struct FirewallModuleStatus {
454    /// [Output Only] The URL of the corresponding Firewall resource.
455    #[serde(rename = "firewallUrl")]
456    pub firewall_url: Option<String>,
457}
458
459impl common::Part for FirewallModuleStatus {}
460
461/// There is no detailed description.
462///
463/// This type is not used in any activity, and only used as *part* of another schema.
464///
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct HealthCheckModule {
469    /// no description provided
470    #[serde(rename = "checkIntervalSec")]
471    pub check_interval_sec: Option<i32>,
472    /// no description provided
473    pub description: Option<String>,
474    /// no description provided
475    #[serde(rename = "healthyThreshold")]
476    pub healthy_threshold: Option<i32>,
477    /// no description provided
478    pub host: Option<String>,
479    /// no description provided
480    pub path: Option<String>,
481    /// no description provided
482    pub port: Option<i32>,
483    /// no description provided
484    #[serde(rename = "timeoutSec")]
485    pub timeout_sec: Option<i32>,
486    /// no description provided
487    #[serde(rename = "unhealthyThreshold")]
488    pub unhealthy_threshold: Option<i32>,
489}
490
491impl common::Part for HealthCheckModule {}
492
493/// There is no detailed description.
494///
495/// This type is not used in any activity, and only used as *part* of another schema.
496///
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct HealthCheckModuleStatus {
501    /// [Output Only] The HealthCheck URL.
502    #[serde(rename = "healthCheckUrl")]
503    pub health_check_url: Option<String>,
504}
505
506impl common::Part for HealthCheckModuleStatus {}
507
508/// There is no detailed description.
509///
510/// This type is not used in any activity, and only used as *part* of another schema.
511///
512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
513#[serde_with::serde_as]
514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
515pub struct LbModule {
516    /// no description provided
517    pub description: Option<String>,
518    /// no description provided
519    #[serde(rename = "healthChecks")]
520    pub health_checks: Option<Vec<String>>,
521    /// no description provided
522    #[serde(rename = "ipAddress")]
523    pub ip_address: Option<String>,
524    /// no description provided
525    #[serde(rename = "ipProtocol")]
526    pub ip_protocol: Option<String>,
527    /// no description provided
528    #[serde(rename = "portRange")]
529    pub port_range: Option<String>,
530    /// no description provided
531    #[serde(rename = "sessionAffinity")]
532    pub session_affinity: Option<String>,
533    /// no description provided
534    #[serde(rename = "targetModules")]
535    pub target_modules: Option<Vec<String>>,
536}
537
538impl common::Part for LbModule {}
539
540/// There is no detailed description.
541///
542/// This type is not used in any activity, and only used as *part* of another schema.
543///
544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
545#[serde_with::serde_as]
546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
547pub struct LbModuleStatus {
548    /// [Output Only] The URL of the corresponding ForwardingRule in GCE.
549    #[serde(rename = "forwardingRuleUrl")]
550    pub forwarding_rule_url: Option<String>,
551    /// [Output Only] The URL of the corresponding TargetPool resource in GCE.
552    #[serde(rename = "targetPoolUrl")]
553    pub target_pool_url: Option<String>,
554}
555
556impl common::Part for LbModuleStatus {}
557
558/// A Compute Engine metadata entry. Identical to the metadata on the corresponding Compute Engine resource.
559///
560/// This type is not used in any activity, and only used as *part* of another schema.
561///
562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
563#[serde_with::serde_as]
564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
565pub struct Metadata {
566    /// The fingerprint of the metadata.
567    #[serde(rename = "fingerPrint")]
568    pub finger_print: Option<String>,
569    /// A list of metadata items.
570    pub items: Option<Vec<MetadataItem>>,
571}
572
573impl common::Part for Metadata {}
574
575/// A Compute Engine metadata item, defined as a key:value pair. Identical to the metadata on the corresponding Compute Engine resource.
576///
577/// This type is not used in any activity, and only used as *part* of another schema.
578///
579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
580#[serde_with::serde_as]
581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
582pub struct MetadataItem {
583    /// A metadata key.
584    pub key: Option<String>,
585    /// A metadata value.
586    pub value: Option<String>,
587}
588
589impl common::Part for MetadataItem {}
590
591/// A module in a configuration. A module represents a single homogeneous, possibly replicated task.
592///
593/// This type is not used in any activity, and only used as *part* of another schema.
594///
595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
596#[serde_with::serde_as]
597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
598pub struct Module {
599    /// no description provided
600    #[serde(rename = "autoscalingModule")]
601    pub autoscaling_module: Option<AutoscalingModule>,
602    /// no description provided
603    #[serde(rename = "firewallModule")]
604    pub firewall_module: Option<FirewallModule>,
605    /// no description provided
606    #[serde(rename = "healthCheckModule")]
607    pub health_check_module: Option<HealthCheckModule>,
608    /// no description provided
609    #[serde(rename = "lbModule")]
610    pub lb_module: Option<LbModule>,
611    /// no description provided
612    #[serde(rename = "networkModule")]
613    pub network_module: Option<NetworkModule>,
614    /// no description provided
615    #[serde(rename = "replicaPoolModule")]
616    pub replica_pool_module: Option<ReplicaPoolModule>,
617    /// The type of this module. Valid values ("AUTOSCALING", "FIREWALL", "HEALTH_CHECK", "LOAD_BALANCING", "NETWORK", "REPLICA_POOL")
618    #[serde(rename = "type")]
619    pub type_: Option<String>,
620}
621
622impl common::Part for Module {}
623
624/// [Output Only] Aggregate status for a module.
625///
626/// This type is not used in any activity, and only used as *part* of another schema.
627///
628#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
629#[serde_with::serde_as]
630#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
631pub struct ModuleStatus {
632    /// [Output Only] The status of the AutoscalingModule, set for type AUTOSCALING.
633    #[serde(rename = "autoscalingModuleStatus")]
634    pub autoscaling_module_status: Option<AutoscalingModuleStatus>,
635    /// [Output Only] The status of the FirewallModule, set for type FIREWALL.
636    #[serde(rename = "firewallModuleStatus")]
637    pub firewall_module_status: Option<FirewallModuleStatus>,
638    /// [Output Only] The status of the HealthCheckModule, set for type HEALTH_CHECK.
639    #[serde(rename = "healthCheckModuleStatus")]
640    pub health_check_module_status: Option<HealthCheckModuleStatus>,
641    /// [Output Only] The status of the LbModule, set for type LOAD_BALANCING.
642    #[serde(rename = "lbModuleStatus")]
643    pub lb_module_status: Option<LbModuleStatus>,
644    /// [Output Only] The status of the NetworkModule, set for type NETWORK.
645    #[serde(rename = "networkModuleStatus")]
646    pub network_module_status: Option<NetworkModuleStatus>,
647    /// [Output Only] The status of the ReplicaPoolModule, set for type VM.
648    #[serde(rename = "replicaPoolModuleStatus")]
649    pub replica_pool_module_status: Option<ReplicaPoolModuleStatus>,
650    /// [Output Only] The current state of the module.
651    pub state: Option<DeployState>,
652    /// [Output Only] The type of the module.
653    #[serde(rename = "type")]
654    pub type_: Option<String>,
655}
656
657impl common::Part for ModuleStatus {}
658
659/// A Compute Engine NetworkInterface resource. Identical to the NetworkInterface on the corresponding Compute Engine resource.
660///
661/// This type is not used in any activity, and only used as *part* of another schema.
662///
663#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
664#[serde_with::serde_as]
665#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
666pub struct NetworkInterface {
667    /// An array of configurations for this interface. This specifies how this interface is configured to interact with other network services
668    #[serde(rename = "accessConfigs")]
669    pub access_configs: Option<Vec<AccessConfig>>,
670    /// Name of the interface.
671    pub name: Option<String>,
672    /// The name of the NetworkModule to which this interface applies. If not specified, or specified as 'default', this will use the 'default' network.
673    pub network: Option<String>,
674    /// An optional IPV4 internal network address to assign to the instance for this network interface.
675    #[serde(rename = "networkIp")]
676    pub network_ip: Option<String>,
677}
678
679impl common::Part for NetworkInterface {}
680
681/// There is no detailed description.
682///
683/// This type is not used in any activity, and only used as *part* of another schema.
684///
685#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
686#[serde_with::serde_as]
687#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
688pub struct NetworkModule {
689    /// Required; The range of internal addresses that are legal on this network. This range is a CIDR specification, for example: 192.168.0.0/16.
690    #[serde(rename = "IPv4Range")]
691    pub i_pv4_range: Option<String>,
692    /// The description of the network.
693    pub description: Option<String>,
694    /// An optional address that is used for default routing to other networks. This must be within the range specified by IPv4Range, and is typicall the first usable address in that range. If not specified, the default value is the first usable address in IPv4Range.
695    #[serde(rename = "gatewayIPv4")]
696    pub gateway_i_pv4: Option<String>,
697}
698
699impl common::Part for NetworkModule {}
700
701/// There is no detailed description.
702///
703/// This type is not used in any activity, and only used as *part* of another schema.
704///
705#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
706#[serde_with::serde_as]
707#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
708pub struct NetworkModuleStatus {
709    /// [Output Only] The URL of the corresponding Network resource.
710    #[serde(rename = "networkUrl")]
711    pub network_url: Option<String>,
712}
713
714impl common::Part for NetworkModuleStatus {}
715
716/// A Persistent Disk resource that will be created and attached to each Replica in the Pool. Each Replica will have a unique persistent disk that is created and attached to that Replica.
717///
718/// This type is not used in any activity, and only used as *part* of another schema.
719///
720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
721#[serde_with::serde_as]
722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
723pub struct NewDisk {
724    /// How the disk will be attached to the Replica.
725    pub attachment: Option<DiskAttachment>,
726    /// If true, then this disk will be deleted when the instance is deleted.
727    #[serde(rename = "autoDelete")]
728    pub auto_delete: Option<bool>,
729    /// If true, indicates that this is the root persistent disk.
730    pub boot: Option<bool>,
731    /// Create the new disk using these parameters. The name of the disk will be <instance_name>-<five_random_charactersgt;.
732    #[serde(rename = "initializeParams")]
733    pub initialize_params: Option<NewDiskInitializeParams>,
734}
735
736impl common::Part for NewDisk {}
737
738/// Initialization parameters for creating a new disk.
739///
740/// This type is not used in any activity, and only used as *part* of another schema.
741///
742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
743#[serde_with::serde_as]
744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
745pub struct NewDiskInitializeParams {
746    /// The size of the created disk in gigabytes.
747    #[serde(rename = "diskSizeGb")]
748    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
749    pub disk_size_gb: Option<i64>,
750    /// Name of the disk type resource describing which disk type to use to create the disk. For example 'pd-ssd' or 'pd-standard'. Default is 'pd-standard'
751    #[serde(rename = "diskType")]
752    pub disk_type: Option<String>,
753    /// The fully-qualified URL of a source image to use to create this disk.
754    #[serde(rename = "sourceImage")]
755    pub source_image: Option<String>,
756}
757
758impl common::Part for NewDiskInitializeParams {}
759
760/// A specification for overriding parameters in a Template that corresponds to the Deployment.
761///
762/// This type is not used in any activity, and only used as *part* of another schema.
763///
764#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
765#[serde_with::serde_as]
766#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
767pub struct ParamOverride {
768    /// A JSON Path expression that specifies which parameter should be overridden.
769    pub path: Option<String>,
770    /// The new value to assign to the overridden parameter.
771    pub value: Option<String>,
772}
773
774impl common::Part for ParamOverride {}
775
776/// There is no detailed description.
777///
778/// This type is not used in any activity, and only used as *part* of another schema.
779///
780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
781#[serde_with::serde_as]
782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
783pub struct ReplicaPoolModule {
784    /// A list of environment variables.
785    #[serde(rename = "envVariables")]
786    pub env_variables: Option<HashMap<String, EnvVariable>>,
787    /// The Health Checks to configure for the ReplicaPoolModule
788    #[serde(rename = "healthChecks")]
789    pub health_checks: Option<Vec<String>>,
790    /// Number of replicas in this module.
791    #[serde(rename = "numReplicas")]
792    pub num_replicas: Option<i32>,
793    /// Information for a ReplicaPoolModule.
794    #[serde(rename = "replicaPoolParams")]
795    pub replica_pool_params: Option<ReplicaPoolParams>,
796    /// [Output Only] The name of the Resource View associated with a ReplicaPoolModule. This field will be generated by the service.
797    #[serde(rename = "resourceView")]
798    pub resource_view: Option<String>,
799}
800
801impl common::Part for ReplicaPoolModule {}
802
803/// There is no detailed description.
804///
805/// This type is not used in any activity, and only used as *part* of another schema.
806///
807#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
808#[serde_with::serde_as]
809#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
810pub struct ReplicaPoolModuleStatus {
811    /// [Output Only] The URL of the associated ReplicaPool resource.
812    #[serde(rename = "replicaPoolUrl")]
813    pub replica_pool_url: Option<String>,
814    /// [Output Only] The URL of the Resource Group associated with this ReplicaPool.
815    #[serde(rename = "resourceViewUrl")]
816    pub resource_view_url: Option<String>,
817}
818
819impl common::Part for ReplicaPoolModuleStatus {}
820
821/// Configuration information for a ReplicaPools resource. Specifying an item within will determine the ReplicaPools API version used for a ReplicaPoolModule. Only one may be specified.
822///
823/// This type is not used in any activity, and only used as *part* of another schema.
824///
825#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
826#[serde_with::serde_as]
827#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
828pub struct ReplicaPoolParams {
829    /// ReplicaPoolParams specifications for use with ReplicaPools v1beta1.
830    pub v1beta1: Option<ReplicaPoolParamsV1Beta1>,
831}
832
833impl common::Part for ReplicaPoolParams {}
834
835/// Configuration information for a ReplicaPools v1beta1 API resource. Directly maps to ReplicaPool InitTemplate.
836///
837/// This type is not used in any activity, and only used as *part* of another schema.
838///
839#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
840#[serde_with::serde_as]
841#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
842pub struct ReplicaPoolParamsV1Beta1 {
843    /// Whether these replicas should be restarted if they experience a failure. The default value is true.
844    #[serde(rename = "autoRestart")]
845    pub auto_restart: Option<bool>,
846    /// The base name for instances within this ReplicaPool.
847    #[serde(rename = "baseInstanceName")]
848    pub base_instance_name: Option<String>,
849    /// Enables IP Forwarding
850    #[serde(rename = "canIpForward")]
851    pub can_ip_forward: Option<bool>,
852    /// An optional textual description of the resource.
853    pub description: Option<String>,
854    /// A list of existing Persistent Disk resources to attach to each replica in the pool. Each disk will be attached in read-only mode to every replica.
855    #[serde(rename = "disksToAttach")]
856    pub disks_to_attach: Option<Vec<ExistingDisk>>,
857    /// A list of Disk resources to create and attach to each Replica in the Pool. Currently, you can only define one disk and it must be a root persistent disk. Note that Replica Pool will create a root persistent disk for each replica.
858    #[serde(rename = "disksToCreate")]
859    pub disks_to_create: Option<Vec<NewDisk>>,
860    /// Name of the Action to be run during initialization of a ReplicaPoolModule.
861    #[serde(rename = "initAction")]
862    pub init_action: Option<String>,
863    /// The machine type for this instance. Either a complete URL, or the resource name (e.g. n1-standard-1).
864    #[serde(rename = "machineType")]
865    pub machine_type: Option<String>,
866    /// The metadata key/value pairs assigned to this instance.
867    pub metadata: Option<Metadata>,
868    /// A list of network interfaces for the instance. Currently only one interface is supported by Google Compute Engine.
869    #[serde(rename = "networkInterfaces")]
870    pub network_interfaces: Option<Vec<NetworkInterface>>,
871    /// no description provided
872    #[serde(rename = "onHostMaintenance")]
873    pub on_host_maintenance: Option<String>,
874    /// A list of Service Accounts to enable for this instance.
875    #[serde(rename = "serviceAccounts")]
876    pub service_accounts: Option<Vec<ServiceAccount>>,
877    /// A list of tags to apply to the Google Compute Engine instance to identify resources.
878    pub tags: Option<Tag>,
879    /// The zone for this ReplicaPool.
880    pub zone: Option<String>,
881}
882
883impl common::Part for ReplicaPoolParamsV1Beta1 {}
884
885/// A Compute Engine service account, identical to the Compute Engine resource.
886///
887/// This type is not used in any activity, and only used as *part* of another schema.
888///
889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
890#[serde_with::serde_as]
891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
892pub struct ServiceAccount {
893    /// Service account email address.
894    pub email: Option<String>,
895    /// List of OAuth2 scopes to obtain for the service account.
896    pub scopes: Option<Vec<String>>,
897}
898
899impl common::Part for ServiceAccount {}
900
901/// A Compute Engine Instance tag, identical to the tags on the corresponding Compute Engine Instance resource.
902///
903/// This type is not used in any activity, and only used as *part* of another schema.
904///
905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
906#[serde_with::serde_as]
907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
908pub struct Tag {
909    /// The fingerprint of the tag.
910    #[serde(rename = "fingerPrint")]
911    pub finger_print: Option<String>,
912    /// Items contained in this tag.
913    pub items: Option<Vec<String>>,
914}
915
916impl common::Part for Tag {}
917
918/// A Template represents a complete configuration for a Deployment.
919///
920/// # Activities
921///
922/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
923/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
924///
925/// * [delete templates](TemplateDeleteCall) (none)
926/// * [get templates](TemplateGetCall) (response)
927/// * [insert templates](TemplateInsertCall) (request|response)
928/// * [list templates](TemplateListCall) (none)
929#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
930#[serde_with::serde_as]
931#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
932pub struct Template {
933    /// Action definitions for use in Module intents in this Template.
934    pub actions: Option<HashMap<String, Action>>,
935    /// A user-supplied description of this Template.
936    pub description: Option<String>,
937    /// A list of modules for this Template.
938    pub modules: Option<HashMap<String, Module>>,
939    /// Name of this Template. The name must conform to the expression: [a-zA-Z0-9-_]{1,64}
940    pub name: Option<String>,
941}
942
943impl common::RequestValue for Template {}
944impl common::Resource for Template {}
945impl common::ResponseResult for Template {}
946
947/// There is no detailed description.
948///
949/// # Activities
950///
951/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
952/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
953///
954/// * [list templates](TemplateListCall) (response)
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct TemplatesListResponse {
959    /// no description provided
960    #[serde(rename = "nextPageToken")]
961    pub next_page_token: Option<String>,
962    /// no description provided
963    pub resources: Option<Vec<Template>>,
964}
965
966impl common::ResponseResult for TemplatesListResponse {}
967
968// ###################
969// MethodBuilders ###
970// #################
971
972/// A builder providing access to all methods supported on *deployment* resources.
973/// It is not used directly, but through the [`Manager`] hub.
974///
975/// # Example
976///
977/// Instantiate a resource builder
978///
979/// ```test_harness,no_run
980/// extern crate hyper;
981/// extern crate hyper_rustls;
982/// extern crate google_manager1_beta2 as manager1_beta2;
983///
984/// # async fn dox() {
985/// use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
986///
987/// let secret: yup_oauth2::ApplicationSecret = Default::default();
988/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
989///     secret,
990///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
991/// ).build().await.unwrap();
992///
993/// let client = hyper_util::client::legacy::Client::builder(
994///     hyper_util::rt::TokioExecutor::new()
995/// )
996/// .build(
997///     hyper_rustls::HttpsConnectorBuilder::new()
998///         .with_native_roots()
999///         .unwrap()
1000///         .https_or_http()
1001///         .enable_http1()
1002///         .build()
1003/// );
1004/// let mut hub = Manager::new(client, auth);
1005/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1006/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
1007/// // to build up your call.
1008/// let rb = hub.deployments();
1009/// # }
1010/// ```
1011pub struct DeploymentMethods<'a, C>
1012where
1013    C: 'a,
1014{
1015    hub: &'a Manager<C>,
1016}
1017
1018impl<'a, C> common::MethodsBuilder for DeploymentMethods<'a, C> {}
1019
1020impl<'a, C> DeploymentMethods<'a, C> {
1021    /// Create a builder to help you perform the following task:
1022    ///
1023    ///
1024    ///
1025    /// # Arguments
1026    ///
1027    /// * `projectId` - No description provided.
1028    /// * `region` - No description provided.
1029    /// * `deploymentName` - No description provided.
1030    pub fn delete(
1031        &self,
1032        project_id: &str,
1033        region: &str,
1034        deployment_name: &str,
1035    ) -> DeploymentDeleteCall<'a, C> {
1036        DeploymentDeleteCall {
1037            hub: self.hub,
1038            _project_id: project_id.to_string(),
1039            _region: region.to_string(),
1040            _deployment_name: deployment_name.to_string(),
1041            _delegate: Default::default(),
1042            _additional_params: Default::default(),
1043            _scopes: Default::default(),
1044        }
1045    }
1046
1047    /// Create a builder to help you perform the following task:
1048    ///
1049    ///
1050    ///
1051    /// # Arguments
1052    ///
1053    /// * `projectId` - No description provided.
1054    /// * `region` - No description provided.
1055    /// * `deploymentName` - No description provided.
1056    pub fn get(
1057        &self,
1058        project_id: &str,
1059        region: &str,
1060        deployment_name: &str,
1061    ) -> DeploymentGetCall<'a, C> {
1062        DeploymentGetCall {
1063            hub: self.hub,
1064            _project_id: project_id.to_string(),
1065            _region: region.to_string(),
1066            _deployment_name: deployment_name.to_string(),
1067            _delegate: Default::default(),
1068            _additional_params: Default::default(),
1069            _scopes: Default::default(),
1070        }
1071    }
1072
1073    /// Create a builder to help you perform the following task:
1074    ///
1075    ///
1076    ///
1077    /// # Arguments
1078    ///
1079    /// * `request` - No description provided.
1080    /// * `projectId` - No description provided.
1081    /// * `region` - No description provided.
1082    pub fn insert(
1083        &self,
1084        request: Deployment,
1085        project_id: &str,
1086        region: &str,
1087    ) -> DeploymentInsertCall<'a, C> {
1088        DeploymentInsertCall {
1089            hub: self.hub,
1090            _request: request,
1091            _project_id: project_id.to_string(),
1092            _region: region.to_string(),
1093            _delegate: Default::default(),
1094            _additional_params: Default::default(),
1095            _scopes: Default::default(),
1096        }
1097    }
1098
1099    /// Create a builder to help you perform the following task:
1100    ///
1101    ///
1102    ///
1103    /// # Arguments
1104    ///
1105    /// * `projectId` - No description provided.
1106    /// * `region` - No description provided.
1107    pub fn list(&self, project_id: &str, region: &str) -> DeploymentListCall<'a, C> {
1108        DeploymentListCall {
1109            hub: self.hub,
1110            _project_id: project_id.to_string(),
1111            _region: region.to_string(),
1112            _page_token: Default::default(),
1113            _max_results: Default::default(),
1114            _delegate: Default::default(),
1115            _additional_params: Default::default(),
1116            _scopes: Default::default(),
1117        }
1118    }
1119}
1120
1121/// A builder providing access to all methods supported on *template* resources.
1122/// It is not used directly, but through the [`Manager`] hub.
1123///
1124/// # Example
1125///
1126/// Instantiate a resource builder
1127///
1128/// ```test_harness,no_run
1129/// extern crate hyper;
1130/// extern crate hyper_rustls;
1131/// extern crate google_manager1_beta2 as manager1_beta2;
1132///
1133/// # async fn dox() {
1134/// use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1135///
1136/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1137/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1138///     secret,
1139///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1140/// ).build().await.unwrap();
1141///
1142/// let client = hyper_util::client::legacy::Client::builder(
1143///     hyper_util::rt::TokioExecutor::new()
1144/// )
1145/// .build(
1146///     hyper_rustls::HttpsConnectorBuilder::new()
1147///         .with_native_roots()
1148///         .unwrap()
1149///         .https_or_http()
1150///         .enable_http1()
1151///         .build()
1152/// );
1153/// let mut hub = Manager::new(client, auth);
1154/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1155/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
1156/// // to build up your call.
1157/// let rb = hub.templates();
1158/// # }
1159/// ```
1160pub struct TemplateMethods<'a, C>
1161where
1162    C: 'a,
1163{
1164    hub: &'a Manager<C>,
1165}
1166
1167impl<'a, C> common::MethodsBuilder for TemplateMethods<'a, C> {}
1168
1169impl<'a, C> TemplateMethods<'a, C> {
1170    /// Create a builder to help you perform the following task:
1171    ///
1172    ///
1173    ///
1174    /// # Arguments
1175    ///
1176    /// * `projectId` - No description provided.
1177    /// * `templateName` - No description provided.
1178    pub fn delete(&self, project_id: &str, template_name: &str) -> TemplateDeleteCall<'a, C> {
1179        TemplateDeleteCall {
1180            hub: self.hub,
1181            _project_id: project_id.to_string(),
1182            _template_name: template_name.to_string(),
1183            _delegate: Default::default(),
1184            _additional_params: Default::default(),
1185            _scopes: Default::default(),
1186        }
1187    }
1188
1189    /// Create a builder to help you perform the following task:
1190    ///
1191    ///
1192    ///
1193    /// # Arguments
1194    ///
1195    /// * `projectId` - No description provided.
1196    /// * `templateName` - No description provided.
1197    pub fn get(&self, project_id: &str, template_name: &str) -> TemplateGetCall<'a, C> {
1198        TemplateGetCall {
1199            hub: self.hub,
1200            _project_id: project_id.to_string(),
1201            _template_name: template_name.to_string(),
1202            _delegate: Default::default(),
1203            _additional_params: Default::default(),
1204            _scopes: Default::default(),
1205        }
1206    }
1207
1208    /// Create a builder to help you perform the following task:
1209    ///
1210    ///
1211    ///
1212    /// # Arguments
1213    ///
1214    /// * `request` - No description provided.
1215    /// * `projectId` - No description provided.
1216    pub fn insert(&self, request: Template, project_id: &str) -> TemplateInsertCall<'a, C> {
1217        TemplateInsertCall {
1218            hub: self.hub,
1219            _request: request,
1220            _project_id: project_id.to_string(),
1221            _delegate: Default::default(),
1222            _additional_params: Default::default(),
1223            _scopes: Default::default(),
1224        }
1225    }
1226
1227    /// Create a builder to help you perform the following task:
1228    ///
1229    ///
1230    ///
1231    /// # Arguments
1232    ///
1233    /// * `projectId` - No description provided.
1234    pub fn list(&self, project_id: &str) -> TemplateListCall<'a, C> {
1235        TemplateListCall {
1236            hub: self.hub,
1237            _project_id: project_id.to_string(),
1238            _page_token: Default::default(),
1239            _max_results: Default::default(),
1240            _delegate: Default::default(),
1241            _additional_params: Default::default(),
1242            _scopes: Default::default(),
1243        }
1244    }
1245}
1246
1247// ###################
1248// CallBuilders   ###
1249// #################
1250
1251///
1252///
1253/// A builder for the *delete* method supported by a *deployment* resource.
1254/// It is not used directly, but through a [`DeploymentMethods`] instance.
1255///
1256/// # Example
1257///
1258/// Instantiate a resource method builder
1259///
1260/// ```test_harness,no_run
1261/// # extern crate hyper;
1262/// # extern crate hyper_rustls;
1263/// # extern crate google_manager1_beta2 as manager1_beta2;
1264/// # async fn dox() {
1265/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1266///
1267/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1268/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1269/// #     secret,
1270/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1271/// # ).build().await.unwrap();
1272///
1273/// # let client = hyper_util::client::legacy::Client::builder(
1274/// #     hyper_util::rt::TokioExecutor::new()
1275/// # )
1276/// # .build(
1277/// #     hyper_rustls::HttpsConnectorBuilder::new()
1278/// #         .with_native_roots()
1279/// #         .unwrap()
1280/// #         .https_or_http()
1281/// #         .enable_http1()
1282/// #         .build()
1283/// # );
1284/// # let mut hub = Manager::new(client, auth);
1285/// // You can configure optional parameters by calling the respective setters at will, and
1286/// // execute the final call using `doit()`.
1287/// // Values shown here are possibly random and not representative !
1288/// let result = hub.deployments().delete("projectId", "region", "deploymentName")
1289///              .doit().await;
1290/// # }
1291/// ```
1292pub struct DeploymentDeleteCall<'a, C>
1293where
1294    C: 'a,
1295{
1296    hub: &'a Manager<C>,
1297    _project_id: String,
1298    _region: String,
1299    _deployment_name: String,
1300    _delegate: Option<&'a mut dyn common::Delegate>,
1301    _additional_params: HashMap<String, String>,
1302    _scopes: BTreeSet<String>,
1303}
1304
1305impl<'a, C> common::CallBuilder for DeploymentDeleteCall<'a, C> {}
1306
1307impl<'a, C> DeploymentDeleteCall<'a, C>
1308where
1309    C: common::Connector,
1310{
1311    /// Perform the operation you have build so far.
1312    pub async fn doit(mut self) -> common::Result<common::Response> {
1313        use std::borrow::Cow;
1314        use std::io::{Read, Seek};
1315
1316        use common::{url::Params, ToParts};
1317        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1318
1319        let mut dd = common::DefaultDelegate;
1320        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1321        dlg.begin(common::MethodInfo {
1322            id: "manager.deployments.delete",
1323            http_method: hyper::Method::DELETE,
1324        });
1325
1326        for &field in ["projectId", "region", "deploymentName"].iter() {
1327            if self._additional_params.contains_key(field) {
1328                dlg.finished(false);
1329                return Err(common::Error::FieldClash(field));
1330            }
1331        }
1332
1333        let mut params = Params::with_capacity(4 + self._additional_params.len());
1334        params.push("projectId", self._project_id);
1335        params.push("region", self._region);
1336        params.push("deploymentName", self._deployment_name);
1337
1338        params.extend(self._additional_params.iter());
1339
1340        let mut url = self.hub._base_url.clone()
1341            + "{projectId}/regions/{region}/deployments/{deploymentName}";
1342        if self._scopes.is_empty() {
1343            self._scopes
1344                .insert(Scope::CloudPlatform.as_ref().to_string());
1345        }
1346
1347        #[allow(clippy::single_element_loop)]
1348        for &(find_this, param_name) in [
1349            ("{projectId}", "projectId"),
1350            ("{region}", "region"),
1351            ("{deploymentName}", "deploymentName"),
1352        ]
1353        .iter()
1354        {
1355            url = params.uri_replacement(url, param_name, find_this, false);
1356        }
1357        {
1358            let to_remove = ["deploymentName", "region", "projectId"];
1359            params.remove_params(&to_remove);
1360        }
1361
1362        let url = params.parse_with_url(&url);
1363
1364        loop {
1365            let token = match self
1366                .hub
1367                .auth
1368                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1369                .await
1370            {
1371                Ok(token) => token,
1372                Err(e) => match dlg.token(e) {
1373                    Ok(token) => token,
1374                    Err(e) => {
1375                        dlg.finished(false);
1376                        return Err(common::Error::MissingToken(e));
1377                    }
1378                },
1379            };
1380            let mut req_result = {
1381                let client = &self.hub.client;
1382                dlg.pre_request();
1383                let mut req_builder = hyper::Request::builder()
1384                    .method(hyper::Method::DELETE)
1385                    .uri(url.as_str())
1386                    .header(USER_AGENT, self.hub._user_agent.clone());
1387
1388                if let Some(token) = token.as_ref() {
1389                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1390                }
1391
1392                let request = req_builder
1393                    .header(CONTENT_LENGTH, 0_u64)
1394                    .body(common::to_body::<String>(None));
1395
1396                client.request(request.unwrap()).await
1397            };
1398
1399            match req_result {
1400                Err(err) => {
1401                    if let common::Retry::After(d) = dlg.http_error(&err) {
1402                        sleep(d).await;
1403                        continue;
1404                    }
1405                    dlg.finished(false);
1406                    return Err(common::Error::HttpError(err));
1407                }
1408                Ok(res) => {
1409                    let (mut parts, body) = res.into_parts();
1410                    let mut body = common::Body::new(body);
1411                    if !parts.status.is_success() {
1412                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1413                        let error = serde_json::from_str(&common::to_string(&bytes));
1414                        let response = common::to_response(parts, bytes.into());
1415
1416                        if let common::Retry::After(d) =
1417                            dlg.http_failure(&response, error.as_ref().ok())
1418                        {
1419                            sleep(d).await;
1420                            continue;
1421                        }
1422
1423                        dlg.finished(false);
1424
1425                        return Err(match error {
1426                            Ok(value) => common::Error::BadRequest(value),
1427                            _ => common::Error::Failure(response),
1428                        });
1429                    }
1430                    let response = common::Response::from_parts(parts, body);
1431
1432                    dlg.finished(true);
1433                    return Ok(response);
1434                }
1435            }
1436        }
1437    }
1438
1439    ///
1440    /// Sets the *project id* path property to the given value.
1441    ///
1442    /// Even though the property as already been set when instantiating this call,
1443    /// we provide this method for API completeness.
1444    pub fn project_id(mut self, new_value: &str) -> DeploymentDeleteCall<'a, C> {
1445        self._project_id = new_value.to_string();
1446        self
1447    }
1448    ///
1449    /// Sets the *region* path property to the given value.
1450    ///
1451    /// Even though the property as already been set when instantiating this call,
1452    /// we provide this method for API completeness.
1453    pub fn region(mut self, new_value: &str) -> DeploymentDeleteCall<'a, C> {
1454        self._region = new_value.to_string();
1455        self
1456    }
1457    ///
1458    /// Sets the *deployment name* path property to the given value.
1459    ///
1460    /// Even though the property as already been set when instantiating this call,
1461    /// we provide this method for API completeness.
1462    pub fn deployment_name(mut self, new_value: &str) -> DeploymentDeleteCall<'a, C> {
1463        self._deployment_name = new_value.to_string();
1464        self
1465    }
1466    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1467    /// while executing the actual API request.
1468    ///
1469    /// ````text
1470    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1471    /// ````
1472    ///
1473    /// Sets the *delegate* property to the given value.
1474    pub fn delegate(
1475        mut self,
1476        new_value: &'a mut dyn common::Delegate,
1477    ) -> DeploymentDeleteCall<'a, C> {
1478        self._delegate = Some(new_value);
1479        self
1480    }
1481
1482    /// Set any additional parameter of the query string used in the request.
1483    /// It should be used to set parameters which are not yet available through their own
1484    /// setters.
1485    ///
1486    /// Please note that this method must not be used to set any of the known parameters
1487    /// which have their own setter method. If done anyway, the request will fail.
1488    ///
1489    /// # Additional Parameters
1490    ///
1491    /// * *alt* (query-string) - Data format for the response.
1492    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1493    /// * *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.
1494    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1495    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1496    /// * *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. Overrides userIp if both are provided.
1497    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1498    pub fn param<T>(mut self, name: T, value: T) -> DeploymentDeleteCall<'a, C>
1499    where
1500        T: AsRef<str>,
1501    {
1502        self._additional_params
1503            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1504        self
1505    }
1506
1507    /// Identifies the authorization scope for the method you are building.
1508    ///
1509    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1510    /// [`Scope::CloudPlatform`].
1511    ///
1512    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1513    /// tokens for more than one scope.
1514    ///
1515    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1516    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1517    /// sufficient, a read-write scope will do as well.
1518    pub fn add_scope<St>(mut self, scope: St) -> DeploymentDeleteCall<'a, C>
1519    where
1520        St: AsRef<str>,
1521    {
1522        self._scopes.insert(String::from(scope.as_ref()));
1523        self
1524    }
1525    /// Identifies the authorization scope(s) for the method you are building.
1526    ///
1527    /// See [`Self::add_scope()`] for details.
1528    pub fn add_scopes<I, St>(mut self, scopes: I) -> DeploymentDeleteCall<'a, C>
1529    where
1530        I: IntoIterator<Item = St>,
1531        St: AsRef<str>,
1532    {
1533        self._scopes
1534            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1535        self
1536    }
1537
1538    /// Removes all scopes, and no default scope will be used either.
1539    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1540    /// for details).
1541    pub fn clear_scopes(mut self) -> DeploymentDeleteCall<'a, C> {
1542        self._scopes.clear();
1543        self
1544    }
1545}
1546
1547///
1548///
1549/// A builder for the *get* method supported by a *deployment* resource.
1550/// It is not used directly, but through a [`DeploymentMethods`] instance.
1551///
1552/// # Example
1553///
1554/// Instantiate a resource method builder
1555///
1556/// ```test_harness,no_run
1557/// # extern crate hyper;
1558/// # extern crate hyper_rustls;
1559/// # extern crate google_manager1_beta2 as manager1_beta2;
1560/// # async fn dox() {
1561/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1562///
1563/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1564/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1565/// #     secret,
1566/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1567/// # ).build().await.unwrap();
1568///
1569/// # let client = hyper_util::client::legacy::Client::builder(
1570/// #     hyper_util::rt::TokioExecutor::new()
1571/// # )
1572/// # .build(
1573/// #     hyper_rustls::HttpsConnectorBuilder::new()
1574/// #         .with_native_roots()
1575/// #         .unwrap()
1576/// #         .https_or_http()
1577/// #         .enable_http1()
1578/// #         .build()
1579/// # );
1580/// # let mut hub = Manager::new(client, auth);
1581/// // You can configure optional parameters by calling the respective setters at will, and
1582/// // execute the final call using `doit()`.
1583/// // Values shown here are possibly random and not representative !
1584/// let result = hub.deployments().get("projectId", "region", "deploymentName")
1585///              .doit().await;
1586/// # }
1587/// ```
1588pub struct DeploymentGetCall<'a, C>
1589where
1590    C: 'a,
1591{
1592    hub: &'a Manager<C>,
1593    _project_id: String,
1594    _region: String,
1595    _deployment_name: String,
1596    _delegate: Option<&'a mut dyn common::Delegate>,
1597    _additional_params: HashMap<String, String>,
1598    _scopes: BTreeSet<String>,
1599}
1600
1601impl<'a, C> common::CallBuilder for DeploymentGetCall<'a, C> {}
1602
1603impl<'a, C> DeploymentGetCall<'a, C>
1604where
1605    C: common::Connector,
1606{
1607    /// Perform the operation you have build so far.
1608    pub async fn doit(mut self) -> common::Result<(common::Response, Deployment)> {
1609        use std::borrow::Cow;
1610        use std::io::{Read, Seek};
1611
1612        use common::{url::Params, ToParts};
1613        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1614
1615        let mut dd = common::DefaultDelegate;
1616        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1617        dlg.begin(common::MethodInfo {
1618            id: "manager.deployments.get",
1619            http_method: hyper::Method::GET,
1620        });
1621
1622        for &field in ["alt", "projectId", "region", "deploymentName"].iter() {
1623            if self._additional_params.contains_key(field) {
1624                dlg.finished(false);
1625                return Err(common::Error::FieldClash(field));
1626            }
1627        }
1628
1629        let mut params = Params::with_capacity(5 + self._additional_params.len());
1630        params.push("projectId", self._project_id);
1631        params.push("region", self._region);
1632        params.push("deploymentName", self._deployment_name);
1633
1634        params.extend(self._additional_params.iter());
1635
1636        params.push("alt", "json");
1637        let mut url = self.hub._base_url.clone()
1638            + "{projectId}/regions/{region}/deployments/{deploymentName}";
1639        if self._scopes.is_empty() {
1640            self._scopes
1641                .insert(Scope::NdevCloudmanReadonly.as_ref().to_string());
1642        }
1643
1644        #[allow(clippy::single_element_loop)]
1645        for &(find_this, param_name) in [
1646            ("{projectId}", "projectId"),
1647            ("{region}", "region"),
1648            ("{deploymentName}", "deploymentName"),
1649        ]
1650        .iter()
1651        {
1652            url = params.uri_replacement(url, param_name, find_this, false);
1653        }
1654        {
1655            let to_remove = ["deploymentName", "region", "projectId"];
1656            params.remove_params(&to_remove);
1657        }
1658
1659        let url = params.parse_with_url(&url);
1660
1661        loop {
1662            let token = match self
1663                .hub
1664                .auth
1665                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1666                .await
1667            {
1668                Ok(token) => token,
1669                Err(e) => match dlg.token(e) {
1670                    Ok(token) => token,
1671                    Err(e) => {
1672                        dlg.finished(false);
1673                        return Err(common::Error::MissingToken(e));
1674                    }
1675                },
1676            };
1677            let mut req_result = {
1678                let client = &self.hub.client;
1679                dlg.pre_request();
1680                let mut req_builder = hyper::Request::builder()
1681                    .method(hyper::Method::GET)
1682                    .uri(url.as_str())
1683                    .header(USER_AGENT, self.hub._user_agent.clone());
1684
1685                if let Some(token) = token.as_ref() {
1686                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1687                }
1688
1689                let request = req_builder
1690                    .header(CONTENT_LENGTH, 0_u64)
1691                    .body(common::to_body::<String>(None));
1692
1693                client.request(request.unwrap()).await
1694            };
1695
1696            match req_result {
1697                Err(err) => {
1698                    if let common::Retry::After(d) = dlg.http_error(&err) {
1699                        sleep(d).await;
1700                        continue;
1701                    }
1702                    dlg.finished(false);
1703                    return Err(common::Error::HttpError(err));
1704                }
1705                Ok(res) => {
1706                    let (mut parts, body) = res.into_parts();
1707                    let mut body = common::Body::new(body);
1708                    if !parts.status.is_success() {
1709                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1710                        let error = serde_json::from_str(&common::to_string(&bytes));
1711                        let response = common::to_response(parts, bytes.into());
1712
1713                        if let common::Retry::After(d) =
1714                            dlg.http_failure(&response, error.as_ref().ok())
1715                        {
1716                            sleep(d).await;
1717                            continue;
1718                        }
1719
1720                        dlg.finished(false);
1721
1722                        return Err(match error {
1723                            Ok(value) => common::Error::BadRequest(value),
1724                            _ => common::Error::Failure(response),
1725                        });
1726                    }
1727                    let response = {
1728                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1729                        let encoded = common::to_string(&bytes);
1730                        match serde_json::from_str(&encoded) {
1731                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1732                            Err(error) => {
1733                                dlg.response_json_decode_error(&encoded, &error);
1734                                return Err(common::Error::JsonDecodeError(
1735                                    encoded.to_string(),
1736                                    error,
1737                                ));
1738                            }
1739                        }
1740                    };
1741
1742                    dlg.finished(true);
1743                    return Ok(response);
1744                }
1745            }
1746        }
1747    }
1748
1749    ///
1750    /// Sets the *project id* path property to the given value.
1751    ///
1752    /// Even though the property as already been set when instantiating this call,
1753    /// we provide this method for API completeness.
1754    pub fn project_id(mut self, new_value: &str) -> DeploymentGetCall<'a, C> {
1755        self._project_id = new_value.to_string();
1756        self
1757    }
1758    ///
1759    /// Sets the *region* path property to the given value.
1760    ///
1761    /// Even though the property as already been set when instantiating this call,
1762    /// we provide this method for API completeness.
1763    pub fn region(mut self, new_value: &str) -> DeploymentGetCall<'a, C> {
1764        self._region = new_value.to_string();
1765        self
1766    }
1767    ///
1768    /// Sets the *deployment name* path property to the given value.
1769    ///
1770    /// Even though the property as already been set when instantiating this call,
1771    /// we provide this method for API completeness.
1772    pub fn deployment_name(mut self, new_value: &str) -> DeploymentGetCall<'a, C> {
1773        self._deployment_name = new_value.to_string();
1774        self
1775    }
1776    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1777    /// while executing the actual API request.
1778    ///
1779    /// ````text
1780    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1781    /// ````
1782    ///
1783    /// Sets the *delegate* property to the given value.
1784    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DeploymentGetCall<'a, C> {
1785        self._delegate = Some(new_value);
1786        self
1787    }
1788
1789    /// Set any additional parameter of the query string used in the request.
1790    /// It should be used to set parameters which are not yet available through their own
1791    /// setters.
1792    ///
1793    /// Please note that this method must not be used to set any of the known parameters
1794    /// which have their own setter method. If done anyway, the request will fail.
1795    ///
1796    /// # Additional Parameters
1797    ///
1798    /// * *alt* (query-string) - Data format for the response.
1799    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1800    /// * *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.
1801    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1802    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1803    /// * *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. Overrides userIp if both are provided.
1804    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1805    pub fn param<T>(mut self, name: T, value: T) -> DeploymentGetCall<'a, C>
1806    where
1807        T: AsRef<str>,
1808    {
1809        self._additional_params
1810            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1811        self
1812    }
1813
1814    /// Identifies the authorization scope for the method you are building.
1815    ///
1816    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1817    /// [`Scope::NdevCloudmanReadonly`].
1818    ///
1819    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1820    /// tokens for more than one scope.
1821    ///
1822    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1823    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1824    /// sufficient, a read-write scope will do as well.
1825    pub fn add_scope<St>(mut self, scope: St) -> DeploymentGetCall<'a, C>
1826    where
1827        St: AsRef<str>,
1828    {
1829        self._scopes.insert(String::from(scope.as_ref()));
1830        self
1831    }
1832    /// Identifies the authorization scope(s) for the method you are building.
1833    ///
1834    /// See [`Self::add_scope()`] for details.
1835    pub fn add_scopes<I, St>(mut self, scopes: I) -> DeploymentGetCall<'a, C>
1836    where
1837        I: IntoIterator<Item = St>,
1838        St: AsRef<str>,
1839    {
1840        self._scopes
1841            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1842        self
1843    }
1844
1845    /// Removes all scopes, and no default scope will be used either.
1846    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1847    /// for details).
1848    pub fn clear_scopes(mut self) -> DeploymentGetCall<'a, C> {
1849        self._scopes.clear();
1850        self
1851    }
1852}
1853
1854///
1855///
1856/// A builder for the *insert* method supported by a *deployment* resource.
1857/// It is not used directly, but through a [`DeploymentMethods`] instance.
1858///
1859/// # Example
1860///
1861/// Instantiate a resource method builder
1862///
1863/// ```test_harness,no_run
1864/// # extern crate hyper;
1865/// # extern crate hyper_rustls;
1866/// # extern crate google_manager1_beta2 as manager1_beta2;
1867/// use manager1_beta2::api::Deployment;
1868/// # async fn dox() {
1869/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1870///
1871/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1873/// #     secret,
1874/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1875/// # ).build().await.unwrap();
1876///
1877/// # let client = hyper_util::client::legacy::Client::builder(
1878/// #     hyper_util::rt::TokioExecutor::new()
1879/// # )
1880/// # .build(
1881/// #     hyper_rustls::HttpsConnectorBuilder::new()
1882/// #         .with_native_roots()
1883/// #         .unwrap()
1884/// #         .https_or_http()
1885/// #         .enable_http1()
1886/// #         .build()
1887/// # );
1888/// # let mut hub = Manager::new(client, auth);
1889/// // As the method needs a request, you would usually fill it with the desired information
1890/// // into the respective structure. Some of the parts shown here might not be applicable !
1891/// // Values shown here are possibly random and not representative !
1892/// let mut req = Deployment::default();
1893///
1894/// // You can configure optional parameters by calling the respective setters at will, and
1895/// // execute the final call using `doit()`.
1896/// // Values shown here are possibly random and not representative !
1897/// let result = hub.deployments().insert(req, "projectId", "region")
1898///              .doit().await;
1899/// # }
1900/// ```
1901pub struct DeploymentInsertCall<'a, C>
1902where
1903    C: 'a,
1904{
1905    hub: &'a Manager<C>,
1906    _request: Deployment,
1907    _project_id: String,
1908    _region: String,
1909    _delegate: Option<&'a mut dyn common::Delegate>,
1910    _additional_params: HashMap<String, String>,
1911    _scopes: BTreeSet<String>,
1912}
1913
1914impl<'a, C> common::CallBuilder for DeploymentInsertCall<'a, C> {}
1915
1916impl<'a, C> DeploymentInsertCall<'a, C>
1917where
1918    C: common::Connector,
1919{
1920    /// Perform the operation you have build so far.
1921    pub async fn doit(mut self) -> common::Result<(common::Response, Deployment)> {
1922        use std::borrow::Cow;
1923        use std::io::{Read, Seek};
1924
1925        use common::{url::Params, ToParts};
1926        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1927
1928        let mut dd = common::DefaultDelegate;
1929        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1930        dlg.begin(common::MethodInfo {
1931            id: "manager.deployments.insert",
1932            http_method: hyper::Method::POST,
1933        });
1934
1935        for &field in ["alt", "projectId", "region"].iter() {
1936            if self._additional_params.contains_key(field) {
1937                dlg.finished(false);
1938                return Err(common::Error::FieldClash(field));
1939            }
1940        }
1941
1942        let mut params = Params::with_capacity(5 + self._additional_params.len());
1943        params.push("projectId", self._project_id);
1944        params.push("region", self._region);
1945
1946        params.extend(self._additional_params.iter());
1947
1948        params.push("alt", "json");
1949        let mut url = self.hub._base_url.clone() + "{projectId}/regions/{region}/deployments";
1950        if self._scopes.is_empty() {
1951            self._scopes
1952                .insert(Scope::AppengineAdmin.as_ref().to_string());
1953        }
1954
1955        #[allow(clippy::single_element_loop)]
1956        for &(find_this, param_name) in
1957            [("{projectId}", "projectId"), ("{region}", "region")].iter()
1958        {
1959            url = params.uri_replacement(url, param_name, find_this, false);
1960        }
1961        {
1962            let to_remove = ["region", "projectId"];
1963            params.remove_params(&to_remove);
1964        }
1965
1966        let url = params.parse_with_url(&url);
1967
1968        let mut json_mime_type = mime::APPLICATION_JSON;
1969        let mut request_value_reader = {
1970            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1971            common::remove_json_null_values(&mut value);
1972            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1973            serde_json::to_writer(&mut dst, &value).unwrap();
1974            dst
1975        };
1976        let request_size = request_value_reader
1977            .seek(std::io::SeekFrom::End(0))
1978            .unwrap();
1979        request_value_reader
1980            .seek(std::io::SeekFrom::Start(0))
1981            .unwrap();
1982
1983        loop {
1984            let token = match self
1985                .hub
1986                .auth
1987                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1988                .await
1989            {
1990                Ok(token) => token,
1991                Err(e) => match dlg.token(e) {
1992                    Ok(token) => token,
1993                    Err(e) => {
1994                        dlg.finished(false);
1995                        return Err(common::Error::MissingToken(e));
1996                    }
1997                },
1998            };
1999            request_value_reader
2000                .seek(std::io::SeekFrom::Start(0))
2001                .unwrap();
2002            let mut req_result = {
2003                let client = &self.hub.client;
2004                dlg.pre_request();
2005                let mut req_builder = hyper::Request::builder()
2006                    .method(hyper::Method::POST)
2007                    .uri(url.as_str())
2008                    .header(USER_AGENT, self.hub._user_agent.clone());
2009
2010                if let Some(token) = token.as_ref() {
2011                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2012                }
2013
2014                let request = req_builder
2015                    .header(CONTENT_TYPE, json_mime_type.to_string())
2016                    .header(CONTENT_LENGTH, request_size as u64)
2017                    .body(common::to_body(
2018                        request_value_reader.get_ref().clone().into(),
2019                    ));
2020
2021                client.request(request.unwrap()).await
2022            };
2023
2024            match req_result {
2025                Err(err) => {
2026                    if let common::Retry::After(d) = dlg.http_error(&err) {
2027                        sleep(d).await;
2028                        continue;
2029                    }
2030                    dlg.finished(false);
2031                    return Err(common::Error::HttpError(err));
2032                }
2033                Ok(res) => {
2034                    let (mut parts, body) = res.into_parts();
2035                    let mut body = common::Body::new(body);
2036                    if !parts.status.is_success() {
2037                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2038                        let error = serde_json::from_str(&common::to_string(&bytes));
2039                        let response = common::to_response(parts, bytes.into());
2040
2041                        if let common::Retry::After(d) =
2042                            dlg.http_failure(&response, error.as_ref().ok())
2043                        {
2044                            sleep(d).await;
2045                            continue;
2046                        }
2047
2048                        dlg.finished(false);
2049
2050                        return Err(match error {
2051                            Ok(value) => common::Error::BadRequest(value),
2052                            _ => common::Error::Failure(response),
2053                        });
2054                    }
2055                    let response = {
2056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2057                        let encoded = common::to_string(&bytes);
2058                        match serde_json::from_str(&encoded) {
2059                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2060                            Err(error) => {
2061                                dlg.response_json_decode_error(&encoded, &error);
2062                                return Err(common::Error::JsonDecodeError(
2063                                    encoded.to_string(),
2064                                    error,
2065                                ));
2066                            }
2067                        }
2068                    };
2069
2070                    dlg.finished(true);
2071                    return Ok(response);
2072                }
2073            }
2074        }
2075    }
2076
2077    ///
2078    /// Sets the *request* property to the given value.
2079    ///
2080    /// Even though the property as already been set when instantiating this call,
2081    /// we provide this method for API completeness.
2082    pub fn request(mut self, new_value: Deployment) -> DeploymentInsertCall<'a, C> {
2083        self._request = new_value;
2084        self
2085    }
2086    ///
2087    /// Sets the *project id* path property to the given value.
2088    ///
2089    /// Even though the property as already been set when instantiating this call,
2090    /// we provide this method for API completeness.
2091    pub fn project_id(mut self, new_value: &str) -> DeploymentInsertCall<'a, C> {
2092        self._project_id = new_value.to_string();
2093        self
2094    }
2095    ///
2096    /// Sets the *region* path property to the given value.
2097    ///
2098    /// Even though the property as already been set when instantiating this call,
2099    /// we provide this method for API completeness.
2100    pub fn region(mut self, new_value: &str) -> DeploymentInsertCall<'a, C> {
2101        self._region = new_value.to_string();
2102        self
2103    }
2104    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2105    /// while executing the actual API request.
2106    ///
2107    /// ````text
2108    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2109    /// ````
2110    ///
2111    /// Sets the *delegate* property to the given value.
2112    pub fn delegate(
2113        mut self,
2114        new_value: &'a mut dyn common::Delegate,
2115    ) -> DeploymentInsertCall<'a, C> {
2116        self._delegate = Some(new_value);
2117        self
2118    }
2119
2120    /// Set any additional parameter of the query string used in the request.
2121    /// It should be used to set parameters which are not yet available through their own
2122    /// setters.
2123    ///
2124    /// Please note that this method must not be used to set any of the known parameters
2125    /// which have their own setter method. If done anyway, the request will fail.
2126    ///
2127    /// # Additional Parameters
2128    ///
2129    /// * *alt* (query-string) - Data format for the response.
2130    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2131    /// * *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.
2132    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2133    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2134    /// * *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. Overrides userIp if both are provided.
2135    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2136    pub fn param<T>(mut self, name: T, value: T) -> DeploymentInsertCall<'a, C>
2137    where
2138        T: AsRef<str>,
2139    {
2140        self._additional_params
2141            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2142        self
2143    }
2144
2145    /// Identifies the authorization scope for the method you are building.
2146    ///
2147    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2148    /// [`Scope::AppengineAdmin`].
2149    ///
2150    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2151    /// tokens for more than one scope.
2152    ///
2153    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2154    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2155    /// sufficient, a read-write scope will do as well.
2156    pub fn add_scope<St>(mut self, scope: St) -> DeploymentInsertCall<'a, C>
2157    where
2158        St: AsRef<str>,
2159    {
2160        self._scopes.insert(String::from(scope.as_ref()));
2161        self
2162    }
2163    /// Identifies the authorization scope(s) for the method you are building.
2164    ///
2165    /// See [`Self::add_scope()`] for details.
2166    pub fn add_scopes<I, St>(mut self, scopes: I) -> DeploymentInsertCall<'a, C>
2167    where
2168        I: IntoIterator<Item = St>,
2169        St: AsRef<str>,
2170    {
2171        self._scopes
2172            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2173        self
2174    }
2175
2176    /// Removes all scopes, and no default scope will be used either.
2177    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2178    /// for details).
2179    pub fn clear_scopes(mut self) -> DeploymentInsertCall<'a, C> {
2180        self._scopes.clear();
2181        self
2182    }
2183}
2184
2185///
2186///
2187/// A builder for the *list* method supported by a *deployment* resource.
2188/// It is not used directly, but through a [`DeploymentMethods`] instance.
2189///
2190/// # Example
2191///
2192/// Instantiate a resource method builder
2193///
2194/// ```test_harness,no_run
2195/// # extern crate hyper;
2196/// # extern crate hyper_rustls;
2197/// # extern crate google_manager1_beta2 as manager1_beta2;
2198/// # async fn dox() {
2199/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2200///
2201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2203/// #     secret,
2204/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2205/// # ).build().await.unwrap();
2206///
2207/// # let client = hyper_util::client::legacy::Client::builder(
2208/// #     hyper_util::rt::TokioExecutor::new()
2209/// # )
2210/// # .build(
2211/// #     hyper_rustls::HttpsConnectorBuilder::new()
2212/// #         .with_native_roots()
2213/// #         .unwrap()
2214/// #         .https_or_http()
2215/// #         .enable_http1()
2216/// #         .build()
2217/// # );
2218/// # let mut hub = Manager::new(client, auth);
2219/// // You can configure optional parameters by calling the respective setters at will, and
2220/// // execute the final call using `doit()`.
2221/// // Values shown here are possibly random and not representative !
2222/// let result = hub.deployments().list("projectId", "region")
2223///              .page_token("duo")
2224///              .max_results(-50)
2225///              .doit().await;
2226/// # }
2227/// ```
2228pub struct DeploymentListCall<'a, C>
2229where
2230    C: 'a,
2231{
2232    hub: &'a Manager<C>,
2233    _project_id: String,
2234    _region: String,
2235    _page_token: Option<String>,
2236    _max_results: Option<i32>,
2237    _delegate: Option<&'a mut dyn common::Delegate>,
2238    _additional_params: HashMap<String, String>,
2239    _scopes: BTreeSet<String>,
2240}
2241
2242impl<'a, C> common::CallBuilder for DeploymentListCall<'a, C> {}
2243
2244impl<'a, C> DeploymentListCall<'a, C>
2245where
2246    C: common::Connector,
2247{
2248    /// Perform the operation you have build so far.
2249    pub async fn doit(mut self) -> common::Result<(common::Response, DeploymentsListResponse)> {
2250        use std::borrow::Cow;
2251        use std::io::{Read, Seek};
2252
2253        use common::{url::Params, ToParts};
2254        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2255
2256        let mut dd = common::DefaultDelegate;
2257        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2258        dlg.begin(common::MethodInfo {
2259            id: "manager.deployments.list",
2260            http_method: hyper::Method::GET,
2261        });
2262
2263        for &field in ["alt", "projectId", "region", "pageToken", "maxResults"].iter() {
2264            if self._additional_params.contains_key(field) {
2265                dlg.finished(false);
2266                return Err(common::Error::FieldClash(field));
2267            }
2268        }
2269
2270        let mut params = Params::with_capacity(6 + self._additional_params.len());
2271        params.push("projectId", self._project_id);
2272        params.push("region", self._region);
2273        if let Some(value) = self._page_token.as_ref() {
2274            params.push("pageToken", value);
2275        }
2276        if let Some(value) = self._max_results.as_ref() {
2277            params.push("maxResults", value.to_string());
2278        }
2279
2280        params.extend(self._additional_params.iter());
2281
2282        params.push("alt", "json");
2283        let mut url = self.hub._base_url.clone() + "{projectId}/regions/{region}/deployments";
2284        if self._scopes.is_empty() {
2285            self._scopes
2286                .insert(Scope::NdevCloudmanReadonly.as_ref().to_string());
2287        }
2288
2289        #[allow(clippy::single_element_loop)]
2290        for &(find_this, param_name) in
2291            [("{projectId}", "projectId"), ("{region}", "region")].iter()
2292        {
2293            url = params.uri_replacement(url, param_name, find_this, false);
2294        }
2295        {
2296            let to_remove = ["region", "projectId"];
2297            params.remove_params(&to_remove);
2298        }
2299
2300        let url = params.parse_with_url(&url);
2301
2302        loop {
2303            let token = match self
2304                .hub
2305                .auth
2306                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2307                .await
2308            {
2309                Ok(token) => token,
2310                Err(e) => match dlg.token(e) {
2311                    Ok(token) => token,
2312                    Err(e) => {
2313                        dlg.finished(false);
2314                        return Err(common::Error::MissingToken(e));
2315                    }
2316                },
2317            };
2318            let mut req_result = {
2319                let client = &self.hub.client;
2320                dlg.pre_request();
2321                let mut req_builder = hyper::Request::builder()
2322                    .method(hyper::Method::GET)
2323                    .uri(url.as_str())
2324                    .header(USER_AGENT, self.hub._user_agent.clone());
2325
2326                if let Some(token) = token.as_ref() {
2327                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2328                }
2329
2330                let request = req_builder
2331                    .header(CONTENT_LENGTH, 0_u64)
2332                    .body(common::to_body::<String>(None));
2333
2334                client.request(request.unwrap()).await
2335            };
2336
2337            match req_result {
2338                Err(err) => {
2339                    if let common::Retry::After(d) = dlg.http_error(&err) {
2340                        sleep(d).await;
2341                        continue;
2342                    }
2343                    dlg.finished(false);
2344                    return Err(common::Error::HttpError(err));
2345                }
2346                Ok(res) => {
2347                    let (mut parts, body) = res.into_parts();
2348                    let mut body = common::Body::new(body);
2349                    if !parts.status.is_success() {
2350                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2351                        let error = serde_json::from_str(&common::to_string(&bytes));
2352                        let response = common::to_response(parts, bytes.into());
2353
2354                        if let common::Retry::After(d) =
2355                            dlg.http_failure(&response, error.as_ref().ok())
2356                        {
2357                            sleep(d).await;
2358                            continue;
2359                        }
2360
2361                        dlg.finished(false);
2362
2363                        return Err(match error {
2364                            Ok(value) => common::Error::BadRequest(value),
2365                            _ => common::Error::Failure(response),
2366                        });
2367                    }
2368                    let response = {
2369                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2370                        let encoded = common::to_string(&bytes);
2371                        match serde_json::from_str(&encoded) {
2372                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2373                            Err(error) => {
2374                                dlg.response_json_decode_error(&encoded, &error);
2375                                return Err(common::Error::JsonDecodeError(
2376                                    encoded.to_string(),
2377                                    error,
2378                                ));
2379                            }
2380                        }
2381                    };
2382
2383                    dlg.finished(true);
2384                    return Ok(response);
2385                }
2386            }
2387        }
2388    }
2389
2390    ///
2391    /// Sets the *project id* path property to the given value.
2392    ///
2393    /// Even though the property as already been set when instantiating this call,
2394    /// we provide this method for API completeness.
2395    pub fn project_id(mut self, new_value: &str) -> DeploymentListCall<'a, C> {
2396        self._project_id = new_value.to_string();
2397        self
2398    }
2399    ///
2400    /// Sets the *region* path property to the given value.
2401    ///
2402    /// Even though the property as already been set when instantiating this call,
2403    /// we provide this method for API completeness.
2404    pub fn region(mut self, new_value: &str) -> DeploymentListCall<'a, C> {
2405        self._region = new_value.to_string();
2406        self
2407    }
2408    /// Specifies a nextPageToken returned by a previous list request. This token can be used to request the next page of results from a previous list request.
2409    ///
2410    /// Sets the *page token* query property to the given value.
2411    pub fn page_token(mut self, new_value: &str) -> DeploymentListCall<'a, C> {
2412        self._page_token = Some(new_value.to_string());
2413        self
2414    }
2415    /// Maximum count of results to be returned. Acceptable values are 0 to 100, inclusive. (Default: 50)
2416    ///
2417    /// Sets the *max results* query property to the given value.
2418    pub fn max_results(mut self, new_value: i32) -> DeploymentListCall<'a, C> {
2419        self._max_results = Some(new_value);
2420        self
2421    }
2422    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2423    /// while executing the actual API request.
2424    ///
2425    /// ````text
2426    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2427    /// ````
2428    ///
2429    /// Sets the *delegate* property to the given value.
2430    pub fn delegate(
2431        mut self,
2432        new_value: &'a mut dyn common::Delegate,
2433    ) -> DeploymentListCall<'a, C> {
2434        self._delegate = Some(new_value);
2435        self
2436    }
2437
2438    /// Set any additional parameter of the query string used in the request.
2439    /// It should be used to set parameters which are not yet available through their own
2440    /// setters.
2441    ///
2442    /// Please note that this method must not be used to set any of the known parameters
2443    /// which have their own setter method. If done anyway, the request will fail.
2444    ///
2445    /// # Additional Parameters
2446    ///
2447    /// * *alt* (query-string) - Data format for the response.
2448    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2449    /// * *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.
2450    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2451    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2452    /// * *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. Overrides userIp if both are provided.
2453    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2454    pub fn param<T>(mut self, name: T, value: T) -> DeploymentListCall<'a, C>
2455    where
2456        T: AsRef<str>,
2457    {
2458        self._additional_params
2459            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2460        self
2461    }
2462
2463    /// Identifies the authorization scope for the method you are building.
2464    ///
2465    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2466    /// [`Scope::NdevCloudmanReadonly`].
2467    ///
2468    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2469    /// tokens for more than one scope.
2470    ///
2471    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2472    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2473    /// sufficient, a read-write scope will do as well.
2474    pub fn add_scope<St>(mut self, scope: St) -> DeploymentListCall<'a, C>
2475    where
2476        St: AsRef<str>,
2477    {
2478        self._scopes.insert(String::from(scope.as_ref()));
2479        self
2480    }
2481    /// Identifies the authorization scope(s) for the method you are building.
2482    ///
2483    /// See [`Self::add_scope()`] for details.
2484    pub fn add_scopes<I, St>(mut self, scopes: I) -> DeploymentListCall<'a, C>
2485    where
2486        I: IntoIterator<Item = St>,
2487        St: AsRef<str>,
2488    {
2489        self._scopes
2490            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2491        self
2492    }
2493
2494    /// Removes all scopes, and no default scope will be used either.
2495    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2496    /// for details).
2497    pub fn clear_scopes(mut self) -> DeploymentListCall<'a, C> {
2498        self._scopes.clear();
2499        self
2500    }
2501}
2502
2503///
2504///
2505/// A builder for the *delete* method supported by a *template* resource.
2506/// It is not used directly, but through a [`TemplateMethods`] instance.
2507///
2508/// # Example
2509///
2510/// Instantiate a resource method builder
2511///
2512/// ```test_harness,no_run
2513/// # extern crate hyper;
2514/// # extern crate hyper_rustls;
2515/// # extern crate google_manager1_beta2 as manager1_beta2;
2516/// # async fn dox() {
2517/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2518///
2519/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2520/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2521/// #     secret,
2522/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2523/// # ).build().await.unwrap();
2524///
2525/// # let client = hyper_util::client::legacy::Client::builder(
2526/// #     hyper_util::rt::TokioExecutor::new()
2527/// # )
2528/// # .build(
2529/// #     hyper_rustls::HttpsConnectorBuilder::new()
2530/// #         .with_native_roots()
2531/// #         .unwrap()
2532/// #         .https_or_http()
2533/// #         .enable_http1()
2534/// #         .build()
2535/// # );
2536/// # let mut hub = Manager::new(client, auth);
2537/// // You can configure optional parameters by calling the respective setters at will, and
2538/// // execute the final call using `doit()`.
2539/// // Values shown here are possibly random and not representative !
2540/// let result = hub.templates().delete("projectId", "templateName")
2541///              .doit().await;
2542/// # }
2543/// ```
2544pub struct TemplateDeleteCall<'a, C>
2545where
2546    C: 'a,
2547{
2548    hub: &'a Manager<C>,
2549    _project_id: String,
2550    _template_name: String,
2551    _delegate: Option<&'a mut dyn common::Delegate>,
2552    _additional_params: HashMap<String, String>,
2553    _scopes: BTreeSet<String>,
2554}
2555
2556impl<'a, C> common::CallBuilder for TemplateDeleteCall<'a, C> {}
2557
2558impl<'a, C> TemplateDeleteCall<'a, C>
2559where
2560    C: common::Connector,
2561{
2562    /// Perform the operation you have build so far.
2563    pub async fn doit(mut self) -> common::Result<common::Response> {
2564        use std::borrow::Cow;
2565        use std::io::{Read, Seek};
2566
2567        use common::{url::Params, ToParts};
2568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2569
2570        let mut dd = common::DefaultDelegate;
2571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2572        dlg.begin(common::MethodInfo {
2573            id: "manager.templates.delete",
2574            http_method: hyper::Method::DELETE,
2575        });
2576
2577        for &field in ["projectId", "templateName"].iter() {
2578            if self._additional_params.contains_key(field) {
2579                dlg.finished(false);
2580                return Err(common::Error::FieldClash(field));
2581            }
2582        }
2583
2584        let mut params = Params::with_capacity(3 + self._additional_params.len());
2585        params.push("projectId", self._project_id);
2586        params.push("templateName", self._template_name);
2587
2588        params.extend(self._additional_params.iter());
2589
2590        let mut url = self.hub._base_url.clone() + "{projectId}/templates/{templateName}";
2591        if self._scopes.is_empty() {
2592            self._scopes
2593                .insert(Scope::CloudPlatform.as_ref().to_string());
2594        }
2595
2596        #[allow(clippy::single_element_loop)]
2597        for &(find_this, param_name) in [
2598            ("{projectId}", "projectId"),
2599            ("{templateName}", "templateName"),
2600        ]
2601        .iter()
2602        {
2603            url = params.uri_replacement(url, param_name, find_this, false);
2604        }
2605        {
2606            let to_remove = ["templateName", "projectId"];
2607            params.remove_params(&to_remove);
2608        }
2609
2610        let url = params.parse_with_url(&url);
2611
2612        loop {
2613            let token = match self
2614                .hub
2615                .auth
2616                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2617                .await
2618            {
2619                Ok(token) => token,
2620                Err(e) => match dlg.token(e) {
2621                    Ok(token) => token,
2622                    Err(e) => {
2623                        dlg.finished(false);
2624                        return Err(common::Error::MissingToken(e));
2625                    }
2626                },
2627            };
2628            let mut req_result = {
2629                let client = &self.hub.client;
2630                dlg.pre_request();
2631                let mut req_builder = hyper::Request::builder()
2632                    .method(hyper::Method::DELETE)
2633                    .uri(url.as_str())
2634                    .header(USER_AGENT, self.hub._user_agent.clone());
2635
2636                if let Some(token) = token.as_ref() {
2637                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2638                }
2639
2640                let request = req_builder
2641                    .header(CONTENT_LENGTH, 0_u64)
2642                    .body(common::to_body::<String>(None));
2643
2644                client.request(request.unwrap()).await
2645            };
2646
2647            match req_result {
2648                Err(err) => {
2649                    if let common::Retry::After(d) = dlg.http_error(&err) {
2650                        sleep(d).await;
2651                        continue;
2652                    }
2653                    dlg.finished(false);
2654                    return Err(common::Error::HttpError(err));
2655                }
2656                Ok(res) => {
2657                    let (mut parts, body) = res.into_parts();
2658                    let mut body = common::Body::new(body);
2659                    if !parts.status.is_success() {
2660                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2661                        let error = serde_json::from_str(&common::to_string(&bytes));
2662                        let response = common::to_response(parts, bytes.into());
2663
2664                        if let common::Retry::After(d) =
2665                            dlg.http_failure(&response, error.as_ref().ok())
2666                        {
2667                            sleep(d).await;
2668                            continue;
2669                        }
2670
2671                        dlg.finished(false);
2672
2673                        return Err(match error {
2674                            Ok(value) => common::Error::BadRequest(value),
2675                            _ => common::Error::Failure(response),
2676                        });
2677                    }
2678                    let response = common::Response::from_parts(parts, body);
2679
2680                    dlg.finished(true);
2681                    return Ok(response);
2682                }
2683            }
2684        }
2685    }
2686
2687    ///
2688    /// Sets the *project id* path property to the given value.
2689    ///
2690    /// Even though the property as already been set when instantiating this call,
2691    /// we provide this method for API completeness.
2692    pub fn project_id(mut self, new_value: &str) -> TemplateDeleteCall<'a, C> {
2693        self._project_id = new_value.to_string();
2694        self
2695    }
2696    ///
2697    /// Sets the *template name* path property to the given value.
2698    ///
2699    /// Even though the property as already been set when instantiating this call,
2700    /// we provide this method for API completeness.
2701    pub fn template_name(mut self, new_value: &str) -> TemplateDeleteCall<'a, C> {
2702        self._template_name = new_value.to_string();
2703        self
2704    }
2705    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2706    /// while executing the actual API request.
2707    ///
2708    /// ````text
2709    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2710    /// ````
2711    ///
2712    /// Sets the *delegate* property to the given value.
2713    pub fn delegate(
2714        mut self,
2715        new_value: &'a mut dyn common::Delegate,
2716    ) -> TemplateDeleteCall<'a, C> {
2717        self._delegate = Some(new_value);
2718        self
2719    }
2720
2721    /// Set any additional parameter of the query string used in the request.
2722    /// It should be used to set parameters which are not yet available through their own
2723    /// setters.
2724    ///
2725    /// Please note that this method must not be used to set any of the known parameters
2726    /// which have their own setter method. If done anyway, the request will fail.
2727    ///
2728    /// # Additional Parameters
2729    ///
2730    /// * *alt* (query-string) - Data format for the response.
2731    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2732    /// * *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.
2733    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2734    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2735    /// * *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. Overrides userIp if both are provided.
2736    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2737    pub fn param<T>(mut self, name: T, value: T) -> TemplateDeleteCall<'a, C>
2738    where
2739        T: AsRef<str>,
2740    {
2741        self._additional_params
2742            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2743        self
2744    }
2745
2746    /// Identifies the authorization scope for the method you are building.
2747    ///
2748    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2749    /// [`Scope::CloudPlatform`].
2750    ///
2751    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2752    /// tokens for more than one scope.
2753    ///
2754    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2755    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2756    /// sufficient, a read-write scope will do as well.
2757    pub fn add_scope<St>(mut self, scope: St) -> TemplateDeleteCall<'a, C>
2758    where
2759        St: AsRef<str>,
2760    {
2761        self._scopes.insert(String::from(scope.as_ref()));
2762        self
2763    }
2764    /// Identifies the authorization scope(s) for the method you are building.
2765    ///
2766    /// See [`Self::add_scope()`] for details.
2767    pub fn add_scopes<I, St>(mut self, scopes: I) -> TemplateDeleteCall<'a, C>
2768    where
2769        I: IntoIterator<Item = St>,
2770        St: AsRef<str>,
2771    {
2772        self._scopes
2773            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2774        self
2775    }
2776
2777    /// Removes all scopes, and no default scope will be used either.
2778    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2779    /// for details).
2780    pub fn clear_scopes(mut self) -> TemplateDeleteCall<'a, C> {
2781        self._scopes.clear();
2782        self
2783    }
2784}
2785
2786///
2787///
2788/// A builder for the *get* method supported by a *template* resource.
2789/// It is not used directly, but through a [`TemplateMethods`] instance.
2790///
2791/// # Example
2792///
2793/// Instantiate a resource method builder
2794///
2795/// ```test_harness,no_run
2796/// # extern crate hyper;
2797/// # extern crate hyper_rustls;
2798/// # extern crate google_manager1_beta2 as manager1_beta2;
2799/// # async fn dox() {
2800/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2801///
2802/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2804/// #     secret,
2805/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2806/// # ).build().await.unwrap();
2807///
2808/// # let client = hyper_util::client::legacy::Client::builder(
2809/// #     hyper_util::rt::TokioExecutor::new()
2810/// # )
2811/// # .build(
2812/// #     hyper_rustls::HttpsConnectorBuilder::new()
2813/// #         .with_native_roots()
2814/// #         .unwrap()
2815/// #         .https_or_http()
2816/// #         .enable_http1()
2817/// #         .build()
2818/// # );
2819/// # let mut hub = Manager::new(client, auth);
2820/// // You can configure optional parameters by calling the respective setters at will, and
2821/// // execute the final call using `doit()`.
2822/// // Values shown here are possibly random and not representative !
2823/// let result = hub.templates().get("projectId", "templateName")
2824///              .doit().await;
2825/// # }
2826/// ```
2827pub struct TemplateGetCall<'a, C>
2828where
2829    C: 'a,
2830{
2831    hub: &'a Manager<C>,
2832    _project_id: String,
2833    _template_name: String,
2834    _delegate: Option<&'a mut dyn common::Delegate>,
2835    _additional_params: HashMap<String, String>,
2836    _scopes: BTreeSet<String>,
2837}
2838
2839impl<'a, C> common::CallBuilder for TemplateGetCall<'a, C> {}
2840
2841impl<'a, C> TemplateGetCall<'a, C>
2842where
2843    C: common::Connector,
2844{
2845    /// Perform the operation you have build so far.
2846    pub async fn doit(mut self) -> common::Result<(common::Response, Template)> {
2847        use std::borrow::Cow;
2848        use std::io::{Read, Seek};
2849
2850        use common::{url::Params, ToParts};
2851        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2852
2853        let mut dd = common::DefaultDelegate;
2854        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2855        dlg.begin(common::MethodInfo {
2856            id: "manager.templates.get",
2857            http_method: hyper::Method::GET,
2858        });
2859
2860        for &field in ["alt", "projectId", "templateName"].iter() {
2861            if self._additional_params.contains_key(field) {
2862                dlg.finished(false);
2863                return Err(common::Error::FieldClash(field));
2864            }
2865        }
2866
2867        let mut params = Params::with_capacity(4 + self._additional_params.len());
2868        params.push("projectId", self._project_id);
2869        params.push("templateName", self._template_name);
2870
2871        params.extend(self._additional_params.iter());
2872
2873        params.push("alt", "json");
2874        let mut url = self.hub._base_url.clone() + "{projectId}/templates/{templateName}";
2875        if self._scopes.is_empty() {
2876            self._scopes
2877                .insert(Scope::NdevCloudmanReadonly.as_ref().to_string());
2878        }
2879
2880        #[allow(clippy::single_element_loop)]
2881        for &(find_this, param_name) in [
2882            ("{projectId}", "projectId"),
2883            ("{templateName}", "templateName"),
2884        ]
2885        .iter()
2886        {
2887            url = params.uri_replacement(url, param_name, find_this, false);
2888        }
2889        {
2890            let to_remove = ["templateName", "projectId"];
2891            params.remove_params(&to_remove);
2892        }
2893
2894        let url = params.parse_with_url(&url);
2895
2896        loop {
2897            let token = match self
2898                .hub
2899                .auth
2900                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2901                .await
2902            {
2903                Ok(token) => token,
2904                Err(e) => match dlg.token(e) {
2905                    Ok(token) => token,
2906                    Err(e) => {
2907                        dlg.finished(false);
2908                        return Err(common::Error::MissingToken(e));
2909                    }
2910                },
2911            };
2912            let mut req_result = {
2913                let client = &self.hub.client;
2914                dlg.pre_request();
2915                let mut req_builder = hyper::Request::builder()
2916                    .method(hyper::Method::GET)
2917                    .uri(url.as_str())
2918                    .header(USER_AGENT, self.hub._user_agent.clone());
2919
2920                if let Some(token) = token.as_ref() {
2921                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2922                }
2923
2924                let request = req_builder
2925                    .header(CONTENT_LENGTH, 0_u64)
2926                    .body(common::to_body::<String>(None));
2927
2928                client.request(request.unwrap()).await
2929            };
2930
2931            match req_result {
2932                Err(err) => {
2933                    if let common::Retry::After(d) = dlg.http_error(&err) {
2934                        sleep(d).await;
2935                        continue;
2936                    }
2937                    dlg.finished(false);
2938                    return Err(common::Error::HttpError(err));
2939                }
2940                Ok(res) => {
2941                    let (mut parts, body) = res.into_parts();
2942                    let mut body = common::Body::new(body);
2943                    if !parts.status.is_success() {
2944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2945                        let error = serde_json::from_str(&common::to_string(&bytes));
2946                        let response = common::to_response(parts, bytes.into());
2947
2948                        if let common::Retry::After(d) =
2949                            dlg.http_failure(&response, error.as_ref().ok())
2950                        {
2951                            sleep(d).await;
2952                            continue;
2953                        }
2954
2955                        dlg.finished(false);
2956
2957                        return Err(match error {
2958                            Ok(value) => common::Error::BadRequest(value),
2959                            _ => common::Error::Failure(response),
2960                        });
2961                    }
2962                    let response = {
2963                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2964                        let encoded = common::to_string(&bytes);
2965                        match serde_json::from_str(&encoded) {
2966                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2967                            Err(error) => {
2968                                dlg.response_json_decode_error(&encoded, &error);
2969                                return Err(common::Error::JsonDecodeError(
2970                                    encoded.to_string(),
2971                                    error,
2972                                ));
2973                            }
2974                        }
2975                    };
2976
2977                    dlg.finished(true);
2978                    return Ok(response);
2979                }
2980            }
2981        }
2982    }
2983
2984    ///
2985    /// Sets the *project id* path property to the given value.
2986    ///
2987    /// Even though the property as already been set when instantiating this call,
2988    /// we provide this method for API completeness.
2989    pub fn project_id(mut self, new_value: &str) -> TemplateGetCall<'a, C> {
2990        self._project_id = new_value.to_string();
2991        self
2992    }
2993    ///
2994    /// Sets the *template name* path property to the given value.
2995    ///
2996    /// Even though the property as already been set when instantiating this call,
2997    /// we provide this method for API completeness.
2998    pub fn template_name(mut self, new_value: &str) -> TemplateGetCall<'a, C> {
2999        self._template_name = new_value.to_string();
3000        self
3001    }
3002    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3003    /// while executing the actual API request.
3004    ///
3005    /// ````text
3006    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3007    /// ````
3008    ///
3009    /// Sets the *delegate* property to the given value.
3010    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TemplateGetCall<'a, C> {
3011        self._delegate = Some(new_value);
3012        self
3013    }
3014
3015    /// Set any additional parameter of the query string used in the request.
3016    /// It should be used to set parameters which are not yet available through their own
3017    /// setters.
3018    ///
3019    /// Please note that this method must not be used to set any of the known parameters
3020    /// which have their own setter method. If done anyway, the request will fail.
3021    ///
3022    /// # Additional Parameters
3023    ///
3024    /// * *alt* (query-string) - Data format for the response.
3025    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3026    /// * *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.
3027    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3028    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3029    /// * *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. Overrides userIp if both are provided.
3030    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3031    pub fn param<T>(mut self, name: T, value: T) -> TemplateGetCall<'a, C>
3032    where
3033        T: AsRef<str>,
3034    {
3035        self._additional_params
3036            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3037        self
3038    }
3039
3040    /// Identifies the authorization scope for the method you are building.
3041    ///
3042    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3043    /// [`Scope::NdevCloudmanReadonly`].
3044    ///
3045    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3046    /// tokens for more than one scope.
3047    ///
3048    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3049    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3050    /// sufficient, a read-write scope will do as well.
3051    pub fn add_scope<St>(mut self, scope: St) -> TemplateGetCall<'a, C>
3052    where
3053        St: AsRef<str>,
3054    {
3055        self._scopes.insert(String::from(scope.as_ref()));
3056        self
3057    }
3058    /// Identifies the authorization scope(s) for the method you are building.
3059    ///
3060    /// See [`Self::add_scope()`] for details.
3061    pub fn add_scopes<I, St>(mut self, scopes: I) -> TemplateGetCall<'a, C>
3062    where
3063        I: IntoIterator<Item = St>,
3064        St: AsRef<str>,
3065    {
3066        self._scopes
3067            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3068        self
3069    }
3070
3071    /// Removes all scopes, and no default scope will be used either.
3072    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3073    /// for details).
3074    pub fn clear_scopes(mut self) -> TemplateGetCall<'a, C> {
3075        self._scopes.clear();
3076        self
3077    }
3078}
3079
3080///
3081///
3082/// A builder for the *insert* method supported by a *template* resource.
3083/// It is not used directly, but through a [`TemplateMethods`] instance.
3084///
3085/// # Example
3086///
3087/// Instantiate a resource method builder
3088///
3089/// ```test_harness,no_run
3090/// # extern crate hyper;
3091/// # extern crate hyper_rustls;
3092/// # extern crate google_manager1_beta2 as manager1_beta2;
3093/// use manager1_beta2::api::Template;
3094/// # async fn dox() {
3095/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3096///
3097/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3098/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3099/// #     secret,
3100/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3101/// # ).build().await.unwrap();
3102///
3103/// # let client = hyper_util::client::legacy::Client::builder(
3104/// #     hyper_util::rt::TokioExecutor::new()
3105/// # )
3106/// # .build(
3107/// #     hyper_rustls::HttpsConnectorBuilder::new()
3108/// #         .with_native_roots()
3109/// #         .unwrap()
3110/// #         .https_or_http()
3111/// #         .enable_http1()
3112/// #         .build()
3113/// # );
3114/// # let mut hub = Manager::new(client, auth);
3115/// // As the method needs a request, you would usually fill it with the desired information
3116/// // into the respective structure. Some of the parts shown here might not be applicable !
3117/// // Values shown here are possibly random and not representative !
3118/// let mut req = Template::default();
3119///
3120/// // You can configure optional parameters by calling the respective setters at will, and
3121/// // execute the final call using `doit()`.
3122/// // Values shown here are possibly random and not representative !
3123/// let result = hub.templates().insert(req, "projectId")
3124///              .doit().await;
3125/// # }
3126/// ```
3127pub struct TemplateInsertCall<'a, C>
3128where
3129    C: 'a,
3130{
3131    hub: &'a Manager<C>,
3132    _request: Template,
3133    _project_id: String,
3134    _delegate: Option<&'a mut dyn common::Delegate>,
3135    _additional_params: HashMap<String, String>,
3136    _scopes: BTreeSet<String>,
3137}
3138
3139impl<'a, C> common::CallBuilder for TemplateInsertCall<'a, C> {}
3140
3141impl<'a, C> TemplateInsertCall<'a, C>
3142where
3143    C: common::Connector,
3144{
3145    /// Perform the operation you have build so far.
3146    pub async fn doit(mut self) -> common::Result<(common::Response, Template)> {
3147        use std::borrow::Cow;
3148        use std::io::{Read, Seek};
3149
3150        use common::{url::Params, ToParts};
3151        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3152
3153        let mut dd = common::DefaultDelegate;
3154        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3155        dlg.begin(common::MethodInfo {
3156            id: "manager.templates.insert",
3157            http_method: hyper::Method::POST,
3158        });
3159
3160        for &field in ["alt", "projectId"].iter() {
3161            if self._additional_params.contains_key(field) {
3162                dlg.finished(false);
3163                return Err(common::Error::FieldClash(field));
3164            }
3165        }
3166
3167        let mut params = Params::with_capacity(4 + self._additional_params.len());
3168        params.push("projectId", self._project_id);
3169
3170        params.extend(self._additional_params.iter());
3171
3172        params.push("alt", "json");
3173        let mut url = self.hub._base_url.clone() + "{projectId}/templates";
3174        if self._scopes.is_empty() {
3175            self._scopes
3176                .insert(Scope::CloudPlatform.as_ref().to_string());
3177        }
3178
3179        #[allow(clippy::single_element_loop)]
3180        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
3181            url = params.uri_replacement(url, param_name, find_this, false);
3182        }
3183        {
3184            let to_remove = ["projectId"];
3185            params.remove_params(&to_remove);
3186        }
3187
3188        let url = params.parse_with_url(&url);
3189
3190        let mut json_mime_type = mime::APPLICATION_JSON;
3191        let mut request_value_reader = {
3192            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3193            common::remove_json_null_values(&mut value);
3194            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3195            serde_json::to_writer(&mut dst, &value).unwrap();
3196            dst
3197        };
3198        let request_size = request_value_reader
3199            .seek(std::io::SeekFrom::End(0))
3200            .unwrap();
3201        request_value_reader
3202            .seek(std::io::SeekFrom::Start(0))
3203            .unwrap();
3204
3205        loop {
3206            let token = match self
3207                .hub
3208                .auth
3209                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3210                .await
3211            {
3212                Ok(token) => token,
3213                Err(e) => match dlg.token(e) {
3214                    Ok(token) => token,
3215                    Err(e) => {
3216                        dlg.finished(false);
3217                        return Err(common::Error::MissingToken(e));
3218                    }
3219                },
3220            };
3221            request_value_reader
3222                .seek(std::io::SeekFrom::Start(0))
3223                .unwrap();
3224            let mut req_result = {
3225                let client = &self.hub.client;
3226                dlg.pre_request();
3227                let mut req_builder = hyper::Request::builder()
3228                    .method(hyper::Method::POST)
3229                    .uri(url.as_str())
3230                    .header(USER_AGENT, self.hub._user_agent.clone());
3231
3232                if let Some(token) = token.as_ref() {
3233                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3234                }
3235
3236                let request = req_builder
3237                    .header(CONTENT_TYPE, json_mime_type.to_string())
3238                    .header(CONTENT_LENGTH, request_size as u64)
3239                    .body(common::to_body(
3240                        request_value_reader.get_ref().clone().into(),
3241                    ));
3242
3243                client.request(request.unwrap()).await
3244            };
3245
3246            match req_result {
3247                Err(err) => {
3248                    if let common::Retry::After(d) = dlg.http_error(&err) {
3249                        sleep(d).await;
3250                        continue;
3251                    }
3252                    dlg.finished(false);
3253                    return Err(common::Error::HttpError(err));
3254                }
3255                Ok(res) => {
3256                    let (mut parts, body) = res.into_parts();
3257                    let mut body = common::Body::new(body);
3258                    if !parts.status.is_success() {
3259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3260                        let error = serde_json::from_str(&common::to_string(&bytes));
3261                        let response = common::to_response(parts, bytes.into());
3262
3263                        if let common::Retry::After(d) =
3264                            dlg.http_failure(&response, error.as_ref().ok())
3265                        {
3266                            sleep(d).await;
3267                            continue;
3268                        }
3269
3270                        dlg.finished(false);
3271
3272                        return Err(match error {
3273                            Ok(value) => common::Error::BadRequest(value),
3274                            _ => common::Error::Failure(response),
3275                        });
3276                    }
3277                    let response = {
3278                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3279                        let encoded = common::to_string(&bytes);
3280                        match serde_json::from_str(&encoded) {
3281                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3282                            Err(error) => {
3283                                dlg.response_json_decode_error(&encoded, &error);
3284                                return Err(common::Error::JsonDecodeError(
3285                                    encoded.to_string(),
3286                                    error,
3287                                ));
3288                            }
3289                        }
3290                    };
3291
3292                    dlg.finished(true);
3293                    return Ok(response);
3294                }
3295            }
3296        }
3297    }
3298
3299    ///
3300    /// Sets the *request* property to the given value.
3301    ///
3302    /// Even though the property as already been set when instantiating this call,
3303    /// we provide this method for API completeness.
3304    pub fn request(mut self, new_value: Template) -> TemplateInsertCall<'a, C> {
3305        self._request = new_value;
3306        self
3307    }
3308    ///
3309    /// Sets the *project id* path property to the given value.
3310    ///
3311    /// Even though the property as already been set when instantiating this call,
3312    /// we provide this method for API completeness.
3313    pub fn project_id(mut self, new_value: &str) -> TemplateInsertCall<'a, C> {
3314        self._project_id = new_value.to_string();
3315        self
3316    }
3317    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3318    /// while executing the actual API request.
3319    ///
3320    /// ````text
3321    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3322    /// ````
3323    ///
3324    /// Sets the *delegate* property to the given value.
3325    pub fn delegate(
3326        mut self,
3327        new_value: &'a mut dyn common::Delegate,
3328    ) -> TemplateInsertCall<'a, C> {
3329        self._delegate = Some(new_value);
3330        self
3331    }
3332
3333    /// Set any additional parameter of the query string used in the request.
3334    /// It should be used to set parameters which are not yet available through their own
3335    /// setters.
3336    ///
3337    /// Please note that this method must not be used to set any of the known parameters
3338    /// which have their own setter method. If done anyway, the request will fail.
3339    ///
3340    /// # Additional Parameters
3341    ///
3342    /// * *alt* (query-string) - Data format for the response.
3343    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3344    /// * *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.
3345    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3346    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3347    /// * *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. Overrides userIp if both are provided.
3348    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3349    pub fn param<T>(mut self, name: T, value: T) -> TemplateInsertCall<'a, C>
3350    where
3351        T: AsRef<str>,
3352    {
3353        self._additional_params
3354            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3355        self
3356    }
3357
3358    /// Identifies the authorization scope for the method you are building.
3359    ///
3360    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3361    /// [`Scope::CloudPlatform`].
3362    ///
3363    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3364    /// tokens for more than one scope.
3365    ///
3366    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3367    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3368    /// sufficient, a read-write scope will do as well.
3369    pub fn add_scope<St>(mut self, scope: St) -> TemplateInsertCall<'a, C>
3370    where
3371        St: AsRef<str>,
3372    {
3373        self._scopes.insert(String::from(scope.as_ref()));
3374        self
3375    }
3376    /// Identifies the authorization scope(s) for the method you are building.
3377    ///
3378    /// See [`Self::add_scope()`] for details.
3379    pub fn add_scopes<I, St>(mut self, scopes: I) -> TemplateInsertCall<'a, C>
3380    where
3381        I: IntoIterator<Item = St>,
3382        St: AsRef<str>,
3383    {
3384        self._scopes
3385            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3386        self
3387    }
3388
3389    /// Removes all scopes, and no default scope will be used either.
3390    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3391    /// for details).
3392    pub fn clear_scopes(mut self) -> TemplateInsertCall<'a, C> {
3393        self._scopes.clear();
3394        self
3395    }
3396}
3397
3398///
3399///
3400/// A builder for the *list* method supported by a *template* resource.
3401/// It is not used directly, but through a [`TemplateMethods`] instance.
3402///
3403/// # Example
3404///
3405/// Instantiate a resource method builder
3406///
3407/// ```test_harness,no_run
3408/// # extern crate hyper;
3409/// # extern crate hyper_rustls;
3410/// # extern crate google_manager1_beta2 as manager1_beta2;
3411/// # async fn dox() {
3412/// # use manager1_beta2::{Manager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3413///
3414/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3415/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3416/// #     secret,
3417/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3418/// # ).build().await.unwrap();
3419///
3420/// # let client = hyper_util::client::legacy::Client::builder(
3421/// #     hyper_util::rt::TokioExecutor::new()
3422/// # )
3423/// # .build(
3424/// #     hyper_rustls::HttpsConnectorBuilder::new()
3425/// #         .with_native_roots()
3426/// #         .unwrap()
3427/// #         .https_or_http()
3428/// #         .enable_http1()
3429/// #         .build()
3430/// # );
3431/// # let mut hub = Manager::new(client, auth);
3432/// // You can configure optional parameters by calling the respective setters at will, and
3433/// // execute the final call using `doit()`.
3434/// // Values shown here are possibly random and not representative !
3435/// let result = hub.templates().list("projectId")
3436///              .page_token("ipsum")
3437///              .max_results(-7)
3438///              .doit().await;
3439/// # }
3440/// ```
3441pub struct TemplateListCall<'a, C>
3442where
3443    C: 'a,
3444{
3445    hub: &'a Manager<C>,
3446    _project_id: String,
3447    _page_token: Option<String>,
3448    _max_results: Option<i32>,
3449    _delegate: Option<&'a mut dyn common::Delegate>,
3450    _additional_params: HashMap<String, String>,
3451    _scopes: BTreeSet<String>,
3452}
3453
3454impl<'a, C> common::CallBuilder for TemplateListCall<'a, C> {}
3455
3456impl<'a, C> TemplateListCall<'a, C>
3457where
3458    C: common::Connector,
3459{
3460    /// Perform the operation you have build so far.
3461    pub async fn doit(mut self) -> common::Result<(common::Response, TemplatesListResponse)> {
3462        use std::borrow::Cow;
3463        use std::io::{Read, Seek};
3464
3465        use common::{url::Params, ToParts};
3466        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3467
3468        let mut dd = common::DefaultDelegate;
3469        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3470        dlg.begin(common::MethodInfo {
3471            id: "manager.templates.list",
3472            http_method: hyper::Method::GET,
3473        });
3474
3475        for &field in ["alt", "projectId", "pageToken", "maxResults"].iter() {
3476            if self._additional_params.contains_key(field) {
3477                dlg.finished(false);
3478                return Err(common::Error::FieldClash(field));
3479            }
3480        }
3481
3482        let mut params = Params::with_capacity(5 + self._additional_params.len());
3483        params.push("projectId", self._project_id);
3484        if let Some(value) = self._page_token.as_ref() {
3485            params.push("pageToken", value);
3486        }
3487        if let Some(value) = self._max_results.as_ref() {
3488            params.push("maxResults", value.to_string());
3489        }
3490
3491        params.extend(self._additional_params.iter());
3492
3493        params.push("alt", "json");
3494        let mut url = self.hub._base_url.clone() + "{projectId}/templates";
3495        if self._scopes.is_empty() {
3496            self._scopes
3497                .insert(Scope::NdevCloudmanReadonly.as_ref().to_string());
3498        }
3499
3500        #[allow(clippy::single_element_loop)]
3501        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
3502            url = params.uri_replacement(url, param_name, find_this, false);
3503        }
3504        {
3505            let to_remove = ["projectId"];
3506            params.remove_params(&to_remove);
3507        }
3508
3509        let url = params.parse_with_url(&url);
3510
3511        loop {
3512            let token = match self
3513                .hub
3514                .auth
3515                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3516                .await
3517            {
3518                Ok(token) => token,
3519                Err(e) => match dlg.token(e) {
3520                    Ok(token) => token,
3521                    Err(e) => {
3522                        dlg.finished(false);
3523                        return Err(common::Error::MissingToken(e));
3524                    }
3525                },
3526            };
3527            let mut req_result = {
3528                let client = &self.hub.client;
3529                dlg.pre_request();
3530                let mut req_builder = hyper::Request::builder()
3531                    .method(hyper::Method::GET)
3532                    .uri(url.as_str())
3533                    .header(USER_AGENT, self.hub._user_agent.clone());
3534
3535                if let Some(token) = token.as_ref() {
3536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3537                }
3538
3539                let request = req_builder
3540                    .header(CONTENT_LENGTH, 0_u64)
3541                    .body(common::to_body::<String>(None));
3542
3543                client.request(request.unwrap()).await
3544            };
3545
3546            match req_result {
3547                Err(err) => {
3548                    if let common::Retry::After(d) = dlg.http_error(&err) {
3549                        sleep(d).await;
3550                        continue;
3551                    }
3552                    dlg.finished(false);
3553                    return Err(common::Error::HttpError(err));
3554                }
3555                Ok(res) => {
3556                    let (mut parts, body) = res.into_parts();
3557                    let mut body = common::Body::new(body);
3558                    if !parts.status.is_success() {
3559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3560                        let error = serde_json::from_str(&common::to_string(&bytes));
3561                        let response = common::to_response(parts, bytes.into());
3562
3563                        if let common::Retry::After(d) =
3564                            dlg.http_failure(&response, error.as_ref().ok())
3565                        {
3566                            sleep(d).await;
3567                            continue;
3568                        }
3569
3570                        dlg.finished(false);
3571
3572                        return Err(match error {
3573                            Ok(value) => common::Error::BadRequest(value),
3574                            _ => common::Error::Failure(response),
3575                        });
3576                    }
3577                    let response = {
3578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3579                        let encoded = common::to_string(&bytes);
3580                        match serde_json::from_str(&encoded) {
3581                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3582                            Err(error) => {
3583                                dlg.response_json_decode_error(&encoded, &error);
3584                                return Err(common::Error::JsonDecodeError(
3585                                    encoded.to_string(),
3586                                    error,
3587                                ));
3588                            }
3589                        }
3590                    };
3591
3592                    dlg.finished(true);
3593                    return Ok(response);
3594                }
3595            }
3596        }
3597    }
3598
3599    ///
3600    /// Sets the *project id* path property to the given value.
3601    ///
3602    /// Even though the property as already been set when instantiating this call,
3603    /// we provide this method for API completeness.
3604    pub fn project_id(mut self, new_value: &str) -> TemplateListCall<'a, C> {
3605        self._project_id = new_value.to_string();
3606        self
3607    }
3608    /// Specifies a nextPageToken returned by a previous list request. This token can be used to request the next page of results from a previous list request.
3609    ///
3610    /// Sets the *page token* query property to the given value.
3611    pub fn page_token(mut self, new_value: &str) -> TemplateListCall<'a, C> {
3612        self._page_token = Some(new_value.to_string());
3613        self
3614    }
3615    /// Maximum count of results to be returned. Acceptable values are 0 to 100, inclusive. (Default: 50)
3616    ///
3617    /// Sets the *max results* query property to the given value.
3618    pub fn max_results(mut self, new_value: i32) -> TemplateListCall<'a, C> {
3619        self._max_results = Some(new_value);
3620        self
3621    }
3622    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3623    /// while executing the actual API request.
3624    ///
3625    /// ````text
3626    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3627    /// ````
3628    ///
3629    /// Sets the *delegate* property to the given value.
3630    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TemplateListCall<'a, C> {
3631        self._delegate = Some(new_value);
3632        self
3633    }
3634
3635    /// Set any additional parameter of the query string used in the request.
3636    /// It should be used to set parameters which are not yet available through their own
3637    /// setters.
3638    ///
3639    /// Please note that this method must not be used to set any of the known parameters
3640    /// which have their own setter method. If done anyway, the request will fail.
3641    ///
3642    /// # Additional Parameters
3643    ///
3644    /// * *alt* (query-string) - Data format for the response.
3645    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3646    /// * *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.
3647    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3648    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3649    /// * *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. Overrides userIp if both are provided.
3650    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3651    pub fn param<T>(mut self, name: T, value: T) -> TemplateListCall<'a, C>
3652    where
3653        T: AsRef<str>,
3654    {
3655        self._additional_params
3656            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3657        self
3658    }
3659
3660    /// Identifies the authorization scope for the method you are building.
3661    ///
3662    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3663    /// [`Scope::NdevCloudmanReadonly`].
3664    ///
3665    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3666    /// tokens for more than one scope.
3667    ///
3668    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3669    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3670    /// sufficient, a read-write scope will do as well.
3671    pub fn add_scope<St>(mut self, scope: St) -> TemplateListCall<'a, C>
3672    where
3673        St: AsRef<str>,
3674    {
3675        self._scopes.insert(String::from(scope.as_ref()));
3676        self
3677    }
3678    /// Identifies the authorization scope(s) for the method you are building.
3679    ///
3680    /// See [`Self::add_scope()`] for details.
3681    pub fn add_scopes<I, St>(mut self, scopes: I) -> TemplateListCall<'a, C>
3682    where
3683        I: IntoIterator<Item = St>,
3684        St: AsRef<str>,
3685    {
3686        self._scopes
3687            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3688        self
3689    }
3690
3691    /// Removes all scopes, and no default scope will be used either.
3692    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3693    /// for details).
3694    pub fn clear_scopes(mut self) -> TemplateListCall<'a, C> {
3695        self._scopes.clear();
3696        self
3697    }
3698}