google_memcache1_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    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudMemorystoreForMemcached related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_memcache1_beta2 as memcache1_beta2;
49/// use memcache1_beta2::api::Instance;
50/// use memcache1_beta2::{Result, Error};
51/// # async fn dox() {
52/// use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = CloudMemorystoreForMemcached::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Instance::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_instances_create(req, "parent")
99///              .instance_id("At")
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct CloudMemorystoreForMemcached<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for CloudMemorystoreForMemcached<C> {}
131
132impl<'a, C> CloudMemorystoreForMemcached<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> CloudMemorystoreForMemcached<C> {
137        CloudMemorystoreForMemcached {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://memcache.googleapis.com/".to_string(),
142            _root_url: "https://memcache.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://memcache.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://memcache.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Request for ApplyParameters.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [locations instances apply parameters projects](ProjectLocationInstanceApplyParameterCall) (request)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct ApplyParametersRequest {
190    /// Whether to apply instance-level parameter group to all nodes. If set to true, users are restricted from specifying individual nodes, and `ApplyParameters` updates all nodes within the instance.
191    #[serde(rename = "applyAll")]
192    pub apply_all: Option<bool>,
193    /// Nodes to which the instance-level parameter group is applied.
194    #[serde(rename = "nodeIds")]
195    pub node_ids: Option<Vec<String>>,
196}
197
198impl common::RequestValue for ApplyParametersRequest {}
199
200/// Request for ApplySoftwareUpdate.
201///
202/// # Activities
203///
204/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
205/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
206///
207/// * [locations instances apply software update projects](ProjectLocationInstanceApplySoftwareUpdateCall) (request)
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct ApplySoftwareUpdateRequest {
212    /// Whether to apply the update to all nodes. If set to true, will explicitly restrict users from specifying any nodes, and apply software update to all nodes (where applicable) within the instance.
213    #[serde(rename = "applyAll")]
214    pub apply_all: Option<bool>,
215    /// Nodes to which we should apply the update to. Note all the selected nodes are updated in parallel.
216    #[serde(rename = "nodeIds")]
217    pub node_ids: Option<Vec<String>>,
218}
219
220impl common::RequestValue for ApplySoftwareUpdateRequest {}
221
222/// The request message for Operations.CancelOperation.
223///
224/// # Activities
225///
226/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
227/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
228///
229/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct CancelOperationRequest {
234    _never_set: Option<bool>,
235}
236
237impl common::RequestValue for CancelOperationRequest {}
238
239/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
240///
241/// # Activities
242///
243/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
244/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
245///
246/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
247/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct Empty {
252    _never_set: Option<bool>,
253}
254
255impl common::ResponseResult for Empty {}
256
257/// Maintenance policy per instance.
258///
259/// This type is not used in any activity, and only used as *part* of another schema.
260///
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct GoogleCloudMemcacheV1beta2MaintenancePolicy {
265    /// Output only. The time when the policy was created.
266    #[serde(rename = "createTime")]
267    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
268    /// Description of what this policy is for. Create/Update methods return INVALID_ARGUMENT if the length is greater than 512.
269    pub description: Option<String>,
270    /// Output only. The time when the policy was updated.
271    #[serde(rename = "updateTime")]
272    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
273    /// Required. Maintenance window that is applied to resources covered by this policy. Minimum 1. For the current version, the maximum number of weekly_maintenance_windows is expected to be one.
274    #[serde(rename = "weeklyMaintenanceWindow")]
275    pub weekly_maintenance_window: Option<Vec<WeeklyMaintenanceWindow>>,
276}
277
278impl common::Part for GoogleCloudMemcacheV1beta2MaintenancePolicy {}
279
280/// Request for UpgradeInstance.
281///
282/// # Activities
283///
284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
286///
287/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (request)
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct GoogleCloudMemcacheV1beta2UpgradeInstanceRequest {
292    /// Required. Specifies the target version of memcached engine to upgrade to.
293    #[serde(rename = "memcacheVersion")]
294    pub memcache_version: Option<String>,
295}
296
297impl common::RequestValue for GoogleCloudMemcacheV1beta2UpgradeInstanceRequest {}
298
299/// A Memorystore for Memcached instance
300///
301/// # Activities
302///
303/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
304/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
305///
306/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request)
307/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
308/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310#[serde_with::serde_as]
311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
312pub struct Instance {
313    /// The full name of the Google Compute Engine [network](https://cloud.google.com/vpc/docs/vpc) to which the instance is connected. If left unspecified, the `default` network will be used.
314    #[serde(rename = "authorizedNetwork")]
315    pub authorized_network: Option<String>,
316    /// Output only. The time the instance was created.
317    #[serde(rename = "createTime")]
318    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
319    /// Output only. Endpoint for the Discovery API.
320    #[serde(rename = "discoveryEndpoint")]
321    pub discovery_endpoint: Option<String>,
322    /// User provided name for the instance, which is only used for display purposes. Cannot be more than 80 characters.
323    #[serde(rename = "displayName")]
324    pub display_name: Option<String>,
325    /// List of messages that describe the current state of the Memcached instance.
326    #[serde(rename = "instanceMessages")]
327    pub instance_messages: Option<Vec<InstanceMessage>>,
328    /// Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources
329    pub labels: Option<HashMap<String, String>>,
330    /// The maintenance policy for the instance. If not provided, the maintenance event will be performed based on Memorystore internal rollout schedule.
331    #[serde(rename = "maintenancePolicy")]
332    pub maintenance_policy: Option<GoogleCloudMemcacheV1beta2MaintenancePolicy>,
333    /// Output only. Published maintenance schedule.
334    #[serde(rename = "maintenanceSchedule")]
335    pub maintenance_schedule: Option<MaintenanceSchedule>,
336    /// Output only. The full version of memcached server running on this instance. System automatically determines the full memcached version for an instance based on the input MemcacheVersion. The full version format will be "memcached-1.5.16".
337    #[serde(rename = "memcacheFullVersion")]
338    pub memcache_full_version: Option<String>,
339    /// Output only. List of Memcached nodes. Refer to Node message for more details.
340    #[serde(rename = "memcacheNodes")]
341    pub memcache_nodes: Option<Vec<Node>>,
342    /// The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest supported major version is `MEMCACHE_1_5`. The minor version will be automatically determined by our system based on the latest supported minor version.
343    #[serde(rename = "memcacheVersion")]
344    pub memcache_version: Option<String>,
345    /// Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details.
346    pub name: Option<String>,
347    /// Required. Configuration for Memcached nodes.
348    #[serde(rename = "nodeConfig")]
349    pub node_config: Option<NodeConfig>,
350    /// Required. Number of nodes in the Memcached instance.
351    #[serde(rename = "nodeCount")]
352    pub node_count: Option<i32>,
353    /// User defined parameters to apply to the memcached process on each node.
354    pub parameters: Option<MemcacheParameters>,
355    /// Optional. Contains the id of allocated IP address ranges associated with the private service access connection for example, "test-default" associated with IP range 10.0.0.0/29.
356    #[serde(rename = "reservedIpRangeId")]
357    pub reserved_ip_range_id: Option<Vec<String>>,
358    /// Optional. Output only. Reserved for future use.
359    #[serde(rename = "satisfiesPzi")]
360    pub satisfies_pzi: Option<bool>,
361    /// Optional. Output only. Reserved for future use.
362    #[serde(rename = "satisfiesPzs")]
363    pub satisfies_pzs: Option<bool>,
364    /// Output only. The state of this Memcached instance.
365    pub state: Option<String>,
366    /// Output only. Returns true if there is an update waiting to be applied
367    #[serde(rename = "updateAvailable")]
368    pub update_available: Option<bool>,
369    /// Output only. The time the instance was updated.
370    #[serde(rename = "updateTime")]
371    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
372    /// Zones in which Memcached nodes should be provisioned. Memcached nodes will be equally distributed across these zones. If not provided, the service will by default create nodes in all zones in the region for the instance.
373    pub zones: Option<Vec<String>>,
374}
375
376impl common::RequestValue for Instance {}
377impl common::ResponseResult for Instance {}
378
379/// There is no detailed description.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct InstanceMessage {
387    /// A code that correspond to one type of user-facing message.
388    pub code: Option<String>,
389    /// Message on memcached instance which will be exposed to users.
390    pub message: Option<String>,
391}
392
393impl common::Part for InstanceMessage {}
394
395/// Response for ListInstances.
396///
397/// # Activities
398///
399/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
400/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
401///
402/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct ListInstancesResponse {
407    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
408    #[serde(rename = "nextPageToken")]
409    pub next_page_token: Option<String>,
410    /// A list of Memcached instances in the project in the specified location, or across all locations. If the `location_id` in the parent field of the request is "-", all regions available to the project are queried, and the results aggregated.
411    pub resources: Option<Vec<Instance>>,
412    /// Locations that could not be reached.
413    pub unreachable: Option<Vec<String>>,
414}
415
416impl common::ResponseResult for ListInstancesResponse {}
417
418/// The response message for Locations.ListLocations.
419///
420/// # Activities
421///
422/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
423/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
424///
425/// * [locations list projects](ProjectLocationListCall) (response)
426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
427#[serde_with::serde_as]
428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
429pub struct ListLocationsResponse {
430    /// A list of locations that matches the specified filter in the request.
431    pub locations: Option<Vec<Location>>,
432    /// The standard List next-page token.
433    #[serde(rename = "nextPageToken")]
434    pub next_page_token: Option<String>,
435}
436
437impl common::ResponseResult for ListLocationsResponse {}
438
439/// The response message for Operations.ListOperations.
440///
441/// # Activities
442///
443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
445///
446/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
448#[serde_with::serde_as]
449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
450pub struct ListOperationsResponse {
451    /// The standard List next-page token.
452    #[serde(rename = "nextPageToken")]
453    pub next_page_token: Option<String>,
454    /// A list of operations that matches the specified filter in the request.
455    pub operations: Option<Vec<Operation>>,
456    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections e.g. when attempting to list all resources across all supported locations.
457    pub unreachable: Option<Vec<String>>,
458}
459
460impl common::ResponseResult for ListOperationsResponse {}
461
462/// A resource that represents a Google Cloud location.
463///
464/// # Activities
465///
466/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
467/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
468///
469/// * [locations get projects](ProjectLocationGetCall) (response)
470#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
471#[serde_with::serde_as]
472#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
473pub struct Location {
474    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
475    #[serde(rename = "displayName")]
476    pub display_name: Option<String>,
477    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
478    pub labels: Option<HashMap<String, String>>,
479    /// The canonical id for this location. For example: `"us-east1"`.
480    #[serde(rename = "locationId")]
481    pub location_id: Option<String>,
482    /// Service-specific metadata. For example the available capacity at the given location.
483    pub metadata: Option<HashMap<String, serde_json::Value>>,
484    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
485    pub name: Option<String>,
486}
487
488impl common::ResponseResult for Location {}
489
490/// Upcoming maintenance schedule.
491///
492/// This type is not used in any activity, and only used as *part* of another schema.
493///
494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
495#[serde_with::serde_as]
496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
497pub struct MaintenanceSchedule {
498    /// Output only. The end time of any upcoming scheduled maintenance for this instance.
499    #[serde(rename = "endTime")]
500    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
501    /// Output only. The deadline that the maintenance schedule start time can not go beyond, including reschedule.
502    #[serde(rename = "scheduleDeadlineTime")]
503    pub schedule_deadline_time: Option<chrono::DateTime<chrono::offset::Utc>>,
504    /// Output only. The start time of any upcoming scheduled maintenance for this instance.
505    #[serde(rename = "startTime")]
506    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
507}
508
509impl common::Part for MaintenanceSchedule {}
510
511/// There is no detailed description.
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct MemcacheParameters {
519    /// Output only. The unique ID associated with this set of parameters. Users can use this id to determine if the parameters associated with the instance differ from the parameters associated with the nodes. A discrepancy between parameter ids can inform users that they may need to take action to apply parameters on nodes.
520    pub id: Option<String>,
521    /// User defined set of parameters to use in the memcached process.
522    pub params: Option<HashMap<String, String>>,
523}
524
525impl common::Part for MemcacheParameters {}
526
527/// There is no detailed description.
528///
529/// This type is not used in any activity, and only used as *part* of another schema.
530///
531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
532#[serde_with::serde_as]
533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
534pub struct Node {
535    /// Output only. Hostname or IP address of the Memcached node used by the clients to connect to the Memcached server on this node.
536    pub host: Option<String>,
537    /// Output only. The full version of memcached server running on this node. e.g. - memcached-1.5.16
538    #[serde(rename = "memcacheFullVersion")]
539    pub memcache_full_version: Option<String>,
540    /// Output only. Major version of memcached server running on this node, e.g. MEMCACHE_1_5
541    #[serde(rename = "memcacheVersion")]
542    pub memcache_version: Option<String>,
543    /// Output only. Identifier of the Memcached node. The node id does not include project or location like the Memcached instance name.
544    #[serde(rename = "nodeId")]
545    pub node_id: Option<String>,
546    /// User defined parameters currently applied to the node.
547    pub parameters: Option<MemcacheParameters>,
548    /// Output only. The port number of the Memcached server on this node.
549    pub port: Option<i32>,
550    /// Output only. Current state of the Memcached node.
551    pub state: Option<String>,
552    /// Output only. Returns true if there is an update waiting to be applied
553    #[serde(rename = "updateAvailable")]
554    pub update_available: Option<bool>,
555    /// Output only. Location (GCP Zone) for the Memcached node.
556    pub zone: Option<String>,
557}
558
559impl common::Part for Node {}
560
561/// Configuration for a Memcached Node.
562///
563/// This type is not used in any activity, and only used as *part* of another schema.
564///
565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
566#[serde_with::serde_as]
567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
568pub struct NodeConfig {
569    /// Required. Number of cpus per Memcached node.
570    #[serde(rename = "cpuCount")]
571    pub cpu_count: Option<i32>,
572    /// Required. Memory size in MiB for each Memcached node.
573    #[serde(rename = "memorySizeMb")]
574    pub memory_size_mb: Option<i32>,
575}
576
577impl common::Part for NodeConfig {}
578
579/// This resource represents a long-running operation that is the result of a network API call.
580///
581/// # Activities
582///
583/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
584/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
585///
586/// * [locations instances apply parameters projects](ProjectLocationInstanceApplyParameterCall) (response)
587/// * [locations instances apply software update projects](ProjectLocationInstanceApplySoftwareUpdateCall) (response)
588/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
589/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
590/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
591/// * [locations instances reschedule maintenance projects](ProjectLocationInstanceRescheduleMaintenanceCall) (response)
592/// * [locations instances update parameters projects](ProjectLocationInstanceUpdateParameterCall) (response)
593/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (response)
594/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
596#[serde_with::serde_as]
597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
598pub struct Operation {
599    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
600    pub done: Option<bool>,
601    /// The error result of the operation in case of failure or cancellation.
602    pub error: Option<Status>,
603    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
604    pub metadata: Option<HashMap<String, serde_json::Value>>,
605    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
606    pub name: Option<String>,
607    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
608    pub response: Option<HashMap<String, serde_json::Value>>,
609}
610
611impl common::ResponseResult for Operation {}
612
613/// Request for RescheduleMaintenance.
614///
615/// # Activities
616///
617/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
618/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
619///
620/// * [locations instances reschedule maintenance projects](ProjectLocationInstanceRescheduleMaintenanceCall) (request)
621#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
622#[serde_with::serde_as]
623#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
624pub struct RescheduleMaintenanceRequest {
625    /// Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.
626    #[serde(rename = "rescheduleType")]
627    pub reschedule_type: Option<String>,
628    /// Timestamp when the maintenance shall be rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for example `2012-11-15T16:19:00.094Z`.
629    #[serde(rename = "scheduleTime")]
630    pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
631}
632
633impl common::RequestValue for RescheduleMaintenanceRequest {}
634
635/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
636///
637/// This type is not used in any activity, and only used as *part* of another schema.
638///
639#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
640#[serde_with::serde_as]
641#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
642pub struct Status {
643    /// The status code, which should be an enum value of google.rpc.Code.
644    pub code: Option<i32>,
645    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
646    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
647    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
648    pub message: Option<String>,
649}
650
651impl common::Part for Status {}
652
653/// Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
654///
655/// This type is not used in any activity, and only used as *part* of another schema.
656///
657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
658#[serde_with::serde_as]
659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
660pub struct TimeOfDay {
661    /// Hours of a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
662    pub hours: Option<i32>,
663    /// Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59.
664    pub minutes: Option<i32>,
665    /// Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999.
666    pub nanos: Option<i32>,
667    /// Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds.
668    pub seconds: Option<i32>,
669}
670
671impl common::Part for TimeOfDay {}
672
673/// Request for UpdateParameters.
674///
675/// # Activities
676///
677/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
678/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
679///
680/// * [locations instances update parameters projects](ProjectLocationInstanceUpdateParameterCall) (request)
681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
682#[serde_with::serde_as]
683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
684pub struct UpdateParametersRequest {
685    /// The parameters to apply to the instance.
686    pub parameters: Option<MemcacheParameters>,
687    /// Required. Mask of fields to update.
688    #[serde(rename = "updateMask")]
689    pub update_mask: Option<common::FieldMask>,
690}
691
692impl common::RequestValue for UpdateParametersRequest {}
693
694/// Time window specified for weekly operations.
695///
696/// This type is not used in any activity, and only used as *part* of another schema.
697///
698#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
699#[serde_with::serde_as]
700#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
701pub struct WeeklyMaintenanceWindow {
702    /// Required. Allows to define schedule that runs specified day of the week.
703    pub day: Option<String>,
704    /// Required. Duration of the time window.
705    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
706    pub duration: Option<chrono::Duration>,
707    /// Required. Start time of the window in UTC.
708    #[serde(rename = "startTime")]
709    pub start_time: Option<TimeOfDay>,
710}
711
712impl common::Part for WeeklyMaintenanceWindow {}
713
714// ###################
715// MethodBuilders ###
716// #################
717
718/// A builder providing access to all methods supported on *project* resources.
719/// It is not used directly, but through the [`CloudMemorystoreForMemcached`] hub.
720///
721/// # Example
722///
723/// Instantiate a resource builder
724///
725/// ```test_harness,no_run
726/// extern crate hyper;
727/// extern crate hyper_rustls;
728/// extern crate google_memcache1_beta2 as memcache1_beta2;
729///
730/// # async fn dox() {
731/// use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
732///
733/// let secret: yup_oauth2::ApplicationSecret = Default::default();
734/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
735///     .with_native_roots()
736///     .unwrap()
737///     .https_only()
738///     .enable_http2()
739///     .build();
740///
741/// let executor = hyper_util::rt::TokioExecutor::new();
742/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
743///     secret,
744///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
745///     yup_oauth2::client::CustomHyperClientBuilder::from(
746///         hyper_util::client::legacy::Client::builder(executor).build(connector),
747///     ),
748/// ).build().await.unwrap();
749///
750/// let client = hyper_util::client::legacy::Client::builder(
751///     hyper_util::rt::TokioExecutor::new()
752/// )
753/// .build(
754///     hyper_rustls::HttpsConnectorBuilder::new()
755///         .with_native_roots()
756///         .unwrap()
757///         .https_or_http()
758///         .enable_http2()
759///         .build()
760/// );
761/// let mut hub = CloudMemorystoreForMemcached::new(client, auth);
762/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
763/// // like `locations_get(...)`, `locations_instances_apply_parameters(...)`, `locations_instances_apply_software_update(...)`, `locations_instances_create(...)`, `locations_instances_delete(...)`, `locations_instances_get(...)`, `locations_instances_list(...)`, `locations_instances_patch(...)`, `locations_instances_reschedule_maintenance(...)`, `locations_instances_update_parameters(...)`, `locations_instances_upgrade(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
764/// // to build up your call.
765/// let rb = hub.projects();
766/// # }
767/// ```
768pub struct ProjectMethods<'a, C>
769where
770    C: 'a,
771{
772    hub: &'a CloudMemorystoreForMemcached<C>,
773}
774
775impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
776
777impl<'a, C> ProjectMethods<'a, C> {
778    /// Create a builder to help you perform the following task:
779    ///
780    /// `ApplyParameters` restarts the set of specified nodes in order to update them to the current set of parameters for the Memcached Instance.
781    ///
782    /// # Arguments
783    ///
784    /// * `request` - No description provided.
785    /// * `name` - Required. Resource name of the Memcached instance for which parameter group updates should be applied.
786    pub fn locations_instances_apply_parameters(
787        &self,
788        request: ApplyParametersRequest,
789        name: &str,
790    ) -> ProjectLocationInstanceApplyParameterCall<'a, C> {
791        ProjectLocationInstanceApplyParameterCall {
792            hub: self.hub,
793            _request: request,
794            _name: name.to_string(),
795            _delegate: Default::default(),
796            _additional_params: Default::default(),
797            _scopes: Default::default(),
798        }
799    }
800
801    /// Create a builder to help you perform the following task:
802    ///
803    /// Updates software on the selected nodes of the Instance.
804    ///
805    /// # Arguments
806    ///
807    /// * `request` - No description provided.
808    /// * `instance` - Required. Resource name of the Memcached instance for which software update should be applied.
809    pub fn locations_instances_apply_software_update(
810        &self,
811        request: ApplySoftwareUpdateRequest,
812        instance: &str,
813    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C> {
814        ProjectLocationInstanceApplySoftwareUpdateCall {
815            hub: self.hub,
816            _request: request,
817            _instance: instance.to_string(),
818            _delegate: Default::default(),
819            _additional_params: Default::default(),
820            _scopes: Default::default(),
821        }
822    }
823
824    /// Create a builder to help you perform the following task:
825    ///
826    /// Creates a new Instance in a given location.
827    ///
828    /// # Arguments
829    ///
830    /// * `request` - No description provided.
831    /// * `parent` - Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region
832    pub fn locations_instances_create(
833        &self,
834        request: Instance,
835        parent: &str,
836    ) -> ProjectLocationInstanceCreateCall<'a, C> {
837        ProjectLocationInstanceCreateCall {
838            hub: self.hub,
839            _request: request,
840            _parent: parent.to_string(),
841            _instance_id: Default::default(),
842            _delegate: Default::default(),
843            _additional_params: Default::default(),
844            _scopes: Default::default(),
845        }
846    }
847
848    /// Create a builder to help you perform the following task:
849    ///
850    /// Deletes a single Instance.
851    ///
852    /// # Arguments
853    ///
854    /// * `name` - Required. Memcached instance resource name in the format: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region
855    pub fn locations_instances_delete(
856        &self,
857        name: &str,
858    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
859        ProjectLocationInstanceDeleteCall {
860            hub: self.hub,
861            _name: name.to_string(),
862            _delegate: Default::default(),
863            _additional_params: Default::default(),
864            _scopes: Default::default(),
865        }
866    }
867
868    /// Create a builder to help you perform the following task:
869    ///
870    /// Gets details of a single Instance.
871    ///
872    /// # Arguments
873    ///
874    /// * `name` - Required. Memcached instance resource name in the format: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region
875    pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
876        ProjectLocationInstanceGetCall {
877            hub: self.hub,
878            _name: name.to_string(),
879            _delegate: Default::default(),
880            _additional_params: Default::default(),
881            _scopes: Default::default(),
882        }
883    }
884
885    /// Create a builder to help you perform the following task:
886    ///
887    /// Lists Instances in a given location.
888    ///
889    /// # Arguments
890    ///
891    /// * `parent` - Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region
892    pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
893        ProjectLocationInstanceListCall {
894            hub: self.hub,
895            _parent: parent.to_string(),
896            _page_token: Default::default(),
897            _page_size: Default::default(),
898            _order_by: Default::default(),
899            _filter: Default::default(),
900            _delegate: Default::default(),
901            _additional_params: Default::default(),
902            _scopes: Default::default(),
903        }
904    }
905
906    /// Create a builder to help you perform the following task:
907    ///
908    /// Updates an existing Instance in a given project and location.
909    ///
910    /// # Arguments
911    ///
912    /// * `request` - No description provided.
913    /// * `name` - Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details.
914    pub fn locations_instances_patch(
915        &self,
916        request: Instance,
917        name: &str,
918    ) -> ProjectLocationInstancePatchCall<'a, C> {
919        ProjectLocationInstancePatchCall {
920            hub: self.hub,
921            _request: request,
922            _name: name.to_string(),
923            _update_mask: Default::default(),
924            _delegate: Default::default(),
925            _additional_params: Default::default(),
926            _scopes: Default::default(),
927        }
928    }
929
930    /// Create a builder to help you perform the following task:
931    ///
932    /// Performs the apply phase of the RescheduleMaintenance verb.
933    ///
934    /// # Arguments
935    ///
936    /// * `request` - No description provided.
937    /// * `instance` - Required. Memcache instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
938    pub fn locations_instances_reschedule_maintenance(
939        &self,
940        request: RescheduleMaintenanceRequest,
941        instance: &str,
942    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
943        ProjectLocationInstanceRescheduleMaintenanceCall {
944            hub: self.hub,
945            _request: request,
946            _instance: instance.to_string(),
947            _delegate: Default::default(),
948            _additional_params: Default::default(),
949            _scopes: Default::default(),
950        }
951    }
952
953    /// Create a builder to help you perform the following task:
954    ///
955    /// Updates the defined Memcached parameters for an existing instance. This method only stages the parameters, it must be followed by `ApplyParameters` to apply the parameters to nodes of the Memcached instance.
956    ///
957    /// # Arguments
958    ///
959    /// * `request` - No description provided.
960    /// * `name` - Required. Resource name of the Memcached instance for which the parameters should be updated.
961    pub fn locations_instances_update_parameters(
962        &self,
963        request: UpdateParametersRequest,
964        name: &str,
965    ) -> ProjectLocationInstanceUpdateParameterCall<'a, C> {
966        ProjectLocationInstanceUpdateParameterCall {
967            hub: self.hub,
968            _request: request,
969            _name: name.to_string(),
970            _delegate: Default::default(),
971            _additional_params: Default::default(),
972            _scopes: Default::default(),
973        }
974    }
975
976    /// Create a builder to help you perform the following task:
977    ///
978    /// Upgrades the Memcache instance to a newer memcached engine version specified in the request.
979    ///
980    /// # Arguments
981    ///
982    /// * `request` - No description provided.
983    /// * `name` - Required. Memcache instance resource name using the form: `projects/{project}/locations/{location}/instances/{instance}` where `location_id` refers to a GCP region.
984    pub fn locations_instances_upgrade(
985        &self,
986        request: GoogleCloudMemcacheV1beta2UpgradeInstanceRequest,
987        name: &str,
988    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
989        ProjectLocationInstanceUpgradeCall {
990            hub: self.hub,
991            _request: request,
992            _name: name.to_string(),
993            _delegate: Default::default(),
994            _additional_params: Default::default(),
995            _scopes: Default::default(),
996        }
997    }
998
999    /// Create a builder to help you perform the following task:
1000    ///
1001    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
1002    ///
1003    /// # Arguments
1004    ///
1005    /// * `request` - No description provided.
1006    /// * `name` - The name of the operation resource to be cancelled.
1007    pub fn locations_operations_cancel(
1008        &self,
1009        request: CancelOperationRequest,
1010        name: &str,
1011    ) -> ProjectLocationOperationCancelCall<'a, C> {
1012        ProjectLocationOperationCancelCall {
1013            hub: self.hub,
1014            _request: request,
1015            _name: name.to_string(),
1016            _delegate: Default::default(),
1017            _additional_params: Default::default(),
1018            _scopes: Default::default(),
1019        }
1020    }
1021
1022    /// Create a builder to help you perform the following task:
1023    ///
1024    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
1025    ///
1026    /// # Arguments
1027    ///
1028    /// * `name` - The name of the operation resource to be deleted.
1029    pub fn locations_operations_delete(
1030        &self,
1031        name: &str,
1032    ) -> ProjectLocationOperationDeleteCall<'a, C> {
1033        ProjectLocationOperationDeleteCall {
1034            hub: self.hub,
1035            _name: name.to_string(),
1036            _delegate: Default::default(),
1037            _additional_params: Default::default(),
1038            _scopes: Default::default(),
1039        }
1040    }
1041
1042    /// Create a builder to help you perform the following task:
1043    ///
1044    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1045    ///
1046    /// # Arguments
1047    ///
1048    /// * `name` - The name of the operation resource.
1049    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
1050        ProjectLocationOperationGetCall {
1051            hub: self.hub,
1052            _name: name.to_string(),
1053            _delegate: Default::default(),
1054            _additional_params: Default::default(),
1055            _scopes: Default::default(),
1056        }
1057    }
1058
1059    /// Create a builder to help you perform the following task:
1060    ///
1061    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1062    ///
1063    /// # Arguments
1064    ///
1065    /// * `name` - The name of the operation's parent resource.
1066    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
1067        ProjectLocationOperationListCall {
1068            hub: self.hub,
1069            _name: name.to_string(),
1070            _return_partial_success: Default::default(),
1071            _page_token: Default::default(),
1072            _page_size: Default::default(),
1073            _filter: Default::default(),
1074            _delegate: Default::default(),
1075            _additional_params: Default::default(),
1076            _scopes: Default::default(),
1077        }
1078    }
1079
1080    /// Create a builder to help you perform the following task:
1081    ///
1082    /// Gets information about a location.
1083    ///
1084    /// # Arguments
1085    ///
1086    /// * `name` - Resource name for the location.
1087    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1088        ProjectLocationGetCall {
1089            hub: self.hub,
1090            _name: name.to_string(),
1091            _delegate: Default::default(),
1092            _additional_params: Default::default(),
1093            _scopes: Default::default(),
1094        }
1095    }
1096
1097    /// Create a builder to help you perform the following task:
1098    ///
1099    /// Lists information about the supported locations for this service.
1100    ///
1101    /// # Arguments
1102    ///
1103    /// * `name` - The resource that owns the locations collection, if applicable.
1104    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1105        ProjectLocationListCall {
1106            hub: self.hub,
1107            _name: name.to_string(),
1108            _page_token: Default::default(),
1109            _page_size: Default::default(),
1110            _filter: Default::default(),
1111            _extra_location_types: Default::default(),
1112            _delegate: Default::default(),
1113            _additional_params: Default::default(),
1114            _scopes: Default::default(),
1115        }
1116    }
1117}
1118
1119// ###################
1120// CallBuilders   ###
1121// #################
1122
1123/// `ApplyParameters` restarts the set of specified nodes in order to update them to the current set of parameters for the Memcached Instance.
1124///
1125/// A builder for the *locations.instances.applyParameters* method supported by a *project* resource.
1126/// It is not used directly, but through a [`ProjectMethods`] instance.
1127///
1128/// # Example
1129///
1130/// Instantiate a resource method builder
1131///
1132/// ```test_harness,no_run
1133/// # extern crate hyper;
1134/// # extern crate hyper_rustls;
1135/// # extern crate google_memcache1_beta2 as memcache1_beta2;
1136/// use memcache1_beta2::api::ApplyParametersRequest;
1137/// # async fn dox() {
1138/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1139///
1140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1141/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1142/// #     .with_native_roots()
1143/// #     .unwrap()
1144/// #     .https_only()
1145/// #     .enable_http2()
1146/// #     .build();
1147///
1148/// # let executor = hyper_util::rt::TokioExecutor::new();
1149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1150/// #     secret,
1151/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1152/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1153/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1154/// #     ),
1155/// # ).build().await.unwrap();
1156///
1157/// # let client = hyper_util::client::legacy::Client::builder(
1158/// #     hyper_util::rt::TokioExecutor::new()
1159/// # )
1160/// # .build(
1161/// #     hyper_rustls::HttpsConnectorBuilder::new()
1162/// #         .with_native_roots()
1163/// #         .unwrap()
1164/// #         .https_or_http()
1165/// #         .enable_http2()
1166/// #         .build()
1167/// # );
1168/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
1169/// // As the method needs a request, you would usually fill it with the desired information
1170/// // into the respective structure. Some of the parts shown here might not be applicable !
1171/// // Values shown here are possibly random and not representative !
1172/// let mut req = ApplyParametersRequest::default();
1173///
1174/// // You can configure optional parameters by calling the respective setters at will, and
1175/// // execute the final call using `doit()`.
1176/// // Values shown here are possibly random and not representative !
1177/// let result = hub.projects().locations_instances_apply_parameters(req, "name")
1178///              .doit().await;
1179/// # }
1180/// ```
1181pub struct ProjectLocationInstanceApplyParameterCall<'a, C>
1182where
1183    C: 'a,
1184{
1185    hub: &'a CloudMemorystoreForMemcached<C>,
1186    _request: ApplyParametersRequest,
1187    _name: String,
1188    _delegate: Option<&'a mut dyn common::Delegate>,
1189    _additional_params: HashMap<String, String>,
1190    _scopes: BTreeSet<String>,
1191}
1192
1193impl<'a, C> common::CallBuilder for ProjectLocationInstanceApplyParameterCall<'a, C> {}
1194
1195impl<'a, C> ProjectLocationInstanceApplyParameterCall<'a, C>
1196where
1197    C: common::Connector,
1198{
1199    /// Perform the operation you have build so far.
1200    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1201        use std::borrow::Cow;
1202        use std::io::{Read, Seek};
1203
1204        use common::{url::Params, ToParts};
1205        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1206
1207        let mut dd = common::DefaultDelegate;
1208        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1209        dlg.begin(common::MethodInfo {
1210            id: "memcache.projects.locations.instances.applyParameters",
1211            http_method: hyper::Method::POST,
1212        });
1213
1214        for &field in ["alt", "name"].iter() {
1215            if self._additional_params.contains_key(field) {
1216                dlg.finished(false);
1217                return Err(common::Error::FieldClash(field));
1218            }
1219        }
1220
1221        let mut params = Params::with_capacity(4 + self._additional_params.len());
1222        params.push("name", self._name);
1223
1224        params.extend(self._additional_params.iter());
1225
1226        params.push("alt", "json");
1227        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}:applyParameters";
1228        if self._scopes.is_empty() {
1229            self._scopes
1230                .insert(Scope::CloudPlatform.as_ref().to_string());
1231        }
1232
1233        #[allow(clippy::single_element_loop)]
1234        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1235            url = params.uri_replacement(url, param_name, find_this, true);
1236        }
1237        {
1238            let to_remove = ["name"];
1239            params.remove_params(&to_remove);
1240        }
1241
1242        let url = params.parse_with_url(&url);
1243
1244        let mut json_mime_type = mime::APPLICATION_JSON;
1245        let mut request_value_reader = {
1246            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1247            common::remove_json_null_values(&mut value);
1248            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1249            serde_json::to_writer(&mut dst, &value).unwrap();
1250            dst
1251        };
1252        let request_size = request_value_reader
1253            .seek(std::io::SeekFrom::End(0))
1254            .unwrap();
1255        request_value_reader
1256            .seek(std::io::SeekFrom::Start(0))
1257            .unwrap();
1258
1259        loop {
1260            let token = match self
1261                .hub
1262                .auth
1263                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1264                .await
1265            {
1266                Ok(token) => token,
1267                Err(e) => match dlg.token(e) {
1268                    Ok(token) => token,
1269                    Err(e) => {
1270                        dlg.finished(false);
1271                        return Err(common::Error::MissingToken(e));
1272                    }
1273                },
1274            };
1275            request_value_reader
1276                .seek(std::io::SeekFrom::Start(0))
1277                .unwrap();
1278            let mut req_result = {
1279                let client = &self.hub.client;
1280                dlg.pre_request();
1281                let mut req_builder = hyper::Request::builder()
1282                    .method(hyper::Method::POST)
1283                    .uri(url.as_str())
1284                    .header(USER_AGENT, self.hub._user_agent.clone());
1285
1286                if let Some(token) = token.as_ref() {
1287                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1288                }
1289
1290                let request = req_builder
1291                    .header(CONTENT_TYPE, json_mime_type.to_string())
1292                    .header(CONTENT_LENGTH, request_size as u64)
1293                    .body(common::to_body(
1294                        request_value_reader.get_ref().clone().into(),
1295                    ));
1296
1297                client.request(request.unwrap()).await
1298            };
1299
1300            match req_result {
1301                Err(err) => {
1302                    if let common::Retry::After(d) = dlg.http_error(&err) {
1303                        sleep(d).await;
1304                        continue;
1305                    }
1306                    dlg.finished(false);
1307                    return Err(common::Error::HttpError(err));
1308                }
1309                Ok(res) => {
1310                    let (mut parts, body) = res.into_parts();
1311                    let mut body = common::Body::new(body);
1312                    if !parts.status.is_success() {
1313                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1314                        let error = serde_json::from_str(&common::to_string(&bytes));
1315                        let response = common::to_response(parts, bytes.into());
1316
1317                        if let common::Retry::After(d) =
1318                            dlg.http_failure(&response, error.as_ref().ok())
1319                        {
1320                            sleep(d).await;
1321                            continue;
1322                        }
1323
1324                        dlg.finished(false);
1325
1326                        return Err(match error {
1327                            Ok(value) => common::Error::BadRequest(value),
1328                            _ => common::Error::Failure(response),
1329                        });
1330                    }
1331                    let response = {
1332                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1333                        let encoded = common::to_string(&bytes);
1334                        match serde_json::from_str(&encoded) {
1335                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1336                            Err(error) => {
1337                                dlg.response_json_decode_error(&encoded, &error);
1338                                return Err(common::Error::JsonDecodeError(
1339                                    encoded.to_string(),
1340                                    error,
1341                                ));
1342                            }
1343                        }
1344                    };
1345
1346                    dlg.finished(true);
1347                    return Ok(response);
1348                }
1349            }
1350        }
1351    }
1352
1353    ///
1354    /// Sets the *request* property to the given value.
1355    ///
1356    /// Even though the property as already been set when instantiating this call,
1357    /// we provide this method for API completeness.
1358    pub fn request(
1359        mut self,
1360        new_value: ApplyParametersRequest,
1361    ) -> ProjectLocationInstanceApplyParameterCall<'a, C> {
1362        self._request = new_value;
1363        self
1364    }
1365    /// Required. Resource name of the Memcached instance for which parameter group updates should be applied.
1366    ///
1367    /// Sets the *name* path property to the given value.
1368    ///
1369    /// Even though the property as already been set when instantiating this call,
1370    /// we provide this method for API completeness.
1371    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceApplyParameterCall<'a, C> {
1372        self._name = new_value.to_string();
1373        self
1374    }
1375    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1376    /// while executing the actual API request.
1377    ///
1378    /// ````text
1379    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1380    /// ````
1381    ///
1382    /// Sets the *delegate* property to the given value.
1383    pub fn delegate(
1384        mut self,
1385        new_value: &'a mut dyn common::Delegate,
1386    ) -> ProjectLocationInstanceApplyParameterCall<'a, C> {
1387        self._delegate = Some(new_value);
1388        self
1389    }
1390
1391    /// Set any additional parameter of the query string used in the request.
1392    /// It should be used to set parameters which are not yet available through their own
1393    /// setters.
1394    ///
1395    /// Please note that this method must not be used to set any of the known parameters
1396    /// which have their own setter method. If done anyway, the request will fail.
1397    ///
1398    /// # Additional Parameters
1399    ///
1400    /// * *$.xgafv* (query-string) - V1 error format.
1401    /// * *access_token* (query-string) - OAuth access token.
1402    /// * *alt* (query-string) - Data format for response.
1403    /// * *callback* (query-string) - JSONP
1404    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1405    /// * *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.
1406    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1407    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1408    /// * *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.
1409    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1410    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1411    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceApplyParameterCall<'a, C>
1412    where
1413        T: AsRef<str>,
1414    {
1415        self._additional_params
1416            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1417        self
1418    }
1419
1420    /// Identifies the authorization scope for the method you are building.
1421    ///
1422    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1423    /// [`Scope::CloudPlatform`].
1424    ///
1425    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1426    /// tokens for more than one scope.
1427    ///
1428    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1429    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1430    /// sufficient, a read-write scope will do as well.
1431    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceApplyParameterCall<'a, C>
1432    where
1433        St: AsRef<str>,
1434    {
1435        self._scopes.insert(String::from(scope.as_ref()));
1436        self
1437    }
1438    /// Identifies the authorization scope(s) for the method you are building.
1439    ///
1440    /// See [`Self::add_scope()`] for details.
1441    pub fn add_scopes<I, St>(
1442        mut self,
1443        scopes: I,
1444    ) -> ProjectLocationInstanceApplyParameterCall<'a, C>
1445    where
1446        I: IntoIterator<Item = St>,
1447        St: AsRef<str>,
1448    {
1449        self._scopes
1450            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1451        self
1452    }
1453
1454    /// Removes all scopes, and no default scope will be used either.
1455    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1456    /// for details).
1457    pub fn clear_scopes(mut self) -> ProjectLocationInstanceApplyParameterCall<'a, C> {
1458        self._scopes.clear();
1459        self
1460    }
1461}
1462
1463/// Updates software on the selected nodes of the Instance.
1464///
1465/// A builder for the *locations.instances.applySoftwareUpdate* method supported by a *project* resource.
1466/// It is not used directly, but through a [`ProjectMethods`] instance.
1467///
1468/// # Example
1469///
1470/// Instantiate a resource method builder
1471///
1472/// ```test_harness,no_run
1473/// # extern crate hyper;
1474/// # extern crate hyper_rustls;
1475/// # extern crate google_memcache1_beta2 as memcache1_beta2;
1476/// use memcache1_beta2::api::ApplySoftwareUpdateRequest;
1477/// # async fn dox() {
1478/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1479///
1480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1482/// #     .with_native_roots()
1483/// #     .unwrap()
1484/// #     .https_only()
1485/// #     .enable_http2()
1486/// #     .build();
1487///
1488/// # let executor = hyper_util::rt::TokioExecutor::new();
1489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1490/// #     secret,
1491/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1492/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1493/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1494/// #     ),
1495/// # ).build().await.unwrap();
1496///
1497/// # let client = hyper_util::client::legacy::Client::builder(
1498/// #     hyper_util::rt::TokioExecutor::new()
1499/// # )
1500/// # .build(
1501/// #     hyper_rustls::HttpsConnectorBuilder::new()
1502/// #         .with_native_roots()
1503/// #         .unwrap()
1504/// #         .https_or_http()
1505/// #         .enable_http2()
1506/// #         .build()
1507/// # );
1508/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
1509/// // As the method needs a request, you would usually fill it with the desired information
1510/// // into the respective structure. Some of the parts shown here might not be applicable !
1511/// // Values shown here are possibly random and not representative !
1512/// let mut req = ApplySoftwareUpdateRequest::default();
1513///
1514/// // You can configure optional parameters by calling the respective setters at will, and
1515/// // execute the final call using `doit()`.
1516/// // Values shown here are possibly random and not representative !
1517/// let result = hub.projects().locations_instances_apply_software_update(req, "instance")
1518///              .doit().await;
1519/// # }
1520/// ```
1521pub struct ProjectLocationInstanceApplySoftwareUpdateCall<'a, C>
1522where
1523    C: 'a,
1524{
1525    hub: &'a CloudMemorystoreForMemcached<C>,
1526    _request: ApplySoftwareUpdateRequest,
1527    _instance: String,
1528    _delegate: Option<&'a mut dyn common::Delegate>,
1529    _additional_params: HashMap<String, String>,
1530    _scopes: BTreeSet<String>,
1531}
1532
1533impl<'a, C> common::CallBuilder for ProjectLocationInstanceApplySoftwareUpdateCall<'a, C> {}
1534
1535impl<'a, C> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C>
1536where
1537    C: common::Connector,
1538{
1539    /// Perform the operation you have build so far.
1540    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1541        use std::borrow::Cow;
1542        use std::io::{Read, Seek};
1543
1544        use common::{url::Params, ToParts};
1545        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1546
1547        let mut dd = common::DefaultDelegate;
1548        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1549        dlg.begin(common::MethodInfo {
1550            id: "memcache.projects.locations.instances.applySoftwareUpdate",
1551            http_method: hyper::Method::POST,
1552        });
1553
1554        for &field in ["alt", "instance"].iter() {
1555            if self._additional_params.contains_key(field) {
1556                dlg.finished(false);
1557                return Err(common::Error::FieldClash(field));
1558            }
1559        }
1560
1561        let mut params = Params::with_capacity(4 + self._additional_params.len());
1562        params.push("instance", self._instance);
1563
1564        params.extend(self._additional_params.iter());
1565
1566        params.push("alt", "json");
1567        let mut url = self.hub._base_url.clone() + "v1beta2/{+instance}:applySoftwareUpdate";
1568        if self._scopes.is_empty() {
1569            self._scopes
1570                .insert(Scope::CloudPlatform.as_ref().to_string());
1571        }
1572
1573        #[allow(clippy::single_element_loop)]
1574        for &(find_this, param_name) in [("{+instance}", "instance")].iter() {
1575            url = params.uri_replacement(url, param_name, find_this, true);
1576        }
1577        {
1578            let to_remove = ["instance"];
1579            params.remove_params(&to_remove);
1580        }
1581
1582        let url = params.parse_with_url(&url);
1583
1584        let mut json_mime_type = mime::APPLICATION_JSON;
1585        let mut request_value_reader = {
1586            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1587            common::remove_json_null_values(&mut value);
1588            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1589            serde_json::to_writer(&mut dst, &value).unwrap();
1590            dst
1591        };
1592        let request_size = request_value_reader
1593            .seek(std::io::SeekFrom::End(0))
1594            .unwrap();
1595        request_value_reader
1596            .seek(std::io::SeekFrom::Start(0))
1597            .unwrap();
1598
1599        loop {
1600            let token = match self
1601                .hub
1602                .auth
1603                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1604                .await
1605            {
1606                Ok(token) => token,
1607                Err(e) => match dlg.token(e) {
1608                    Ok(token) => token,
1609                    Err(e) => {
1610                        dlg.finished(false);
1611                        return Err(common::Error::MissingToken(e));
1612                    }
1613                },
1614            };
1615            request_value_reader
1616                .seek(std::io::SeekFrom::Start(0))
1617                .unwrap();
1618            let mut req_result = {
1619                let client = &self.hub.client;
1620                dlg.pre_request();
1621                let mut req_builder = hyper::Request::builder()
1622                    .method(hyper::Method::POST)
1623                    .uri(url.as_str())
1624                    .header(USER_AGENT, self.hub._user_agent.clone());
1625
1626                if let Some(token) = token.as_ref() {
1627                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1628                }
1629
1630                let request = req_builder
1631                    .header(CONTENT_TYPE, json_mime_type.to_string())
1632                    .header(CONTENT_LENGTH, request_size as u64)
1633                    .body(common::to_body(
1634                        request_value_reader.get_ref().clone().into(),
1635                    ));
1636
1637                client.request(request.unwrap()).await
1638            };
1639
1640            match req_result {
1641                Err(err) => {
1642                    if let common::Retry::After(d) = dlg.http_error(&err) {
1643                        sleep(d).await;
1644                        continue;
1645                    }
1646                    dlg.finished(false);
1647                    return Err(common::Error::HttpError(err));
1648                }
1649                Ok(res) => {
1650                    let (mut parts, body) = res.into_parts();
1651                    let mut body = common::Body::new(body);
1652                    if !parts.status.is_success() {
1653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1654                        let error = serde_json::from_str(&common::to_string(&bytes));
1655                        let response = common::to_response(parts, bytes.into());
1656
1657                        if let common::Retry::After(d) =
1658                            dlg.http_failure(&response, error.as_ref().ok())
1659                        {
1660                            sleep(d).await;
1661                            continue;
1662                        }
1663
1664                        dlg.finished(false);
1665
1666                        return Err(match error {
1667                            Ok(value) => common::Error::BadRequest(value),
1668                            _ => common::Error::Failure(response),
1669                        });
1670                    }
1671                    let response = {
1672                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1673                        let encoded = common::to_string(&bytes);
1674                        match serde_json::from_str(&encoded) {
1675                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1676                            Err(error) => {
1677                                dlg.response_json_decode_error(&encoded, &error);
1678                                return Err(common::Error::JsonDecodeError(
1679                                    encoded.to_string(),
1680                                    error,
1681                                ));
1682                            }
1683                        }
1684                    };
1685
1686                    dlg.finished(true);
1687                    return Ok(response);
1688                }
1689            }
1690        }
1691    }
1692
1693    ///
1694    /// Sets the *request* property to the given value.
1695    ///
1696    /// Even though the property as already been set when instantiating this call,
1697    /// we provide this method for API completeness.
1698    pub fn request(
1699        mut self,
1700        new_value: ApplySoftwareUpdateRequest,
1701    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C> {
1702        self._request = new_value;
1703        self
1704    }
1705    /// Required. Resource name of the Memcached instance for which software update should be applied.
1706    ///
1707    /// Sets the *instance* path property to the given value.
1708    ///
1709    /// Even though the property as already been set when instantiating this call,
1710    /// we provide this method for API completeness.
1711    pub fn instance(
1712        mut self,
1713        new_value: &str,
1714    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C> {
1715        self._instance = new_value.to_string();
1716        self
1717    }
1718    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1719    /// while executing the actual API request.
1720    ///
1721    /// ````text
1722    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1723    /// ````
1724    ///
1725    /// Sets the *delegate* property to the given value.
1726    pub fn delegate(
1727        mut self,
1728        new_value: &'a mut dyn common::Delegate,
1729    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C> {
1730        self._delegate = Some(new_value);
1731        self
1732    }
1733
1734    /// Set any additional parameter of the query string used in the request.
1735    /// It should be used to set parameters which are not yet available through their own
1736    /// setters.
1737    ///
1738    /// Please note that this method must not be used to set any of the known parameters
1739    /// which have their own setter method. If done anyway, the request will fail.
1740    ///
1741    /// # Additional Parameters
1742    ///
1743    /// * *$.xgafv* (query-string) - V1 error format.
1744    /// * *access_token* (query-string) - OAuth access token.
1745    /// * *alt* (query-string) - Data format for response.
1746    /// * *callback* (query-string) - JSONP
1747    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1748    /// * *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.
1749    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1750    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1751    /// * *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.
1752    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1753    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1754    pub fn param<T>(
1755        mut self,
1756        name: T,
1757        value: T,
1758    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C>
1759    where
1760        T: AsRef<str>,
1761    {
1762        self._additional_params
1763            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1764        self
1765    }
1766
1767    /// Identifies the authorization scope for the method you are building.
1768    ///
1769    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1770    /// [`Scope::CloudPlatform`].
1771    ///
1772    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1773    /// tokens for more than one scope.
1774    ///
1775    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1776    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1777    /// sufficient, a read-write scope will do as well.
1778    pub fn add_scope<St>(
1779        mut self,
1780        scope: St,
1781    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C>
1782    where
1783        St: AsRef<str>,
1784    {
1785        self._scopes.insert(String::from(scope.as_ref()));
1786        self
1787    }
1788    /// Identifies the authorization scope(s) for the method you are building.
1789    ///
1790    /// See [`Self::add_scope()`] for details.
1791    pub fn add_scopes<I, St>(
1792        mut self,
1793        scopes: I,
1794    ) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C>
1795    where
1796        I: IntoIterator<Item = St>,
1797        St: AsRef<str>,
1798    {
1799        self._scopes
1800            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1801        self
1802    }
1803
1804    /// Removes all scopes, and no default scope will be used either.
1805    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1806    /// for details).
1807    pub fn clear_scopes(mut self) -> ProjectLocationInstanceApplySoftwareUpdateCall<'a, C> {
1808        self._scopes.clear();
1809        self
1810    }
1811}
1812
1813/// Creates a new Instance in a given location.
1814///
1815/// A builder for the *locations.instances.create* method supported by a *project* resource.
1816/// It is not used directly, but through a [`ProjectMethods`] instance.
1817///
1818/// # Example
1819///
1820/// Instantiate a resource method builder
1821///
1822/// ```test_harness,no_run
1823/// # extern crate hyper;
1824/// # extern crate hyper_rustls;
1825/// # extern crate google_memcache1_beta2 as memcache1_beta2;
1826/// use memcache1_beta2::api::Instance;
1827/// # async fn dox() {
1828/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1829///
1830/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1831/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1832/// #     .with_native_roots()
1833/// #     .unwrap()
1834/// #     .https_only()
1835/// #     .enable_http2()
1836/// #     .build();
1837///
1838/// # let executor = hyper_util::rt::TokioExecutor::new();
1839/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1840/// #     secret,
1841/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1842/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1843/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1844/// #     ),
1845/// # ).build().await.unwrap();
1846///
1847/// # let client = hyper_util::client::legacy::Client::builder(
1848/// #     hyper_util::rt::TokioExecutor::new()
1849/// # )
1850/// # .build(
1851/// #     hyper_rustls::HttpsConnectorBuilder::new()
1852/// #         .with_native_roots()
1853/// #         .unwrap()
1854/// #         .https_or_http()
1855/// #         .enable_http2()
1856/// #         .build()
1857/// # );
1858/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
1859/// // As the method needs a request, you would usually fill it with the desired information
1860/// // into the respective structure. Some of the parts shown here might not be applicable !
1861/// // Values shown here are possibly random and not representative !
1862/// let mut req = Instance::default();
1863///
1864/// // You can configure optional parameters by calling the respective setters at will, and
1865/// // execute the final call using `doit()`.
1866/// // Values shown here are possibly random and not representative !
1867/// let result = hub.projects().locations_instances_create(req, "parent")
1868///              .instance_id("takimata")
1869///              .doit().await;
1870/// # }
1871/// ```
1872pub struct ProjectLocationInstanceCreateCall<'a, C>
1873where
1874    C: 'a,
1875{
1876    hub: &'a CloudMemorystoreForMemcached<C>,
1877    _request: Instance,
1878    _parent: String,
1879    _instance_id: Option<String>,
1880    _delegate: Option<&'a mut dyn common::Delegate>,
1881    _additional_params: HashMap<String, String>,
1882    _scopes: BTreeSet<String>,
1883}
1884
1885impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
1886
1887impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
1888where
1889    C: common::Connector,
1890{
1891    /// Perform the operation you have build so far.
1892    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1893        use std::borrow::Cow;
1894        use std::io::{Read, Seek};
1895
1896        use common::{url::Params, ToParts};
1897        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1898
1899        let mut dd = common::DefaultDelegate;
1900        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1901        dlg.begin(common::MethodInfo {
1902            id: "memcache.projects.locations.instances.create",
1903            http_method: hyper::Method::POST,
1904        });
1905
1906        for &field in ["alt", "parent", "instanceId"].iter() {
1907            if self._additional_params.contains_key(field) {
1908                dlg.finished(false);
1909                return Err(common::Error::FieldClash(field));
1910            }
1911        }
1912
1913        let mut params = Params::with_capacity(5 + self._additional_params.len());
1914        params.push("parent", self._parent);
1915        if let Some(value) = self._instance_id.as_ref() {
1916            params.push("instanceId", value);
1917        }
1918
1919        params.extend(self._additional_params.iter());
1920
1921        params.push("alt", "json");
1922        let mut url = self.hub._base_url.clone() + "v1beta2/{+parent}/instances";
1923        if self._scopes.is_empty() {
1924            self._scopes
1925                .insert(Scope::CloudPlatform.as_ref().to_string());
1926        }
1927
1928        #[allow(clippy::single_element_loop)]
1929        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1930            url = params.uri_replacement(url, param_name, find_this, true);
1931        }
1932        {
1933            let to_remove = ["parent"];
1934            params.remove_params(&to_remove);
1935        }
1936
1937        let url = params.parse_with_url(&url);
1938
1939        let mut json_mime_type = mime::APPLICATION_JSON;
1940        let mut request_value_reader = {
1941            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1942            common::remove_json_null_values(&mut value);
1943            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1944            serde_json::to_writer(&mut dst, &value).unwrap();
1945            dst
1946        };
1947        let request_size = request_value_reader
1948            .seek(std::io::SeekFrom::End(0))
1949            .unwrap();
1950        request_value_reader
1951            .seek(std::io::SeekFrom::Start(0))
1952            .unwrap();
1953
1954        loop {
1955            let token = match self
1956                .hub
1957                .auth
1958                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1959                .await
1960            {
1961                Ok(token) => token,
1962                Err(e) => match dlg.token(e) {
1963                    Ok(token) => token,
1964                    Err(e) => {
1965                        dlg.finished(false);
1966                        return Err(common::Error::MissingToken(e));
1967                    }
1968                },
1969            };
1970            request_value_reader
1971                .seek(std::io::SeekFrom::Start(0))
1972                .unwrap();
1973            let mut req_result = {
1974                let client = &self.hub.client;
1975                dlg.pre_request();
1976                let mut req_builder = hyper::Request::builder()
1977                    .method(hyper::Method::POST)
1978                    .uri(url.as_str())
1979                    .header(USER_AGENT, self.hub._user_agent.clone());
1980
1981                if let Some(token) = token.as_ref() {
1982                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1983                }
1984
1985                let request = req_builder
1986                    .header(CONTENT_TYPE, json_mime_type.to_string())
1987                    .header(CONTENT_LENGTH, request_size as u64)
1988                    .body(common::to_body(
1989                        request_value_reader.get_ref().clone().into(),
1990                    ));
1991
1992                client.request(request.unwrap()).await
1993            };
1994
1995            match req_result {
1996                Err(err) => {
1997                    if let common::Retry::After(d) = dlg.http_error(&err) {
1998                        sleep(d).await;
1999                        continue;
2000                    }
2001                    dlg.finished(false);
2002                    return Err(common::Error::HttpError(err));
2003                }
2004                Ok(res) => {
2005                    let (mut parts, body) = res.into_parts();
2006                    let mut body = common::Body::new(body);
2007                    if !parts.status.is_success() {
2008                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2009                        let error = serde_json::from_str(&common::to_string(&bytes));
2010                        let response = common::to_response(parts, bytes.into());
2011
2012                        if let common::Retry::After(d) =
2013                            dlg.http_failure(&response, error.as_ref().ok())
2014                        {
2015                            sleep(d).await;
2016                            continue;
2017                        }
2018
2019                        dlg.finished(false);
2020
2021                        return Err(match error {
2022                            Ok(value) => common::Error::BadRequest(value),
2023                            _ => common::Error::Failure(response),
2024                        });
2025                    }
2026                    let response = {
2027                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2028                        let encoded = common::to_string(&bytes);
2029                        match serde_json::from_str(&encoded) {
2030                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2031                            Err(error) => {
2032                                dlg.response_json_decode_error(&encoded, &error);
2033                                return Err(common::Error::JsonDecodeError(
2034                                    encoded.to_string(),
2035                                    error,
2036                                ));
2037                            }
2038                        }
2039                    };
2040
2041                    dlg.finished(true);
2042                    return Ok(response);
2043                }
2044            }
2045        }
2046    }
2047
2048    ///
2049    /// Sets the *request* property to the given value.
2050    ///
2051    /// Even though the property as already been set when instantiating this call,
2052    /// we provide this method for API completeness.
2053    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, C> {
2054        self._request = new_value;
2055        self
2056    }
2057    /// Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region
2058    ///
2059    /// Sets the *parent* path property to the given value.
2060    ///
2061    /// Even though the property as already been set when instantiating this call,
2062    /// we provide this method for API completeness.
2063    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
2064        self._parent = new_value.to_string();
2065        self
2066    }
2067    /// Required. The logical name of the Memcached instance in the user project with the following restrictions: * Must contain only lowercase letters, numbers, and hyphens. * Must start with a letter. * Must be between 1-40 characters. * Must end with a number or a letter. * Must be unique within the user project / location. If any of the above are not met, the API raises an invalid argument error.
2068    ///
2069    /// Sets the *instance id* query property to the given value.
2070    pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
2071        self._instance_id = Some(new_value.to_string());
2072        self
2073    }
2074    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2075    /// while executing the actual API request.
2076    ///
2077    /// ````text
2078    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2079    /// ````
2080    ///
2081    /// Sets the *delegate* property to the given value.
2082    pub fn delegate(
2083        mut self,
2084        new_value: &'a mut dyn common::Delegate,
2085    ) -> ProjectLocationInstanceCreateCall<'a, C> {
2086        self._delegate = Some(new_value);
2087        self
2088    }
2089
2090    /// Set any additional parameter of the query string used in the request.
2091    /// It should be used to set parameters which are not yet available through their own
2092    /// setters.
2093    ///
2094    /// Please note that this method must not be used to set any of the known parameters
2095    /// which have their own setter method. If done anyway, the request will fail.
2096    ///
2097    /// # Additional Parameters
2098    ///
2099    /// * *$.xgafv* (query-string) - V1 error format.
2100    /// * *access_token* (query-string) - OAuth access token.
2101    /// * *alt* (query-string) - Data format for response.
2102    /// * *callback* (query-string) - JSONP
2103    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2104    /// * *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.
2105    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2106    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2107    /// * *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.
2108    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2109    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2110    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
2111    where
2112        T: AsRef<str>,
2113    {
2114        self._additional_params
2115            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2116        self
2117    }
2118
2119    /// Identifies the authorization scope for the method you are building.
2120    ///
2121    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2122    /// [`Scope::CloudPlatform`].
2123    ///
2124    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2125    /// tokens for more than one scope.
2126    ///
2127    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2128    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2129    /// sufficient, a read-write scope will do as well.
2130    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
2131    where
2132        St: AsRef<str>,
2133    {
2134        self._scopes.insert(String::from(scope.as_ref()));
2135        self
2136    }
2137    /// Identifies the authorization scope(s) for the method you are building.
2138    ///
2139    /// See [`Self::add_scope()`] for details.
2140    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
2141    where
2142        I: IntoIterator<Item = St>,
2143        St: AsRef<str>,
2144    {
2145        self._scopes
2146            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2147        self
2148    }
2149
2150    /// Removes all scopes, and no default scope will be used either.
2151    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2152    /// for details).
2153    pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
2154        self._scopes.clear();
2155        self
2156    }
2157}
2158
2159/// Deletes a single Instance.
2160///
2161/// A builder for the *locations.instances.delete* method supported by a *project* resource.
2162/// It is not used directly, but through a [`ProjectMethods`] instance.
2163///
2164/// # Example
2165///
2166/// Instantiate a resource method builder
2167///
2168/// ```test_harness,no_run
2169/// # extern crate hyper;
2170/// # extern crate hyper_rustls;
2171/// # extern crate google_memcache1_beta2 as memcache1_beta2;
2172/// # async fn dox() {
2173/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2174///
2175/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2176/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2177/// #     .with_native_roots()
2178/// #     .unwrap()
2179/// #     .https_only()
2180/// #     .enable_http2()
2181/// #     .build();
2182///
2183/// # let executor = hyper_util::rt::TokioExecutor::new();
2184/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2185/// #     secret,
2186/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2187/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2188/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2189/// #     ),
2190/// # ).build().await.unwrap();
2191///
2192/// # let client = hyper_util::client::legacy::Client::builder(
2193/// #     hyper_util::rt::TokioExecutor::new()
2194/// # )
2195/// # .build(
2196/// #     hyper_rustls::HttpsConnectorBuilder::new()
2197/// #         .with_native_roots()
2198/// #         .unwrap()
2199/// #         .https_or_http()
2200/// #         .enable_http2()
2201/// #         .build()
2202/// # );
2203/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
2204/// // You can configure optional parameters by calling the respective setters at will, and
2205/// // execute the final call using `doit()`.
2206/// // Values shown here are possibly random and not representative !
2207/// let result = hub.projects().locations_instances_delete("name")
2208///              .doit().await;
2209/// # }
2210/// ```
2211pub struct ProjectLocationInstanceDeleteCall<'a, C>
2212where
2213    C: 'a,
2214{
2215    hub: &'a CloudMemorystoreForMemcached<C>,
2216    _name: String,
2217    _delegate: Option<&'a mut dyn common::Delegate>,
2218    _additional_params: HashMap<String, String>,
2219    _scopes: BTreeSet<String>,
2220}
2221
2222impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
2223
2224impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
2225where
2226    C: common::Connector,
2227{
2228    /// Perform the operation you have build so far.
2229    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2230        use std::borrow::Cow;
2231        use std::io::{Read, Seek};
2232
2233        use common::{url::Params, ToParts};
2234        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2235
2236        let mut dd = common::DefaultDelegate;
2237        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2238        dlg.begin(common::MethodInfo {
2239            id: "memcache.projects.locations.instances.delete",
2240            http_method: hyper::Method::DELETE,
2241        });
2242
2243        for &field in ["alt", "name"].iter() {
2244            if self._additional_params.contains_key(field) {
2245                dlg.finished(false);
2246                return Err(common::Error::FieldClash(field));
2247            }
2248        }
2249
2250        let mut params = Params::with_capacity(3 + self._additional_params.len());
2251        params.push("name", self._name);
2252
2253        params.extend(self._additional_params.iter());
2254
2255        params.push("alt", "json");
2256        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
2257        if self._scopes.is_empty() {
2258            self._scopes
2259                .insert(Scope::CloudPlatform.as_ref().to_string());
2260        }
2261
2262        #[allow(clippy::single_element_loop)]
2263        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2264            url = params.uri_replacement(url, param_name, find_this, true);
2265        }
2266        {
2267            let to_remove = ["name"];
2268            params.remove_params(&to_remove);
2269        }
2270
2271        let url = params.parse_with_url(&url);
2272
2273        loop {
2274            let token = match self
2275                .hub
2276                .auth
2277                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2278                .await
2279            {
2280                Ok(token) => token,
2281                Err(e) => match dlg.token(e) {
2282                    Ok(token) => token,
2283                    Err(e) => {
2284                        dlg.finished(false);
2285                        return Err(common::Error::MissingToken(e));
2286                    }
2287                },
2288            };
2289            let mut req_result = {
2290                let client = &self.hub.client;
2291                dlg.pre_request();
2292                let mut req_builder = hyper::Request::builder()
2293                    .method(hyper::Method::DELETE)
2294                    .uri(url.as_str())
2295                    .header(USER_AGENT, self.hub._user_agent.clone());
2296
2297                if let Some(token) = token.as_ref() {
2298                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2299                }
2300
2301                let request = req_builder
2302                    .header(CONTENT_LENGTH, 0_u64)
2303                    .body(common::to_body::<String>(None));
2304
2305                client.request(request.unwrap()).await
2306            };
2307
2308            match req_result {
2309                Err(err) => {
2310                    if let common::Retry::After(d) = dlg.http_error(&err) {
2311                        sleep(d).await;
2312                        continue;
2313                    }
2314                    dlg.finished(false);
2315                    return Err(common::Error::HttpError(err));
2316                }
2317                Ok(res) => {
2318                    let (mut parts, body) = res.into_parts();
2319                    let mut body = common::Body::new(body);
2320                    if !parts.status.is_success() {
2321                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2322                        let error = serde_json::from_str(&common::to_string(&bytes));
2323                        let response = common::to_response(parts, bytes.into());
2324
2325                        if let common::Retry::After(d) =
2326                            dlg.http_failure(&response, error.as_ref().ok())
2327                        {
2328                            sleep(d).await;
2329                            continue;
2330                        }
2331
2332                        dlg.finished(false);
2333
2334                        return Err(match error {
2335                            Ok(value) => common::Error::BadRequest(value),
2336                            _ => common::Error::Failure(response),
2337                        });
2338                    }
2339                    let response = {
2340                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2341                        let encoded = common::to_string(&bytes);
2342                        match serde_json::from_str(&encoded) {
2343                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2344                            Err(error) => {
2345                                dlg.response_json_decode_error(&encoded, &error);
2346                                return Err(common::Error::JsonDecodeError(
2347                                    encoded.to_string(),
2348                                    error,
2349                                ));
2350                            }
2351                        }
2352                    };
2353
2354                    dlg.finished(true);
2355                    return Ok(response);
2356                }
2357            }
2358        }
2359    }
2360
2361    /// Required. Memcached instance resource name in the format: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region
2362    ///
2363    /// Sets the *name* path property to the given value.
2364    ///
2365    /// Even though the property as already been set when instantiating this call,
2366    /// we provide this method for API completeness.
2367    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
2368        self._name = new_value.to_string();
2369        self
2370    }
2371    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2372    /// while executing the actual API request.
2373    ///
2374    /// ````text
2375    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2376    /// ````
2377    ///
2378    /// Sets the *delegate* property to the given value.
2379    pub fn delegate(
2380        mut self,
2381        new_value: &'a mut dyn common::Delegate,
2382    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
2383        self._delegate = Some(new_value);
2384        self
2385    }
2386
2387    /// Set any additional parameter of the query string used in the request.
2388    /// It should be used to set parameters which are not yet available through their own
2389    /// setters.
2390    ///
2391    /// Please note that this method must not be used to set any of the known parameters
2392    /// which have their own setter method. If done anyway, the request will fail.
2393    ///
2394    /// # Additional Parameters
2395    ///
2396    /// * *$.xgafv* (query-string) - V1 error format.
2397    /// * *access_token* (query-string) - OAuth access token.
2398    /// * *alt* (query-string) - Data format for response.
2399    /// * *callback* (query-string) - JSONP
2400    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2401    /// * *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.
2402    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2403    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2404    /// * *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.
2405    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2406    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2407    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
2408    where
2409        T: AsRef<str>,
2410    {
2411        self._additional_params
2412            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2413        self
2414    }
2415
2416    /// Identifies the authorization scope for the method you are building.
2417    ///
2418    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2419    /// [`Scope::CloudPlatform`].
2420    ///
2421    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2422    /// tokens for more than one scope.
2423    ///
2424    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2425    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2426    /// sufficient, a read-write scope will do as well.
2427    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
2428    where
2429        St: AsRef<str>,
2430    {
2431        self._scopes.insert(String::from(scope.as_ref()));
2432        self
2433    }
2434    /// Identifies the authorization scope(s) for the method you are building.
2435    ///
2436    /// See [`Self::add_scope()`] for details.
2437    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
2438    where
2439        I: IntoIterator<Item = St>,
2440        St: AsRef<str>,
2441    {
2442        self._scopes
2443            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2444        self
2445    }
2446
2447    /// Removes all scopes, and no default scope will be used either.
2448    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2449    /// for details).
2450    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
2451        self._scopes.clear();
2452        self
2453    }
2454}
2455
2456/// Gets details of a single Instance.
2457///
2458/// A builder for the *locations.instances.get* method supported by a *project* resource.
2459/// It is not used directly, but through a [`ProjectMethods`] instance.
2460///
2461/// # Example
2462///
2463/// Instantiate a resource method builder
2464///
2465/// ```test_harness,no_run
2466/// # extern crate hyper;
2467/// # extern crate hyper_rustls;
2468/// # extern crate google_memcache1_beta2 as memcache1_beta2;
2469/// # async fn dox() {
2470/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2471///
2472/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2473/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2474/// #     .with_native_roots()
2475/// #     .unwrap()
2476/// #     .https_only()
2477/// #     .enable_http2()
2478/// #     .build();
2479///
2480/// # let executor = hyper_util::rt::TokioExecutor::new();
2481/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2482/// #     secret,
2483/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2484/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2485/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2486/// #     ),
2487/// # ).build().await.unwrap();
2488///
2489/// # let client = hyper_util::client::legacy::Client::builder(
2490/// #     hyper_util::rt::TokioExecutor::new()
2491/// # )
2492/// # .build(
2493/// #     hyper_rustls::HttpsConnectorBuilder::new()
2494/// #         .with_native_roots()
2495/// #         .unwrap()
2496/// #         .https_or_http()
2497/// #         .enable_http2()
2498/// #         .build()
2499/// # );
2500/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
2501/// // You can configure optional parameters by calling the respective setters at will, and
2502/// // execute the final call using `doit()`.
2503/// // Values shown here are possibly random and not representative !
2504/// let result = hub.projects().locations_instances_get("name")
2505///              .doit().await;
2506/// # }
2507/// ```
2508pub struct ProjectLocationInstanceGetCall<'a, C>
2509where
2510    C: 'a,
2511{
2512    hub: &'a CloudMemorystoreForMemcached<C>,
2513    _name: String,
2514    _delegate: Option<&'a mut dyn common::Delegate>,
2515    _additional_params: HashMap<String, String>,
2516    _scopes: BTreeSet<String>,
2517}
2518
2519impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
2520
2521impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
2522where
2523    C: common::Connector,
2524{
2525    /// Perform the operation you have build so far.
2526    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
2527        use std::borrow::Cow;
2528        use std::io::{Read, Seek};
2529
2530        use common::{url::Params, ToParts};
2531        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2532
2533        let mut dd = common::DefaultDelegate;
2534        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2535        dlg.begin(common::MethodInfo {
2536            id: "memcache.projects.locations.instances.get",
2537            http_method: hyper::Method::GET,
2538        });
2539
2540        for &field in ["alt", "name"].iter() {
2541            if self._additional_params.contains_key(field) {
2542                dlg.finished(false);
2543                return Err(common::Error::FieldClash(field));
2544            }
2545        }
2546
2547        let mut params = Params::with_capacity(3 + self._additional_params.len());
2548        params.push("name", self._name);
2549
2550        params.extend(self._additional_params.iter());
2551
2552        params.push("alt", "json");
2553        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
2554        if self._scopes.is_empty() {
2555            self._scopes
2556                .insert(Scope::CloudPlatform.as_ref().to_string());
2557        }
2558
2559        #[allow(clippy::single_element_loop)]
2560        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2561            url = params.uri_replacement(url, param_name, find_this, true);
2562        }
2563        {
2564            let to_remove = ["name"];
2565            params.remove_params(&to_remove);
2566        }
2567
2568        let url = params.parse_with_url(&url);
2569
2570        loop {
2571            let token = match self
2572                .hub
2573                .auth
2574                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2575                .await
2576            {
2577                Ok(token) => token,
2578                Err(e) => match dlg.token(e) {
2579                    Ok(token) => token,
2580                    Err(e) => {
2581                        dlg.finished(false);
2582                        return Err(common::Error::MissingToken(e));
2583                    }
2584                },
2585            };
2586            let mut req_result = {
2587                let client = &self.hub.client;
2588                dlg.pre_request();
2589                let mut req_builder = hyper::Request::builder()
2590                    .method(hyper::Method::GET)
2591                    .uri(url.as_str())
2592                    .header(USER_AGENT, self.hub._user_agent.clone());
2593
2594                if let Some(token) = token.as_ref() {
2595                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2596                }
2597
2598                let request = req_builder
2599                    .header(CONTENT_LENGTH, 0_u64)
2600                    .body(common::to_body::<String>(None));
2601
2602                client.request(request.unwrap()).await
2603            };
2604
2605            match req_result {
2606                Err(err) => {
2607                    if let common::Retry::After(d) = dlg.http_error(&err) {
2608                        sleep(d).await;
2609                        continue;
2610                    }
2611                    dlg.finished(false);
2612                    return Err(common::Error::HttpError(err));
2613                }
2614                Ok(res) => {
2615                    let (mut parts, body) = res.into_parts();
2616                    let mut body = common::Body::new(body);
2617                    if !parts.status.is_success() {
2618                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2619                        let error = serde_json::from_str(&common::to_string(&bytes));
2620                        let response = common::to_response(parts, bytes.into());
2621
2622                        if let common::Retry::After(d) =
2623                            dlg.http_failure(&response, error.as_ref().ok())
2624                        {
2625                            sleep(d).await;
2626                            continue;
2627                        }
2628
2629                        dlg.finished(false);
2630
2631                        return Err(match error {
2632                            Ok(value) => common::Error::BadRequest(value),
2633                            _ => common::Error::Failure(response),
2634                        });
2635                    }
2636                    let response = {
2637                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2638                        let encoded = common::to_string(&bytes);
2639                        match serde_json::from_str(&encoded) {
2640                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2641                            Err(error) => {
2642                                dlg.response_json_decode_error(&encoded, &error);
2643                                return Err(common::Error::JsonDecodeError(
2644                                    encoded.to_string(),
2645                                    error,
2646                                ));
2647                            }
2648                        }
2649                    };
2650
2651                    dlg.finished(true);
2652                    return Ok(response);
2653                }
2654            }
2655        }
2656    }
2657
2658    /// Required. Memcached instance resource name in the format: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region
2659    ///
2660    /// Sets the *name* path property to the given value.
2661    ///
2662    /// Even though the property as already been set when instantiating this call,
2663    /// we provide this method for API completeness.
2664    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
2665        self._name = new_value.to_string();
2666        self
2667    }
2668    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2669    /// while executing the actual API request.
2670    ///
2671    /// ````text
2672    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2673    /// ````
2674    ///
2675    /// Sets the *delegate* property to the given value.
2676    pub fn delegate(
2677        mut self,
2678        new_value: &'a mut dyn common::Delegate,
2679    ) -> ProjectLocationInstanceGetCall<'a, C> {
2680        self._delegate = Some(new_value);
2681        self
2682    }
2683
2684    /// Set any additional parameter of the query string used in the request.
2685    /// It should be used to set parameters which are not yet available through their own
2686    /// setters.
2687    ///
2688    /// Please note that this method must not be used to set any of the known parameters
2689    /// which have their own setter method. If done anyway, the request will fail.
2690    ///
2691    /// # Additional Parameters
2692    ///
2693    /// * *$.xgafv* (query-string) - V1 error format.
2694    /// * *access_token* (query-string) - OAuth access token.
2695    /// * *alt* (query-string) - Data format for response.
2696    /// * *callback* (query-string) - JSONP
2697    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2698    /// * *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.
2699    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2700    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2701    /// * *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.
2702    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2703    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2704    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
2705    where
2706        T: AsRef<str>,
2707    {
2708        self._additional_params
2709            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2710        self
2711    }
2712
2713    /// Identifies the authorization scope for the method you are building.
2714    ///
2715    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2716    /// [`Scope::CloudPlatform`].
2717    ///
2718    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2719    /// tokens for more than one scope.
2720    ///
2721    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2722    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2723    /// sufficient, a read-write scope will do as well.
2724    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
2725    where
2726        St: AsRef<str>,
2727    {
2728        self._scopes.insert(String::from(scope.as_ref()));
2729        self
2730    }
2731    /// Identifies the authorization scope(s) for the method you are building.
2732    ///
2733    /// See [`Self::add_scope()`] for details.
2734    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
2735    where
2736        I: IntoIterator<Item = St>,
2737        St: AsRef<str>,
2738    {
2739        self._scopes
2740            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2741        self
2742    }
2743
2744    /// Removes all scopes, and no default scope will be used either.
2745    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2746    /// for details).
2747    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
2748        self._scopes.clear();
2749        self
2750    }
2751}
2752
2753/// Lists Instances in a given location.
2754///
2755/// A builder for the *locations.instances.list* method supported by a *project* resource.
2756/// It is not used directly, but through a [`ProjectMethods`] instance.
2757///
2758/// # Example
2759///
2760/// Instantiate a resource method builder
2761///
2762/// ```test_harness,no_run
2763/// # extern crate hyper;
2764/// # extern crate hyper_rustls;
2765/// # extern crate google_memcache1_beta2 as memcache1_beta2;
2766/// # async fn dox() {
2767/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2768///
2769/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2770/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2771/// #     .with_native_roots()
2772/// #     .unwrap()
2773/// #     .https_only()
2774/// #     .enable_http2()
2775/// #     .build();
2776///
2777/// # let executor = hyper_util::rt::TokioExecutor::new();
2778/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2779/// #     secret,
2780/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2781/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2782/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2783/// #     ),
2784/// # ).build().await.unwrap();
2785///
2786/// # let client = hyper_util::client::legacy::Client::builder(
2787/// #     hyper_util::rt::TokioExecutor::new()
2788/// # )
2789/// # .build(
2790/// #     hyper_rustls::HttpsConnectorBuilder::new()
2791/// #         .with_native_roots()
2792/// #         .unwrap()
2793/// #         .https_or_http()
2794/// #         .enable_http2()
2795/// #         .build()
2796/// # );
2797/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
2798/// // You can configure optional parameters by calling the respective setters at will, and
2799/// // execute the final call using `doit()`.
2800/// // Values shown here are possibly random and not representative !
2801/// let result = hub.projects().locations_instances_list("parent")
2802///              .page_token("gubergren")
2803///              .page_size(-51)
2804///              .order_by("gubergren")
2805///              .filter("eos")
2806///              .doit().await;
2807/// # }
2808/// ```
2809pub struct ProjectLocationInstanceListCall<'a, C>
2810where
2811    C: 'a,
2812{
2813    hub: &'a CloudMemorystoreForMemcached<C>,
2814    _parent: String,
2815    _page_token: Option<String>,
2816    _page_size: Option<i32>,
2817    _order_by: Option<String>,
2818    _filter: Option<String>,
2819    _delegate: Option<&'a mut dyn common::Delegate>,
2820    _additional_params: HashMap<String, String>,
2821    _scopes: BTreeSet<String>,
2822}
2823
2824impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
2825
2826impl<'a, C> ProjectLocationInstanceListCall<'a, C>
2827where
2828    C: common::Connector,
2829{
2830    /// Perform the operation you have build so far.
2831    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
2832        use std::borrow::Cow;
2833        use std::io::{Read, Seek};
2834
2835        use common::{url::Params, ToParts};
2836        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2837
2838        let mut dd = common::DefaultDelegate;
2839        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2840        dlg.begin(common::MethodInfo {
2841            id: "memcache.projects.locations.instances.list",
2842            http_method: hyper::Method::GET,
2843        });
2844
2845        for &field in [
2846            "alt",
2847            "parent",
2848            "pageToken",
2849            "pageSize",
2850            "orderBy",
2851            "filter",
2852        ]
2853        .iter()
2854        {
2855            if self._additional_params.contains_key(field) {
2856                dlg.finished(false);
2857                return Err(common::Error::FieldClash(field));
2858            }
2859        }
2860
2861        let mut params = Params::with_capacity(7 + self._additional_params.len());
2862        params.push("parent", self._parent);
2863        if let Some(value) = self._page_token.as_ref() {
2864            params.push("pageToken", value);
2865        }
2866        if let Some(value) = self._page_size.as_ref() {
2867            params.push("pageSize", value.to_string());
2868        }
2869        if let Some(value) = self._order_by.as_ref() {
2870            params.push("orderBy", value);
2871        }
2872        if let Some(value) = self._filter.as_ref() {
2873            params.push("filter", value);
2874        }
2875
2876        params.extend(self._additional_params.iter());
2877
2878        params.push("alt", "json");
2879        let mut url = self.hub._base_url.clone() + "v1beta2/{+parent}/instances";
2880        if self._scopes.is_empty() {
2881            self._scopes
2882                .insert(Scope::CloudPlatform.as_ref().to_string());
2883        }
2884
2885        #[allow(clippy::single_element_loop)]
2886        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2887            url = params.uri_replacement(url, param_name, find_this, true);
2888        }
2889        {
2890            let to_remove = ["parent"];
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    /// Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region
2985    ///
2986    /// Sets the *parent* path property to the given value.
2987    ///
2988    /// Even though the property as already been set when instantiating this call,
2989    /// we provide this method for API completeness.
2990    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
2991        self._parent = new_value.to_string();
2992        self
2993    }
2994    /// The `next_page_token` value returned from a previous List request, if any.
2995    ///
2996    /// Sets the *page token* query property to the given value.
2997    pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
2998        self._page_token = Some(new_value.to_string());
2999        self
3000    }
3001    /// The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the `page_size` value, the response may include a partial list and a caller should only rely on response's `next_page_token` to determine if there are more instances left to be queried.
3002    ///
3003    /// Sets the *page size* query property to the given value.
3004    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
3005        self._page_size = Some(new_value);
3006        self
3007    }
3008    /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
3009    ///
3010    /// Sets the *order by* query property to the given value.
3011    pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
3012        self._order_by = Some(new_value.to_string());
3013        self
3014    }
3015    /// List filter. For example, exclude all Memcached instances with name as my-instance by specifying `"name != my-instance"`.
3016    ///
3017    /// Sets the *filter* query property to the given value.
3018    pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
3019        self._filter = Some(new_value.to_string());
3020        self
3021    }
3022    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3023    /// while executing the actual API request.
3024    ///
3025    /// ````text
3026    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3027    /// ````
3028    ///
3029    /// Sets the *delegate* property to the given value.
3030    pub fn delegate(
3031        mut self,
3032        new_value: &'a mut dyn common::Delegate,
3033    ) -> ProjectLocationInstanceListCall<'a, C> {
3034        self._delegate = Some(new_value);
3035        self
3036    }
3037
3038    /// Set any additional parameter of the query string used in the request.
3039    /// It should be used to set parameters which are not yet available through their own
3040    /// setters.
3041    ///
3042    /// Please note that this method must not be used to set any of the known parameters
3043    /// which have their own setter method. If done anyway, the request will fail.
3044    ///
3045    /// # Additional Parameters
3046    ///
3047    /// * *$.xgafv* (query-string) - V1 error format.
3048    /// * *access_token* (query-string) - OAuth access token.
3049    /// * *alt* (query-string) - Data format for response.
3050    /// * *callback* (query-string) - JSONP
3051    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3052    /// * *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.
3053    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3054    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3055    /// * *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.
3056    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3057    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3058    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
3059    where
3060        T: AsRef<str>,
3061    {
3062        self._additional_params
3063            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3064        self
3065    }
3066
3067    /// Identifies the authorization scope for the method you are building.
3068    ///
3069    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3070    /// [`Scope::CloudPlatform`].
3071    ///
3072    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3073    /// tokens for more than one scope.
3074    ///
3075    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3076    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3077    /// sufficient, a read-write scope will do as well.
3078    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
3079    where
3080        St: AsRef<str>,
3081    {
3082        self._scopes.insert(String::from(scope.as_ref()));
3083        self
3084    }
3085    /// Identifies the authorization scope(s) for the method you are building.
3086    ///
3087    /// See [`Self::add_scope()`] for details.
3088    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
3089    where
3090        I: IntoIterator<Item = St>,
3091        St: AsRef<str>,
3092    {
3093        self._scopes
3094            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3095        self
3096    }
3097
3098    /// Removes all scopes, and no default scope will be used either.
3099    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3100    /// for details).
3101    pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
3102        self._scopes.clear();
3103        self
3104    }
3105}
3106
3107/// Updates an existing Instance in a given project and location.
3108///
3109/// A builder for the *locations.instances.patch* method supported by a *project* resource.
3110/// It is not used directly, but through a [`ProjectMethods`] instance.
3111///
3112/// # Example
3113///
3114/// Instantiate a resource method builder
3115///
3116/// ```test_harness,no_run
3117/// # extern crate hyper;
3118/// # extern crate hyper_rustls;
3119/// # extern crate google_memcache1_beta2 as memcache1_beta2;
3120/// use memcache1_beta2::api::Instance;
3121/// # async fn dox() {
3122/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3123///
3124/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3125/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3126/// #     .with_native_roots()
3127/// #     .unwrap()
3128/// #     .https_only()
3129/// #     .enable_http2()
3130/// #     .build();
3131///
3132/// # let executor = hyper_util::rt::TokioExecutor::new();
3133/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3134/// #     secret,
3135/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3136/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3137/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3138/// #     ),
3139/// # ).build().await.unwrap();
3140///
3141/// # let client = hyper_util::client::legacy::Client::builder(
3142/// #     hyper_util::rt::TokioExecutor::new()
3143/// # )
3144/// # .build(
3145/// #     hyper_rustls::HttpsConnectorBuilder::new()
3146/// #         .with_native_roots()
3147/// #         .unwrap()
3148/// #         .https_or_http()
3149/// #         .enable_http2()
3150/// #         .build()
3151/// # );
3152/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
3153/// // As the method needs a request, you would usually fill it with the desired information
3154/// // into the respective structure. Some of the parts shown here might not be applicable !
3155/// // Values shown here are possibly random and not representative !
3156/// let mut req = Instance::default();
3157///
3158/// // You can configure optional parameters by calling the respective setters at will, and
3159/// // execute the final call using `doit()`.
3160/// // Values shown here are possibly random and not representative !
3161/// let result = hub.projects().locations_instances_patch(req, "name")
3162///              .update_mask(FieldMask::new::<&str>(&[]))
3163///              .doit().await;
3164/// # }
3165/// ```
3166pub struct ProjectLocationInstancePatchCall<'a, C>
3167where
3168    C: 'a,
3169{
3170    hub: &'a CloudMemorystoreForMemcached<C>,
3171    _request: Instance,
3172    _name: String,
3173    _update_mask: Option<common::FieldMask>,
3174    _delegate: Option<&'a mut dyn common::Delegate>,
3175    _additional_params: HashMap<String, String>,
3176    _scopes: BTreeSet<String>,
3177}
3178
3179impl<'a, C> common::CallBuilder for ProjectLocationInstancePatchCall<'a, C> {}
3180
3181impl<'a, C> ProjectLocationInstancePatchCall<'a, C>
3182where
3183    C: common::Connector,
3184{
3185    /// Perform the operation you have build so far.
3186    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3187        use std::borrow::Cow;
3188        use std::io::{Read, Seek};
3189
3190        use common::{url::Params, ToParts};
3191        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3192
3193        let mut dd = common::DefaultDelegate;
3194        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3195        dlg.begin(common::MethodInfo {
3196            id: "memcache.projects.locations.instances.patch",
3197            http_method: hyper::Method::PATCH,
3198        });
3199
3200        for &field in ["alt", "name", "updateMask"].iter() {
3201            if self._additional_params.contains_key(field) {
3202                dlg.finished(false);
3203                return Err(common::Error::FieldClash(field));
3204            }
3205        }
3206
3207        let mut params = Params::with_capacity(5 + self._additional_params.len());
3208        params.push("name", self._name);
3209        if let Some(value) = self._update_mask.as_ref() {
3210            params.push("updateMask", value.to_string());
3211        }
3212
3213        params.extend(self._additional_params.iter());
3214
3215        params.push("alt", "json");
3216        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
3217        if self._scopes.is_empty() {
3218            self._scopes
3219                .insert(Scope::CloudPlatform.as_ref().to_string());
3220        }
3221
3222        #[allow(clippy::single_element_loop)]
3223        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3224            url = params.uri_replacement(url, param_name, find_this, true);
3225        }
3226        {
3227            let to_remove = ["name"];
3228            params.remove_params(&to_remove);
3229        }
3230
3231        let url = params.parse_with_url(&url);
3232
3233        let mut json_mime_type = mime::APPLICATION_JSON;
3234        let mut request_value_reader = {
3235            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3236            common::remove_json_null_values(&mut value);
3237            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3238            serde_json::to_writer(&mut dst, &value).unwrap();
3239            dst
3240        };
3241        let request_size = request_value_reader
3242            .seek(std::io::SeekFrom::End(0))
3243            .unwrap();
3244        request_value_reader
3245            .seek(std::io::SeekFrom::Start(0))
3246            .unwrap();
3247
3248        loop {
3249            let token = match self
3250                .hub
3251                .auth
3252                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3253                .await
3254            {
3255                Ok(token) => token,
3256                Err(e) => match dlg.token(e) {
3257                    Ok(token) => token,
3258                    Err(e) => {
3259                        dlg.finished(false);
3260                        return Err(common::Error::MissingToken(e));
3261                    }
3262                },
3263            };
3264            request_value_reader
3265                .seek(std::io::SeekFrom::Start(0))
3266                .unwrap();
3267            let mut req_result = {
3268                let client = &self.hub.client;
3269                dlg.pre_request();
3270                let mut req_builder = hyper::Request::builder()
3271                    .method(hyper::Method::PATCH)
3272                    .uri(url.as_str())
3273                    .header(USER_AGENT, self.hub._user_agent.clone());
3274
3275                if let Some(token) = token.as_ref() {
3276                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3277                }
3278
3279                let request = req_builder
3280                    .header(CONTENT_TYPE, json_mime_type.to_string())
3281                    .header(CONTENT_LENGTH, request_size as u64)
3282                    .body(common::to_body(
3283                        request_value_reader.get_ref().clone().into(),
3284                    ));
3285
3286                client.request(request.unwrap()).await
3287            };
3288
3289            match req_result {
3290                Err(err) => {
3291                    if let common::Retry::After(d) = dlg.http_error(&err) {
3292                        sleep(d).await;
3293                        continue;
3294                    }
3295                    dlg.finished(false);
3296                    return Err(common::Error::HttpError(err));
3297                }
3298                Ok(res) => {
3299                    let (mut parts, body) = res.into_parts();
3300                    let mut body = common::Body::new(body);
3301                    if !parts.status.is_success() {
3302                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3303                        let error = serde_json::from_str(&common::to_string(&bytes));
3304                        let response = common::to_response(parts, bytes.into());
3305
3306                        if let common::Retry::After(d) =
3307                            dlg.http_failure(&response, error.as_ref().ok())
3308                        {
3309                            sleep(d).await;
3310                            continue;
3311                        }
3312
3313                        dlg.finished(false);
3314
3315                        return Err(match error {
3316                            Ok(value) => common::Error::BadRequest(value),
3317                            _ => common::Error::Failure(response),
3318                        });
3319                    }
3320                    let response = {
3321                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3322                        let encoded = common::to_string(&bytes);
3323                        match serde_json::from_str(&encoded) {
3324                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3325                            Err(error) => {
3326                                dlg.response_json_decode_error(&encoded, &error);
3327                                return Err(common::Error::JsonDecodeError(
3328                                    encoded.to_string(),
3329                                    error,
3330                                ));
3331                            }
3332                        }
3333                    };
3334
3335                    dlg.finished(true);
3336                    return Ok(response);
3337                }
3338            }
3339        }
3340    }
3341
3342    ///
3343    /// Sets the *request* property to the given value.
3344    ///
3345    /// Even though the property as already been set when instantiating this call,
3346    /// we provide this method for API completeness.
3347    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, C> {
3348        self._request = new_value;
3349        self
3350    }
3351    /// Required. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` Note: Memcached instances are managed and addressed at the regional level so `location_id` here refers to a Google Cloud region; however, users may choose which zones Memcached nodes should be provisioned in within an instance. Refer to zones field for more details.
3352    ///
3353    /// Sets the *name* path property to the given value.
3354    ///
3355    /// Even though the property as already been set when instantiating this call,
3356    /// we provide this method for API completeness.
3357    pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, C> {
3358        self._name = new_value.to_string();
3359        self
3360    }
3361    /// Required. Mask of fields to update. * `displayName`
3362    ///
3363    /// Sets the *update mask* query property to the given value.
3364    pub fn update_mask(
3365        mut self,
3366        new_value: common::FieldMask,
3367    ) -> ProjectLocationInstancePatchCall<'a, C> {
3368        self._update_mask = Some(new_value);
3369        self
3370    }
3371    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3372    /// while executing the actual API request.
3373    ///
3374    /// ````text
3375    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3376    /// ````
3377    ///
3378    /// Sets the *delegate* property to the given value.
3379    pub fn delegate(
3380        mut self,
3381        new_value: &'a mut dyn common::Delegate,
3382    ) -> ProjectLocationInstancePatchCall<'a, C> {
3383        self._delegate = Some(new_value);
3384        self
3385    }
3386
3387    /// Set any additional parameter of the query string used in the request.
3388    /// It should be used to set parameters which are not yet available through their own
3389    /// setters.
3390    ///
3391    /// Please note that this method must not be used to set any of the known parameters
3392    /// which have their own setter method. If done anyway, the request will fail.
3393    ///
3394    /// # Additional Parameters
3395    ///
3396    /// * *$.xgafv* (query-string) - V1 error format.
3397    /// * *access_token* (query-string) - OAuth access token.
3398    /// * *alt* (query-string) - Data format for response.
3399    /// * *callback* (query-string) - JSONP
3400    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3401    /// * *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.
3402    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3403    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3404    /// * *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.
3405    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3406    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3407    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, C>
3408    where
3409        T: AsRef<str>,
3410    {
3411        self._additional_params
3412            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3413        self
3414    }
3415
3416    /// Identifies the authorization scope for the method you are building.
3417    ///
3418    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3419    /// [`Scope::CloudPlatform`].
3420    ///
3421    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3422    /// tokens for more than one scope.
3423    ///
3424    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3425    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3426    /// sufficient, a read-write scope will do as well.
3427    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, C>
3428    where
3429        St: AsRef<str>,
3430    {
3431        self._scopes.insert(String::from(scope.as_ref()));
3432        self
3433    }
3434    /// Identifies the authorization scope(s) for the method you are building.
3435    ///
3436    /// See [`Self::add_scope()`] for details.
3437    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, C>
3438    where
3439        I: IntoIterator<Item = St>,
3440        St: AsRef<str>,
3441    {
3442        self._scopes
3443            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3444        self
3445    }
3446
3447    /// Removes all scopes, and no default scope will be used either.
3448    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3449    /// for details).
3450    pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, C> {
3451        self._scopes.clear();
3452        self
3453    }
3454}
3455
3456/// Performs the apply phase of the RescheduleMaintenance verb.
3457///
3458/// A builder for the *locations.instances.rescheduleMaintenance* method supported by a *project* resource.
3459/// It is not used directly, but through a [`ProjectMethods`] instance.
3460///
3461/// # Example
3462///
3463/// Instantiate a resource method builder
3464///
3465/// ```test_harness,no_run
3466/// # extern crate hyper;
3467/// # extern crate hyper_rustls;
3468/// # extern crate google_memcache1_beta2 as memcache1_beta2;
3469/// use memcache1_beta2::api::RescheduleMaintenanceRequest;
3470/// # async fn dox() {
3471/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3472///
3473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3474/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3475/// #     .with_native_roots()
3476/// #     .unwrap()
3477/// #     .https_only()
3478/// #     .enable_http2()
3479/// #     .build();
3480///
3481/// # let executor = hyper_util::rt::TokioExecutor::new();
3482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3483/// #     secret,
3484/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3485/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3486/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3487/// #     ),
3488/// # ).build().await.unwrap();
3489///
3490/// # let client = hyper_util::client::legacy::Client::builder(
3491/// #     hyper_util::rt::TokioExecutor::new()
3492/// # )
3493/// # .build(
3494/// #     hyper_rustls::HttpsConnectorBuilder::new()
3495/// #         .with_native_roots()
3496/// #         .unwrap()
3497/// #         .https_or_http()
3498/// #         .enable_http2()
3499/// #         .build()
3500/// # );
3501/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
3502/// // As the method needs a request, you would usually fill it with the desired information
3503/// // into the respective structure. Some of the parts shown here might not be applicable !
3504/// // Values shown here are possibly random and not representative !
3505/// let mut req = RescheduleMaintenanceRequest::default();
3506///
3507/// // You can configure optional parameters by calling the respective setters at will, and
3508/// // execute the final call using `doit()`.
3509/// // Values shown here are possibly random and not representative !
3510/// let result = hub.projects().locations_instances_reschedule_maintenance(req, "instance")
3511///              .doit().await;
3512/// # }
3513/// ```
3514pub struct ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
3515where
3516    C: 'a,
3517{
3518    hub: &'a CloudMemorystoreForMemcached<C>,
3519    _request: RescheduleMaintenanceRequest,
3520    _instance: String,
3521    _delegate: Option<&'a mut dyn common::Delegate>,
3522    _additional_params: HashMap<String, String>,
3523    _scopes: BTreeSet<String>,
3524}
3525
3526impl<'a, C> common::CallBuilder for ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {}
3527
3528impl<'a, C> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
3529where
3530    C: common::Connector,
3531{
3532    /// Perform the operation you have build so far.
3533    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3534        use std::borrow::Cow;
3535        use std::io::{Read, Seek};
3536
3537        use common::{url::Params, ToParts};
3538        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3539
3540        let mut dd = common::DefaultDelegate;
3541        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3542        dlg.begin(common::MethodInfo {
3543            id: "memcache.projects.locations.instances.rescheduleMaintenance",
3544            http_method: hyper::Method::POST,
3545        });
3546
3547        for &field in ["alt", "instance"].iter() {
3548            if self._additional_params.contains_key(field) {
3549                dlg.finished(false);
3550                return Err(common::Error::FieldClash(field));
3551            }
3552        }
3553
3554        let mut params = Params::with_capacity(4 + self._additional_params.len());
3555        params.push("instance", self._instance);
3556
3557        params.extend(self._additional_params.iter());
3558
3559        params.push("alt", "json");
3560        let mut url = self.hub._base_url.clone() + "v1beta2/{+instance}:rescheduleMaintenance";
3561        if self._scopes.is_empty() {
3562            self._scopes
3563                .insert(Scope::CloudPlatform.as_ref().to_string());
3564        }
3565
3566        #[allow(clippy::single_element_loop)]
3567        for &(find_this, param_name) in [("{+instance}", "instance")].iter() {
3568            url = params.uri_replacement(url, param_name, find_this, true);
3569        }
3570        {
3571            let to_remove = ["instance"];
3572            params.remove_params(&to_remove);
3573        }
3574
3575        let url = params.parse_with_url(&url);
3576
3577        let mut json_mime_type = mime::APPLICATION_JSON;
3578        let mut request_value_reader = {
3579            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3580            common::remove_json_null_values(&mut value);
3581            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3582            serde_json::to_writer(&mut dst, &value).unwrap();
3583            dst
3584        };
3585        let request_size = request_value_reader
3586            .seek(std::io::SeekFrom::End(0))
3587            .unwrap();
3588        request_value_reader
3589            .seek(std::io::SeekFrom::Start(0))
3590            .unwrap();
3591
3592        loop {
3593            let token = match self
3594                .hub
3595                .auth
3596                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3597                .await
3598            {
3599                Ok(token) => token,
3600                Err(e) => match dlg.token(e) {
3601                    Ok(token) => token,
3602                    Err(e) => {
3603                        dlg.finished(false);
3604                        return Err(common::Error::MissingToken(e));
3605                    }
3606                },
3607            };
3608            request_value_reader
3609                .seek(std::io::SeekFrom::Start(0))
3610                .unwrap();
3611            let mut req_result = {
3612                let client = &self.hub.client;
3613                dlg.pre_request();
3614                let mut req_builder = hyper::Request::builder()
3615                    .method(hyper::Method::POST)
3616                    .uri(url.as_str())
3617                    .header(USER_AGENT, self.hub._user_agent.clone());
3618
3619                if let Some(token) = token.as_ref() {
3620                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3621                }
3622
3623                let request = req_builder
3624                    .header(CONTENT_TYPE, json_mime_type.to_string())
3625                    .header(CONTENT_LENGTH, request_size as u64)
3626                    .body(common::to_body(
3627                        request_value_reader.get_ref().clone().into(),
3628                    ));
3629
3630                client.request(request.unwrap()).await
3631            };
3632
3633            match req_result {
3634                Err(err) => {
3635                    if let common::Retry::After(d) = dlg.http_error(&err) {
3636                        sleep(d).await;
3637                        continue;
3638                    }
3639                    dlg.finished(false);
3640                    return Err(common::Error::HttpError(err));
3641                }
3642                Ok(res) => {
3643                    let (mut parts, body) = res.into_parts();
3644                    let mut body = common::Body::new(body);
3645                    if !parts.status.is_success() {
3646                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3647                        let error = serde_json::from_str(&common::to_string(&bytes));
3648                        let response = common::to_response(parts, bytes.into());
3649
3650                        if let common::Retry::After(d) =
3651                            dlg.http_failure(&response, error.as_ref().ok())
3652                        {
3653                            sleep(d).await;
3654                            continue;
3655                        }
3656
3657                        dlg.finished(false);
3658
3659                        return Err(match error {
3660                            Ok(value) => common::Error::BadRequest(value),
3661                            _ => common::Error::Failure(response),
3662                        });
3663                    }
3664                    let response = {
3665                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3666                        let encoded = common::to_string(&bytes);
3667                        match serde_json::from_str(&encoded) {
3668                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3669                            Err(error) => {
3670                                dlg.response_json_decode_error(&encoded, &error);
3671                                return Err(common::Error::JsonDecodeError(
3672                                    encoded.to_string(),
3673                                    error,
3674                                ));
3675                            }
3676                        }
3677                    };
3678
3679                    dlg.finished(true);
3680                    return Ok(response);
3681                }
3682            }
3683        }
3684    }
3685
3686    ///
3687    /// Sets the *request* property to the given value.
3688    ///
3689    /// Even though the property as already been set when instantiating this call,
3690    /// we provide this method for API completeness.
3691    pub fn request(
3692        mut self,
3693        new_value: RescheduleMaintenanceRequest,
3694    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
3695        self._request = new_value;
3696        self
3697    }
3698    /// Required. Memcache instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
3699    ///
3700    /// Sets the *instance* path property to the given value.
3701    ///
3702    /// Even though the property as already been set when instantiating this call,
3703    /// we provide this method for API completeness.
3704    pub fn instance(
3705        mut self,
3706        new_value: &str,
3707    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
3708        self._instance = new_value.to_string();
3709        self
3710    }
3711    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3712    /// while executing the actual API request.
3713    ///
3714    /// ````text
3715    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3716    /// ````
3717    ///
3718    /// Sets the *delegate* property to the given value.
3719    pub fn delegate(
3720        mut self,
3721        new_value: &'a mut dyn common::Delegate,
3722    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
3723        self._delegate = Some(new_value);
3724        self
3725    }
3726
3727    /// Set any additional parameter of the query string used in the request.
3728    /// It should be used to set parameters which are not yet available through their own
3729    /// setters.
3730    ///
3731    /// Please note that this method must not be used to set any of the known parameters
3732    /// which have their own setter method. If done anyway, the request will fail.
3733    ///
3734    /// # Additional Parameters
3735    ///
3736    /// * *$.xgafv* (query-string) - V1 error format.
3737    /// * *access_token* (query-string) - OAuth access token.
3738    /// * *alt* (query-string) - Data format for response.
3739    /// * *callback* (query-string) - JSONP
3740    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3741    /// * *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.
3742    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3743    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3744    /// * *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.
3745    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3746    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3747    pub fn param<T>(
3748        mut self,
3749        name: T,
3750        value: T,
3751    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
3752    where
3753        T: AsRef<str>,
3754    {
3755        self._additional_params
3756            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3757        self
3758    }
3759
3760    /// Identifies the authorization scope for the method you are building.
3761    ///
3762    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3763    /// [`Scope::CloudPlatform`].
3764    ///
3765    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3766    /// tokens for more than one scope.
3767    ///
3768    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3769    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3770    /// sufficient, a read-write scope will do as well.
3771    pub fn add_scope<St>(
3772        mut self,
3773        scope: St,
3774    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
3775    where
3776        St: AsRef<str>,
3777    {
3778        self._scopes.insert(String::from(scope.as_ref()));
3779        self
3780    }
3781    /// Identifies the authorization scope(s) for the method you are building.
3782    ///
3783    /// See [`Self::add_scope()`] for details.
3784    pub fn add_scopes<I, St>(
3785        mut self,
3786        scopes: I,
3787    ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
3788    where
3789        I: IntoIterator<Item = St>,
3790        St: AsRef<str>,
3791    {
3792        self._scopes
3793            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3794        self
3795    }
3796
3797    /// Removes all scopes, and no default scope will be used either.
3798    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3799    /// for details).
3800    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
3801        self._scopes.clear();
3802        self
3803    }
3804}
3805
3806/// Updates the defined Memcached parameters for an existing instance. This method only stages the parameters, it must be followed by `ApplyParameters` to apply the parameters to nodes of the Memcached instance.
3807///
3808/// A builder for the *locations.instances.updateParameters* method supported by a *project* resource.
3809/// It is not used directly, but through a [`ProjectMethods`] instance.
3810///
3811/// # Example
3812///
3813/// Instantiate a resource method builder
3814///
3815/// ```test_harness,no_run
3816/// # extern crate hyper;
3817/// # extern crate hyper_rustls;
3818/// # extern crate google_memcache1_beta2 as memcache1_beta2;
3819/// use memcache1_beta2::api::UpdateParametersRequest;
3820/// # async fn dox() {
3821/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3822///
3823/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3824/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3825/// #     .with_native_roots()
3826/// #     .unwrap()
3827/// #     .https_only()
3828/// #     .enable_http2()
3829/// #     .build();
3830///
3831/// # let executor = hyper_util::rt::TokioExecutor::new();
3832/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3833/// #     secret,
3834/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3835/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3836/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3837/// #     ),
3838/// # ).build().await.unwrap();
3839///
3840/// # let client = hyper_util::client::legacy::Client::builder(
3841/// #     hyper_util::rt::TokioExecutor::new()
3842/// # )
3843/// # .build(
3844/// #     hyper_rustls::HttpsConnectorBuilder::new()
3845/// #         .with_native_roots()
3846/// #         .unwrap()
3847/// #         .https_or_http()
3848/// #         .enable_http2()
3849/// #         .build()
3850/// # );
3851/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
3852/// // As the method needs a request, you would usually fill it with the desired information
3853/// // into the respective structure. Some of the parts shown here might not be applicable !
3854/// // Values shown here are possibly random and not representative !
3855/// let mut req = UpdateParametersRequest::default();
3856///
3857/// // You can configure optional parameters by calling the respective setters at will, and
3858/// // execute the final call using `doit()`.
3859/// // Values shown here are possibly random and not representative !
3860/// let result = hub.projects().locations_instances_update_parameters(req, "name")
3861///              .doit().await;
3862/// # }
3863/// ```
3864pub struct ProjectLocationInstanceUpdateParameterCall<'a, C>
3865where
3866    C: 'a,
3867{
3868    hub: &'a CloudMemorystoreForMemcached<C>,
3869    _request: UpdateParametersRequest,
3870    _name: String,
3871    _delegate: Option<&'a mut dyn common::Delegate>,
3872    _additional_params: HashMap<String, String>,
3873    _scopes: BTreeSet<String>,
3874}
3875
3876impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateParameterCall<'a, C> {}
3877
3878impl<'a, C> ProjectLocationInstanceUpdateParameterCall<'a, C>
3879where
3880    C: common::Connector,
3881{
3882    /// Perform the operation you have build so far.
3883    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3884        use std::borrow::Cow;
3885        use std::io::{Read, Seek};
3886
3887        use common::{url::Params, ToParts};
3888        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3889
3890        let mut dd = common::DefaultDelegate;
3891        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3892        dlg.begin(common::MethodInfo {
3893            id: "memcache.projects.locations.instances.updateParameters",
3894            http_method: hyper::Method::PATCH,
3895        });
3896
3897        for &field in ["alt", "name"].iter() {
3898            if self._additional_params.contains_key(field) {
3899                dlg.finished(false);
3900                return Err(common::Error::FieldClash(field));
3901            }
3902        }
3903
3904        let mut params = Params::with_capacity(4 + self._additional_params.len());
3905        params.push("name", self._name);
3906
3907        params.extend(self._additional_params.iter());
3908
3909        params.push("alt", "json");
3910        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}:updateParameters";
3911        if self._scopes.is_empty() {
3912            self._scopes
3913                .insert(Scope::CloudPlatform.as_ref().to_string());
3914        }
3915
3916        #[allow(clippy::single_element_loop)]
3917        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3918            url = params.uri_replacement(url, param_name, find_this, true);
3919        }
3920        {
3921            let to_remove = ["name"];
3922            params.remove_params(&to_remove);
3923        }
3924
3925        let url = params.parse_with_url(&url);
3926
3927        let mut json_mime_type = mime::APPLICATION_JSON;
3928        let mut request_value_reader = {
3929            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3930            common::remove_json_null_values(&mut value);
3931            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3932            serde_json::to_writer(&mut dst, &value).unwrap();
3933            dst
3934        };
3935        let request_size = request_value_reader
3936            .seek(std::io::SeekFrom::End(0))
3937            .unwrap();
3938        request_value_reader
3939            .seek(std::io::SeekFrom::Start(0))
3940            .unwrap();
3941
3942        loop {
3943            let token = match self
3944                .hub
3945                .auth
3946                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3947                .await
3948            {
3949                Ok(token) => token,
3950                Err(e) => match dlg.token(e) {
3951                    Ok(token) => token,
3952                    Err(e) => {
3953                        dlg.finished(false);
3954                        return Err(common::Error::MissingToken(e));
3955                    }
3956                },
3957            };
3958            request_value_reader
3959                .seek(std::io::SeekFrom::Start(0))
3960                .unwrap();
3961            let mut req_result = {
3962                let client = &self.hub.client;
3963                dlg.pre_request();
3964                let mut req_builder = hyper::Request::builder()
3965                    .method(hyper::Method::PATCH)
3966                    .uri(url.as_str())
3967                    .header(USER_AGENT, self.hub._user_agent.clone());
3968
3969                if let Some(token) = token.as_ref() {
3970                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3971                }
3972
3973                let request = req_builder
3974                    .header(CONTENT_TYPE, json_mime_type.to_string())
3975                    .header(CONTENT_LENGTH, request_size as u64)
3976                    .body(common::to_body(
3977                        request_value_reader.get_ref().clone().into(),
3978                    ));
3979
3980                client.request(request.unwrap()).await
3981            };
3982
3983            match req_result {
3984                Err(err) => {
3985                    if let common::Retry::After(d) = dlg.http_error(&err) {
3986                        sleep(d).await;
3987                        continue;
3988                    }
3989                    dlg.finished(false);
3990                    return Err(common::Error::HttpError(err));
3991                }
3992                Ok(res) => {
3993                    let (mut parts, body) = res.into_parts();
3994                    let mut body = common::Body::new(body);
3995                    if !parts.status.is_success() {
3996                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3997                        let error = serde_json::from_str(&common::to_string(&bytes));
3998                        let response = common::to_response(parts, bytes.into());
3999
4000                        if let common::Retry::After(d) =
4001                            dlg.http_failure(&response, error.as_ref().ok())
4002                        {
4003                            sleep(d).await;
4004                            continue;
4005                        }
4006
4007                        dlg.finished(false);
4008
4009                        return Err(match error {
4010                            Ok(value) => common::Error::BadRequest(value),
4011                            _ => common::Error::Failure(response),
4012                        });
4013                    }
4014                    let response = {
4015                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4016                        let encoded = common::to_string(&bytes);
4017                        match serde_json::from_str(&encoded) {
4018                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4019                            Err(error) => {
4020                                dlg.response_json_decode_error(&encoded, &error);
4021                                return Err(common::Error::JsonDecodeError(
4022                                    encoded.to_string(),
4023                                    error,
4024                                ));
4025                            }
4026                        }
4027                    };
4028
4029                    dlg.finished(true);
4030                    return Ok(response);
4031                }
4032            }
4033        }
4034    }
4035
4036    ///
4037    /// Sets the *request* property to the given value.
4038    ///
4039    /// Even though the property as already been set when instantiating this call,
4040    /// we provide this method for API completeness.
4041    pub fn request(
4042        mut self,
4043        new_value: UpdateParametersRequest,
4044    ) -> ProjectLocationInstanceUpdateParameterCall<'a, C> {
4045        self._request = new_value;
4046        self
4047    }
4048    /// Required. Resource name of the Memcached instance for which the parameters should be updated.
4049    ///
4050    /// Sets the *name* path property to the given value.
4051    ///
4052    /// Even though the property as already been set when instantiating this call,
4053    /// we provide this method for API completeness.
4054    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpdateParameterCall<'a, C> {
4055        self._name = new_value.to_string();
4056        self
4057    }
4058    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4059    /// while executing the actual API request.
4060    ///
4061    /// ````text
4062    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4063    /// ````
4064    ///
4065    /// Sets the *delegate* property to the given value.
4066    pub fn delegate(
4067        mut self,
4068        new_value: &'a mut dyn common::Delegate,
4069    ) -> ProjectLocationInstanceUpdateParameterCall<'a, C> {
4070        self._delegate = Some(new_value);
4071        self
4072    }
4073
4074    /// Set any additional parameter of the query string used in the request.
4075    /// It should be used to set parameters which are not yet available through their own
4076    /// setters.
4077    ///
4078    /// Please note that this method must not be used to set any of the known parameters
4079    /// which have their own setter method. If done anyway, the request will fail.
4080    ///
4081    /// # Additional Parameters
4082    ///
4083    /// * *$.xgafv* (query-string) - V1 error format.
4084    /// * *access_token* (query-string) - OAuth access token.
4085    /// * *alt* (query-string) - Data format for response.
4086    /// * *callback* (query-string) - JSONP
4087    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4088    /// * *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.
4089    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4090    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4091    /// * *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.
4092    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4093    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4094    pub fn param<T>(
4095        mut self,
4096        name: T,
4097        value: T,
4098    ) -> ProjectLocationInstanceUpdateParameterCall<'a, C>
4099    where
4100        T: AsRef<str>,
4101    {
4102        self._additional_params
4103            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4104        self
4105    }
4106
4107    /// Identifies the authorization scope for the method you are building.
4108    ///
4109    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4110    /// [`Scope::CloudPlatform`].
4111    ///
4112    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4113    /// tokens for more than one scope.
4114    ///
4115    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4116    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4117    /// sufficient, a read-write scope will do as well.
4118    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpdateParameterCall<'a, C>
4119    where
4120        St: AsRef<str>,
4121    {
4122        self._scopes.insert(String::from(scope.as_ref()));
4123        self
4124    }
4125    /// Identifies the authorization scope(s) for the method you are building.
4126    ///
4127    /// See [`Self::add_scope()`] for details.
4128    pub fn add_scopes<I, St>(
4129        mut self,
4130        scopes: I,
4131    ) -> ProjectLocationInstanceUpdateParameterCall<'a, C>
4132    where
4133        I: IntoIterator<Item = St>,
4134        St: AsRef<str>,
4135    {
4136        self._scopes
4137            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4138        self
4139    }
4140
4141    /// Removes all scopes, and no default scope will be used either.
4142    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4143    /// for details).
4144    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpdateParameterCall<'a, C> {
4145        self._scopes.clear();
4146        self
4147    }
4148}
4149
4150/// Upgrades the Memcache instance to a newer memcached engine version specified in the request.
4151///
4152/// A builder for the *locations.instances.upgrade* method supported by a *project* resource.
4153/// It is not used directly, but through a [`ProjectMethods`] instance.
4154///
4155/// # Example
4156///
4157/// Instantiate a resource method builder
4158///
4159/// ```test_harness,no_run
4160/// # extern crate hyper;
4161/// # extern crate hyper_rustls;
4162/// # extern crate google_memcache1_beta2 as memcache1_beta2;
4163/// use memcache1_beta2::api::GoogleCloudMemcacheV1beta2UpgradeInstanceRequest;
4164/// # async fn dox() {
4165/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4166///
4167/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4168/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4169/// #     .with_native_roots()
4170/// #     .unwrap()
4171/// #     .https_only()
4172/// #     .enable_http2()
4173/// #     .build();
4174///
4175/// # let executor = hyper_util::rt::TokioExecutor::new();
4176/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4177/// #     secret,
4178/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4179/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4180/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4181/// #     ),
4182/// # ).build().await.unwrap();
4183///
4184/// # let client = hyper_util::client::legacy::Client::builder(
4185/// #     hyper_util::rt::TokioExecutor::new()
4186/// # )
4187/// # .build(
4188/// #     hyper_rustls::HttpsConnectorBuilder::new()
4189/// #         .with_native_roots()
4190/// #         .unwrap()
4191/// #         .https_or_http()
4192/// #         .enable_http2()
4193/// #         .build()
4194/// # );
4195/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
4196/// // As the method needs a request, you would usually fill it with the desired information
4197/// // into the respective structure. Some of the parts shown here might not be applicable !
4198/// // Values shown here are possibly random and not representative !
4199/// let mut req = GoogleCloudMemcacheV1beta2UpgradeInstanceRequest::default();
4200///
4201/// // You can configure optional parameters by calling the respective setters at will, and
4202/// // execute the final call using `doit()`.
4203/// // Values shown here are possibly random and not representative !
4204/// let result = hub.projects().locations_instances_upgrade(req, "name")
4205///              .doit().await;
4206/// # }
4207/// ```
4208pub struct ProjectLocationInstanceUpgradeCall<'a, C>
4209where
4210    C: 'a,
4211{
4212    hub: &'a CloudMemorystoreForMemcached<C>,
4213    _request: GoogleCloudMemcacheV1beta2UpgradeInstanceRequest,
4214    _name: String,
4215    _delegate: Option<&'a mut dyn common::Delegate>,
4216    _additional_params: HashMap<String, String>,
4217    _scopes: BTreeSet<String>,
4218}
4219
4220impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpgradeCall<'a, C> {}
4221
4222impl<'a, C> ProjectLocationInstanceUpgradeCall<'a, C>
4223where
4224    C: common::Connector,
4225{
4226    /// Perform the operation you have build so far.
4227    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4228        use std::borrow::Cow;
4229        use std::io::{Read, Seek};
4230
4231        use common::{url::Params, ToParts};
4232        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4233
4234        let mut dd = common::DefaultDelegate;
4235        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4236        dlg.begin(common::MethodInfo {
4237            id: "memcache.projects.locations.instances.upgrade",
4238            http_method: hyper::Method::POST,
4239        });
4240
4241        for &field in ["alt", "name"].iter() {
4242            if self._additional_params.contains_key(field) {
4243                dlg.finished(false);
4244                return Err(common::Error::FieldClash(field));
4245            }
4246        }
4247
4248        let mut params = Params::with_capacity(4 + self._additional_params.len());
4249        params.push("name", self._name);
4250
4251        params.extend(self._additional_params.iter());
4252
4253        params.push("alt", "json");
4254        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}:upgrade";
4255        if self._scopes.is_empty() {
4256            self._scopes
4257                .insert(Scope::CloudPlatform.as_ref().to_string());
4258        }
4259
4260        #[allow(clippy::single_element_loop)]
4261        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4262            url = params.uri_replacement(url, param_name, find_this, true);
4263        }
4264        {
4265            let to_remove = ["name"];
4266            params.remove_params(&to_remove);
4267        }
4268
4269        let url = params.parse_with_url(&url);
4270
4271        let mut json_mime_type = mime::APPLICATION_JSON;
4272        let mut request_value_reader = {
4273            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4274            common::remove_json_null_values(&mut value);
4275            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4276            serde_json::to_writer(&mut dst, &value).unwrap();
4277            dst
4278        };
4279        let request_size = request_value_reader
4280            .seek(std::io::SeekFrom::End(0))
4281            .unwrap();
4282        request_value_reader
4283            .seek(std::io::SeekFrom::Start(0))
4284            .unwrap();
4285
4286        loop {
4287            let token = match self
4288                .hub
4289                .auth
4290                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4291                .await
4292            {
4293                Ok(token) => token,
4294                Err(e) => match dlg.token(e) {
4295                    Ok(token) => token,
4296                    Err(e) => {
4297                        dlg.finished(false);
4298                        return Err(common::Error::MissingToken(e));
4299                    }
4300                },
4301            };
4302            request_value_reader
4303                .seek(std::io::SeekFrom::Start(0))
4304                .unwrap();
4305            let mut req_result = {
4306                let client = &self.hub.client;
4307                dlg.pre_request();
4308                let mut req_builder = hyper::Request::builder()
4309                    .method(hyper::Method::POST)
4310                    .uri(url.as_str())
4311                    .header(USER_AGENT, self.hub._user_agent.clone());
4312
4313                if let Some(token) = token.as_ref() {
4314                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4315                }
4316
4317                let request = req_builder
4318                    .header(CONTENT_TYPE, json_mime_type.to_string())
4319                    .header(CONTENT_LENGTH, request_size as u64)
4320                    .body(common::to_body(
4321                        request_value_reader.get_ref().clone().into(),
4322                    ));
4323
4324                client.request(request.unwrap()).await
4325            };
4326
4327            match req_result {
4328                Err(err) => {
4329                    if let common::Retry::After(d) = dlg.http_error(&err) {
4330                        sleep(d).await;
4331                        continue;
4332                    }
4333                    dlg.finished(false);
4334                    return Err(common::Error::HttpError(err));
4335                }
4336                Ok(res) => {
4337                    let (mut parts, body) = res.into_parts();
4338                    let mut body = common::Body::new(body);
4339                    if !parts.status.is_success() {
4340                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4341                        let error = serde_json::from_str(&common::to_string(&bytes));
4342                        let response = common::to_response(parts, bytes.into());
4343
4344                        if let common::Retry::After(d) =
4345                            dlg.http_failure(&response, error.as_ref().ok())
4346                        {
4347                            sleep(d).await;
4348                            continue;
4349                        }
4350
4351                        dlg.finished(false);
4352
4353                        return Err(match error {
4354                            Ok(value) => common::Error::BadRequest(value),
4355                            _ => common::Error::Failure(response),
4356                        });
4357                    }
4358                    let response = {
4359                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4360                        let encoded = common::to_string(&bytes);
4361                        match serde_json::from_str(&encoded) {
4362                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4363                            Err(error) => {
4364                                dlg.response_json_decode_error(&encoded, &error);
4365                                return Err(common::Error::JsonDecodeError(
4366                                    encoded.to_string(),
4367                                    error,
4368                                ));
4369                            }
4370                        }
4371                    };
4372
4373                    dlg.finished(true);
4374                    return Ok(response);
4375                }
4376            }
4377        }
4378    }
4379
4380    ///
4381    /// Sets the *request* property to the given value.
4382    ///
4383    /// Even though the property as already been set when instantiating this call,
4384    /// we provide this method for API completeness.
4385    pub fn request(
4386        mut self,
4387        new_value: GoogleCloudMemcacheV1beta2UpgradeInstanceRequest,
4388    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
4389        self._request = new_value;
4390        self
4391    }
4392    /// Required. Memcache instance resource name using the form: `projects/{project}/locations/{location}/instances/{instance}` where `location_id` refers to a GCP region.
4393    ///
4394    /// Sets the *name* path property to the given value.
4395    ///
4396    /// Even though the property as already been set when instantiating this call,
4397    /// we provide this method for API completeness.
4398    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpgradeCall<'a, C> {
4399        self._name = new_value.to_string();
4400        self
4401    }
4402    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4403    /// while executing the actual API request.
4404    ///
4405    /// ````text
4406    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4407    /// ````
4408    ///
4409    /// Sets the *delegate* property to the given value.
4410    pub fn delegate(
4411        mut self,
4412        new_value: &'a mut dyn common::Delegate,
4413    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
4414        self._delegate = Some(new_value);
4415        self
4416    }
4417
4418    /// Set any additional parameter of the query string used in the request.
4419    /// It should be used to set parameters which are not yet available through their own
4420    /// setters.
4421    ///
4422    /// Please note that this method must not be used to set any of the known parameters
4423    /// which have their own setter method. If done anyway, the request will fail.
4424    ///
4425    /// # Additional Parameters
4426    ///
4427    /// * *$.xgafv* (query-string) - V1 error format.
4428    /// * *access_token* (query-string) - OAuth access token.
4429    /// * *alt* (query-string) - Data format for response.
4430    /// * *callback* (query-string) - JSONP
4431    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4432    /// * *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.
4433    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4434    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4435    /// * *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.
4436    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4437    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4438    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUpgradeCall<'a, C>
4439    where
4440        T: AsRef<str>,
4441    {
4442        self._additional_params
4443            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4444        self
4445    }
4446
4447    /// Identifies the authorization scope for the method you are building.
4448    ///
4449    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4450    /// [`Scope::CloudPlatform`].
4451    ///
4452    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4453    /// tokens for more than one scope.
4454    ///
4455    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4456    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4457    /// sufficient, a read-write scope will do as well.
4458    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpgradeCall<'a, C>
4459    where
4460        St: AsRef<str>,
4461    {
4462        self._scopes.insert(String::from(scope.as_ref()));
4463        self
4464    }
4465    /// Identifies the authorization scope(s) for the method you are building.
4466    ///
4467    /// See [`Self::add_scope()`] for details.
4468    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUpgradeCall<'a, C>
4469    where
4470        I: IntoIterator<Item = St>,
4471        St: AsRef<str>,
4472    {
4473        self._scopes
4474            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4475        self
4476    }
4477
4478    /// Removes all scopes, and no default scope will be used either.
4479    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4480    /// for details).
4481    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpgradeCall<'a, C> {
4482        self._scopes.clear();
4483        self
4484    }
4485}
4486
4487/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
4488///
4489/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
4490/// It is not used directly, but through a [`ProjectMethods`] instance.
4491///
4492/// # Example
4493///
4494/// Instantiate a resource method builder
4495///
4496/// ```test_harness,no_run
4497/// # extern crate hyper;
4498/// # extern crate hyper_rustls;
4499/// # extern crate google_memcache1_beta2 as memcache1_beta2;
4500/// use memcache1_beta2::api::CancelOperationRequest;
4501/// # async fn dox() {
4502/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4503///
4504/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4505/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4506/// #     .with_native_roots()
4507/// #     .unwrap()
4508/// #     .https_only()
4509/// #     .enable_http2()
4510/// #     .build();
4511///
4512/// # let executor = hyper_util::rt::TokioExecutor::new();
4513/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4514/// #     secret,
4515/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4516/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4517/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4518/// #     ),
4519/// # ).build().await.unwrap();
4520///
4521/// # let client = hyper_util::client::legacy::Client::builder(
4522/// #     hyper_util::rt::TokioExecutor::new()
4523/// # )
4524/// # .build(
4525/// #     hyper_rustls::HttpsConnectorBuilder::new()
4526/// #         .with_native_roots()
4527/// #         .unwrap()
4528/// #         .https_or_http()
4529/// #         .enable_http2()
4530/// #         .build()
4531/// # );
4532/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
4533/// // As the method needs a request, you would usually fill it with the desired information
4534/// // into the respective structure. Some of the parts shown here might not be applicable !
4535/// // Values shown here are possibly random and not representative !
4536/// let mut req = CancelOperationRequest::default();
4537///
4538/// // You can configure optional parameters by calling the respective setters at will, and
4539/// // execute the final call using `doit()`.
4540/// // Values shown here are possibly random and not representative !
4541/// let result = hub.projects().locations_operations_cancel(req, "name")
4542///              .doit().await;
4543/// # }
4544/// ```
4545pub struct ProjectLocationOperationCancelCall<'a, C>
4546where
4547    C: 'a,
4548{
4549    hub: &'a CloudMemorystoreForMemcached<C>,
4550    _request: CancelOperationRequest,
4551    _name: String,
4552    _delegate: Option<&'a mut dyn common::Delegate>,
4553    _additional_params: HashMap<String, String>,
4554    _scopes: BTreeSet<String>,
4555}
4556
4557impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
4558
4559impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
4560where
4561    C: common::Connector,
4562{
4563    /// Perform the operation you have build so far.
4564    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4565        use std::borrow::Cow;
4566        use std::io::{Read, Seek};
4567
4568        use common::{url::Params, ToParts};
4569        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4570
4571        let mut dd = common::DefaultDelegate;
4572        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4573        dlg.begin(common::MethodInfo {
4574            id: "memcache.projects.locations.operations.cancel",
4575            http_method: hyper::Method::POST,
4576        });
4577
4578        for &field in ["alt", "name"].iter() {
4579            if self._additional_params.contains_key(field) {
4580                dlg.finished(false);
4581                return Err(common::Error::FieldClash(field));
4582            }
4583        }
4584
4585        let mut params = Params::with_capacity(4 + self._additional_params.len());
4586        params.push("name", self._name);
4587
4588        params.extend(self._additional_params.iter());
4589
4590        params.push("alt", "json");
4591        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}:cancel";
4592        if self._scopes.is_empty() {
4593            self._scopes
4594                .insert(Scope::CloudPlatform.as_ref().to_string());
4595        }
4596
4597        #[allow(clippy::single_element_loop)]
4598        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4599            url = params.uri_replacement(url, param_name, find_this, true);
4600        }
4601        {
4602            let to_remove = ["name"];
4603            params.remove_params(&to_remove);
4604        }
4605
4606        let url = params.parse_with_url(&url);
4607
4608        let mut json_mime_type = mime::APPLICATION_JSON;
4609        let mut request_value_reader = {
4610            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4611            common::remove_json_null_values(&mut value);
4612            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4613            serde_json::to_writer(&mut dst, &value).unwrap();
4614            dst
4615        };
4616        let request_size = request_value_reader
4617            .seek(std::io::SeekFrom::End(0))
4618            .unwrap();
4619        request_value_reader
4620            .seek(std::io::SeekFrom::Start(0))
4621            .unwrap();
4622
4623        loop {
4624            let token = match self
4625                .hub
4626                .auth
4627                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4628                .await
4629            {
4630                Ok(token) => token,
4631                Err(e) => match dlg.token(e) {
4632                    Ok(token) => token,
4633                    Err(e) => {
4634                        dlg.finished(false);
4635                        return Err(common::Error::MissingToken(e));
4636                    }
4637                },
4638            };
4639            request_value_reader
4640                .seek(std::io::SeekFrom::Start(0))
4641                .unwrap();
4642            let mut req_result = {
4643                let client = &self.hub.client;
4644                dlg.pre_request();
4645                let mut req_builder = hyper::Request::builder()
4646                    .method(hyper::Method::POST)
4647                    .uri(url.as_str())
4648                    .header(USER_AGENT, self.hub._user_agent.clone());
4649
4650                if let Some(token) = token.as_ref() {
4651                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4652                }
4653
4654                let request = req_builder
4655                    .header(CONTENT_TYPE, json_mime_type.to_string())
4656                    .header(CONTENT_LENGTH, request_size as u64)
4657                    .body(common::to_body(
4658                        request_value_reader.get_ref().clone().into(),
4659                    ));
4660
4661                client.request(request.unwrap()).await
4662            };
4663
4664            match req_result {
4665                Err(err) => {
4666                    if let common::Retry::After(d) = dlg.http_error(&err) {
4667                        sleep(d).await;
4668                        continue;
4669                    }
4670                    dlg.finished(false);
4671                    return Err(common::Error::HttpError(err));
4672                }
4673                Ok(res) => {
4674                    let (mut parts, body) = res.into_parts();
4675                    let mut body = common::Body::new(body);
4676                    if !parts.status.is_success() {
4677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4678                        let error = serde_json::from_str(&common::to_string(&bytes));
4679                        let response = common::to_response(parts, bytes.into());
4680
4681                        if let common::Retry::After(d) =
4682                            dlg.http_failure(&response, error.as_ref().ok())
4683                        {
4684                            sleep(d).await;
4685                            continue;
4686                        }
4687
4688                        dlg.finished(false);
4689
4690                        return Err(match error {
4691                            Ok(value) => common::Error::BadRequest(value),
4692                            _ => common::Error::Failure(response),
4693                        });
4694                    }
4695                    let response = {
4696                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4697                        let encoded = common::to_string(&bytes);
4698                        match serde_json::from_str(&encoded) {
4699                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4700                            Err(error) => {
4701                                dlg.response_json_decode_error(&encoded, &error);
4702                                return Err(common::Error::JsonDecodeError(
4703                                    encoded.to_string(),
4704                                    error,
4705                                ));
4706                            }
4707                        }
4708                    };
4709
4710                    dlg.finished(true);
4711                    return Ok(response);
4712                }
4713            }
4714        }
4715    }
4716
4717    ///
4718    /// Sets the *request* property to the given value.
4719    ///
4720    /// Even though the property as already been set when instantiating this call,
4721    /// we provide this method for API completeness.
4722    pub fn request(
4723        mut self,
4724        new_value: CancelOperationRequest,
4725    ) -> ProjectLocationOperationCancelCall<'a, C> {
4726        self._request = new_value;
4727        self
4728    }
4729    /// The name of the operation resource to be cancelled.
4730    ///
4731    /// Sets the *name* path property to the given value.
4732    ///
4733    /// Even though the property as already been set when instantiating this call,
4734    /// we provide this method for API completeness.
4735    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
4736        self._name = new_value.to_string();
4737        self
4738    }
4739    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4740    /// while executing the actual API request.
4741    ///
4742    /// ````text
4743    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4744    /// ````
4745    ///
4746    /// Sets the *delegate* property to the given value.
4747    pub fn delegate(
4748        mut self,
4749        new_value: &'a mut dyn common::Delegate,
4750    ) -> ProjectLocationOperationCancelCall<'a, C> {
4751        self._delegate = Some(new_value);
4752        self
4753    }
4754
4755    /// Set any additional parameter of the query string used in the request.
4756    /// It should be used to set parameters which are not yet available through their own
4757    /// setters.
4758    ///
4759    /// Please note that this method must not be used to set any of the known parameters
4760    /// which have their own setter method. If done anyway, the request will fail.
4761    ///
4762    /// # Additional Parameters
4763    ///
4764    /// * *$.xgafv* (query-string) - V1 error format.
4765    /// * *access_token* (query-string) - OAuth access token.
4766    /// * *alt* (query-string) - Data format for response.
4767    /// * *callback* (query-string) - JSONP
4768    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4769    /// * *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.
4770    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4771    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4772    /// * *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.
4773    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4774    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4775    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
4776    where
4777        T: AsRef<str>,
4778    {
4779        self._additional_params
4780            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4781        self
4782    }
4783
4784    /// Identifies the authorization scope for the method you are building.
4785    ///
4786    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4787    /// [`Scope::CloudPlatform`].
4788    ///
4789    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4790    /// tokens for more than one scope.
4791    ///
4792    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4793    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4794    /// sufficient, a read-write scope will do as well.
4795    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
4796    where
4797        St: AsRef<str>,
4798    {
4799        self._scopes.insert(String::from(scope.as_ref()));
4800        self
4801    }
4802    /// Identifies the authorization scope(s) for the method you are building.
4803    ///
4804    /// See [`Self::add_scope()`] for details.
4805    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
4806    where
4807        I: IntoIterator<Item = St>,
4808        St: AsRef<str>,
4809    {
4810        self._scopes
4811            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4812        self
4813    }
4814
4815    /// Removes all scopes, and no default scope will be used either.
4816    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4817    /// for details).
4818    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
4819        self._scopes.clear();
4820        self
4821    }
4822}
4823
4824/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
4825///
4826/// A builder for the *locations.operations.delete* method supported by a *project* resource.
4827/// It is not used directly, but through a [`ProjectMethods`] instance.
4828///
4829/// # Example
4830///
4831/// Instantiate a resource method builder
4832///
4833/// ```test_harness,no_run
4834/// # extern crate hyper;
4835/// # extern crate hyper_rustls;
4836/// # extern crate google_memcache1_beta2 as memcache1_beta2;
4837/// # async fn dox() {
4838/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4839///
4840/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4841/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4842/// #     .with_native_roots()
4843/// #     .unwrap()
4844/// #     .https_only()
4845/// #     .enable_http2()
4846/// #     .build();
4847///
4848/// # let executor = hyper_util::rt::TokioExecutor::new();
4849/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4850/// #     secret,
4851/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4852/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4853/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4854/// #     ),
4855/// # ).build().await.unwrap();
4856///
4857/// # let client = hyper_util::client::legacy::Client::builder(
4858/// #     hyper_util::rt::TokioExecutor::new()
4859/// # )
4860/// # .build(
4861/// #     hyper_rustls::HttpsConnectorBuilder::new()
4862/// #         .with_native_roots()
4863/// #         .unwrap()
4864/// #         .https_or_http()
4865/// #         .enable_http2()
4866/// #         .build()
4867/// # );
4868/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
4869/// // You can configure optional parameters by calling the respective setters at will, and
4870/// // execute the final call using `doit()`.
4871/// // Values shown here are possibly random and not representative !
4872/// let result = hub.projects().locations_operations_delete("name")
4873///              .doit().await;
4874/// # }
4875/// ```
4876pub struct ProjectLocationOperationDeleteCall<'a, C>
4877where
4878    C: 'a,
4879{
4880    hub: &'a CloudMemorystoreForMemcached<C>,
4881    _name: String,
4882    _delegate: Option<&'a mut dyn common::Delegate>,
4883    _additional_params: HashMap<String, String>,
4884    _scopes: BTreeSet<String>,
4885}
4886
4887impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
4888
4889impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
4890where
4891    C: common::Connector,
4892{
4893    /// Perform the operation you have build so far.
4894    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4895        use std::borrow::Cow;
4896        use std::io::{Read, Seek};
4897
4898        use common::{url::Params, ToParts};
4899        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4900
4901        let mut dd = common::DefaultDelegate;
4902        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4903        dlg.begin(common::MethodInfo {
4904            id: "memcache.projects.locations.operations.delete",
4905            http_method: hyper::Method::DELETE,
4906        });
4907
4908        for &field in ["alt", "name"].iter() {
4909            if self._additional_params.contains_key(field) {
4910                dlg.finished(false);
4911                return Err(common::Error::FieldClash(field));
4912            }
4913        }
4914
4915        let mut params = Params::with_capacity(3 + self._additional_params.len());
4916        params.push("name", self._name);
4917
4918        params.extend(self._additional_params.iter());
4919
4920        params.push("alt", "json");
4921        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
4922        if self._scopes.is_empty() {
4923            self._scopes
4924                .insert(Scope::CloudPlatform.as_ref().to_string());
4925        }
4926
4927        #[allow(clippy::single_element_loop)]
4928        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4929            url = params.uri_replacement(url, param_name, find_this, true);
4930        }
4931        {
4932            let to_remove = ["name"];
4933            params.remove_params(&to_remove);
4934        }
4935
4936        let url = params.parse_with_url(&url);
4937
4938        loop {
4939            let token = match self
4940                .hub
4941                .auth
4942                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4943                .await
4944            {
4945                Ok(token) => token,
4946                Err(e) => match dlg.token(e) {
4947                    Ok(token) => token,
4948                    Err(e) => {
4949                        dlg.finished(false);
4950                        return Err(common::Error::MissingToken(e));
4951                    }
4952                },
4953            };
4954            let mut req_result = {
4955                let client = &self.hub.client;
4956                dlg.pre_request();
4957                let mut req_builder = hyper::Request::builder()
4958                    .method(hyper::Method::DELETE)
4959                    .uri(url.as_str())
4960                    .header(USER_AGENT, self.hub._user_agent.clone());
4961
4962                if let Some(token) = token.as_ref() {
4963                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4964                }
4965
4966                let request = req_builder
4967                    .header(CONTENT_LENGTH, 0_u64)
4968                    .body(common::to_body::<String>(None));
4969
4970                client.request(request.unwrap()).await
4971            };
4972
4973            match req_result {
4974                Err(err) => {
4975                    if let common::Retry::After(d) = dlg.http_error(&err) {
4976                        sleep(d).await;
4977                        continue;
4978                    }
4979                    dlg.finished(false);
4980                    return Err(common::Error::HttpError(err));
4981                }
4982                Ok(res) => {
4983                    let (mut parts, body) = res.into_parts();
4984                    let mut body = common::Body::new(body);
4985                    if !parts.status.is_success() {
4986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4987                        let error = serde_json::from_str(&common::to_string(&bytes));
4988                        let response = common::to_response(parts, bytes.into());
4989
4990                        if let common::Retry::After(d) =
4991                            dlg.http_failure(&response, error.as_ref().ok())
4992                        {
4993                            sleep(d).await;
4994                            continue;
4995                        }
4996
4997                        dlg.finished(false);
4998
4999                        return Err(match error {
5000                            Ok(value) => common::Error::BadRequest(value),
5001                            _ => common::Error::Failure(response),
5002                        });
5003                    }
5004                    let response = {
5005                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5006                        let encoded = common::to_string(&bytes);
5007                        match serde_json::from_str(&encoded) {
5008                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5009                            Err(error) => {
5010                                dlg.response_json_decode_error(&encoded, &error);
5011                                return Err(common::Error::JsonDecodeError(
5012                                    encoded.to_string(),
5013                                    error,
5014                                ));
5015                            }
5016                        }
5017                    };
5018
5019                    dlg.finished(true);
5020                    return Ok(response);
5021                }
5022            }
5023        }
5024    }
5025
5026    /// The name of the operation resource to be deleted.
5027    ///
5028    /// Sets the *name* path property to the given value.
5029    ///
5030    /// Even though the property as already been set when instantiating this call,
5031    /// we provide this method for API completeness.
5032    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
5033        self._name = new_value.to_string();
5034        self
5035    }
5036    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5037    /// while executing the actual API request.
5038    ///
5039    /// ````text
5040    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5041    /// ````
5042    ///
5043    /// Sets the *delegate* property to the given value.
5044    pub fn delegate(
5045        mut self,
5046        new_value: &'a mut dyn common::Delegate,
5047    ) -> ProjectLocationOperationDeleteCall<'a, C> {
5048        self._delegate = Some(new_value);
5049        self
5050    }
5051
5052    /// Set any additional parameter of the query string used in the request.
5053    /// It should be used to set parameters which are not yet available through their own
5054    /// setters.
5055    ///
5056    /// Please note that this method must not be used to set any of the known parameters
5057    /// which have their own setter method. If done anyway, the request will fail.
5058    ///
5059    /// # Additional Parameters
5060    ///
5061    /// * *$.xgafv* (query-string) - V1 error format.
5062    /// * *access_token* (query-string) - OAuth access token.
5063    /// * *alt* (query-string) - Data format for response.
5064    /// * *callback* (query-string) - JSONP
5065    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5066    /// * *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.
5067    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5068    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5069    /// * *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.
5070    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5071    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5072    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
5073    where
5074        T: AsRef<str>,
5075    {
5076        self._additional_params
5077            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5078        self
5079    }
5080
5081    /// Identifies the authorization scope for the method you are building.
5082    ///
5083    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5084    /// [`Scope::CloudPlatform`].
5085    ///
5086    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5087    /// tokens for more than one scope.
5088    ///
5089    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5090    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5091    /// sufficient, a read-write scope will do as well.
5092    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
5093    where
5094        St: AsRef<str>,
5095    {
5096        self._scopes.insert(String::from(scope.as_ref()));
5097        self
5098    }
5099    /// Identifies the authorization scope(s) for the method you are building.
5100    ///
5101    /// See [`Self::add_scope()`] for details.
5102    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
5103    where
5104        I: IntoIterator<Item = St>,
5105        St: AsRef<str>,
5106    {
5107        self._scopes
5108            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5109        self
5110    }
5111
5112    /// Removes all scopes, and no default scope will be used either.
5113    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5114    /// for details).
5115    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
5116        self._scopes.clear();
5117        self
5118    }
5119}
5120
5121/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
5122///
5123/// A builder for the *locations.operations.get* method supported by a *project* resource.
5124/// It is not used directly, but through a [`ProjectMethods`] instance.
5125///
5126/// # Example
5127///
5128/// Instantiate a resource method builder
5129///
5130/// ```test_harness,no_run
5131/// # extern crate hyper;
5132/// # extern crate hyper_rustls;
5133/// # extern crate google_memcache1_beta2 as memcache1_beta2;
5134/// # async fn dox() {
5135/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5136///
5137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5139/// #     .with_native_roots()
5140/// #     .unwrap()
5141/// #     .https_only()
5142/// #     .enable_http2()
5143/// #     .build();
5144///
5145/// # let executor = hyper_util::rt::TokioExecutor::new();
5146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5147/// #     secret,
5148/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5149/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5150/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5151/// #     ),
5152/// # ).build().await.unwrap();
5153///
5154/// # let client = hyper_util::client::legacy::Client::builder(
5155/// #     hyper_util::rt::TokioExecutor::new()
5156/// # )
5157/// # .build(
5158/// #     hyper_rustls::HttpsConnectorBuilder::new()
5159/// #         .with_native_roots()
5160/// #         .unwrap()
5161/// #         .https_or_http()
5162/// #         .enable_http2()
5163/// #         .build()
5164/// # );
5165/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
5166/// // You can configure optional parameters by calling the respective setters at will, and
5167/// // execute the final call using `doit()`.
5168/// // Values shown here are possibly random and not representative !
5169/// let result = hub.projects().locations_operations_get("name")
5170///              .doit().await;
5171/// # }
5172/// ```
5173pub struct ProjectLocationOperationGetCall<'a, C>
5174where
5175    C: 'a,
5176{
5177    hub: &'a CloudMemorystoreForMemcached<C>,
5178    _name: String,
5179    _delegate: Option<&'a mut dyn common::Delegate>,
5180    _additional_params: HashMap<String, String>,
5181    _scopes: BTreeSet<String>,
5182}
5183
5184impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
5185
5186impl<'a, C> ProjectLocationOperationGetCall<'a, C>
5187where
5188    C: common::Connector,
5189{
5190    /// Perform the operation you have build so far.
5191    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5192        use std::borrow::Cow;
5193        use std::io::{Read, Seek};
5194
5195        use common::{url::Params, ToParts};
5196        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5197
5198        let mut dd = common::DefaultDelegate;
5199        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5200        dlg.begin(common::MethodInfo {
5201            id: "memcache.projects.locations.operations.get",
5202            http_method: hyper::Method::GET,
5203        });
5204
5205        for &field in ["alt", "name"].iter() {
5206            if self._additional_params.contains_key(field) {
5207                dlg.finished(false);
5208                return Err(common::Error::FieldClash(field));
5209            }
5210        }
5211
5212        let mut params = Params::with_capacity(3 + self._additional_params.len());
5213        params.push("name", self._name);
5214
5215        params.extend(self._additional_params.iter());
5216
5217        params.push("alt", "json");
5218        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
5219        if self._scopes.is_empty() {
5220            self._scopes
5221                .insert(Scope::CloudPlatform.as_ref().to_string());
5222        }
5223
5224        #[allow(clippy::single_element_loop)]
5225        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5226            url = params.uri_replacement(url, param_name, find_this, true);
5227        }
5228        {
5229            let to_remove = ["name"];
5230            params.remove_params(&to_remove);
5231        }
5232
5233        let url = params.parse_with_url(&url);
5234
5235        loop {
5236            let token = match self
5237                .hub
5238                .auth
5239                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5240                .await
5241            {
5242                Ok(token) => token,
5243                Err(e) => match dlg.token(e) {
5244                    Ok(token) => token,
5245                    Err(e) => {
5246                        dlg.finished(false);
5247                        return Err(common::Error::MissingToken(e));
5248                    }
5249                },
5250            };
5251            let mut req_result = {
5252                let client = &self.hub.client;
5253                dlg.pre_request();
5254                let mut req_builder = hyper::Request::builder()
5255                    .method(hyper::Method::GET)
5256                    .uri(url.as_str())
5257                    .header(USER_AGENT, self.hub._user_agent.clone());
5258
5259                if let Some(token) = token.as_ref() {
5260                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5261                }
5262
5263                let request = req_builder
5264                    .header(CONTENT_LENGTH, 0_u64)
5265                    .body(common::to_body::<String>(None));
5266
5267                client.request(request.unwrap()).await
5268            };
5269
5270            match req_result {
5271                Err(err) => {
5272                    if let common::Retry::After(d) = dlg.http_error(&err) {
5273                        sleep(d).await;
5274                        continue;
5275                    }
5276                    dlg.finished(false);
5277                    return Err(common::Error::HttpError(err));
5278                }
5279                Ok(res) => {
5280                    let (mut parts, body) = res.into_parts();
5281                    let mut body = common::Body::new(body);
5282                    if !parts.status.is_success() {
5283                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5284                        let error = serde_json::from_str(&common::to_string(&bytes));
5285                        let response = common::to_response(parts, bytes.into());
5286
5287                        if let common::Retry::After(d) =
5288                            dlg.http_failure(&response, error.as_ref().ok())
5289                        {
5290                            sleep(d).await;
5291                            continue;
5292                        }
5293
5294                        dlg.finished(false);
5295
5296                        return Err(match error {
5297                            Ok(value) => common::Error::BadRequest(value),
5298                            _ => common::Error::Failure(response),
5299                        });
5300                    }
5301                    let response = {
5302                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5303                        let encoded = common::to_string(&bytes);
5304                        match serde_json::from_str(&encoded) {
5305                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5306                            Err(error) => {
5307                                dlg.response_json_decode_error(&encoded, &error);
5308                                return Err(common::Error::JsonDecodeError(
5309                                    encoded.to_string(),
5310                                    error,
5311                                ));
5312                            }
5313                        }
5314                    };
5315
5316                    dlg.finished(true);
5317                    return Ok(response);
5318                }
5319            }
5320        }
5321    }
5322
5323    /// The name of the operation resource.
5324    ///
5325    /// Sets the *name* path property to the given value.
5326    ///
5327    /// Even though the property as already been set when instantiating this call,
5328    /// we provide this method for API completeness.
5329    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
5330        self._name = new_value.to_string();
5331        self
5332    }
5333    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5334    /// while executing the actual API request.
5335    ///
5336    /// ````text
5337    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5338    /// ````
5339    ///
5340    /// Sets the *delegate* property to the given value.
5341    pub fn delegate(
5342        mut self,
5343        new_value: &'a mut dyn common::Delegate,
5344    ) -> ProjectLocationOperationGetCall<'a, C> {
5345        self._delegate = Some(new_value);
5346        self
5347    }
5348
5349    /// Set any additional parameter of the query string used in the request.
5350    /// It should be used to set parameters which are not yet available through their own
5351    /// setters.
5352    ///
5353    /// Please note that this method must not be used to set any of the known parameters
5354    /// which have their own setter method. If done anyway, the request will fail.
5355    ///
5356    /// # Additional Parameters
5357    ///
5358    /// * *$.xgafv* (query-string) - V1 error format.
5359    /// * *access_token* (query-string) - OAuth access token.
5360    /// * *alt* (query-string) - Data format for response.
5361    /// * *callback* (query-string) - JSONP
5362    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5363    /// * *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.
5364    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5365    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5366    /// * *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.
5367    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5368    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5369    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
5370    where
5371        T: AsRef<str>,
5372    {
5373        self._additional_params
5374            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5375        self
5376    }
5377
5378    /// Identifies the authorization scope for the method you are building.
5379    ///
5380    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5381    /// [`Scope::CloudPlatform`].
5382    ///
5383    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5384    /// tokens for more than one scope.
5385    ///
5386    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5387    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5388    /// sufficient, a read-write scope will do as well.
5389    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
5390    where
5391        St: AsRef<str>,
5392    {
5393        self._scopes.insert(String::from(scope.as_ref()));
5394        self
5395    }
5396    /// Identifies the authorization scope(s) for the method you are building.
5397    ///
5398    /// See [`Self::add_scope()`] for details.
5399    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
5400    where
5401        I: IntoIterator<Item = St>,
5402        St: AsRef<str>,
5403    {
5404        self._scopes
5405            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5406        self
5407    }
5408
5409    /// Removes all scopes, and no default scope will be used either.
5410    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5411    /// for details).
5412    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
5413        self._scopes.clear();
5414        self
5415    }
5416}
5417
5418/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5419///
5420/// A builder for the *locations.operations.list* method supported by a *project* resource.
5421/// It is not used directly, but through a [`ProjectMethods`] instance.
5422///
5423/// # Example
5424///
5425/// Instantiate a resource method builder
5426///
5427/// ```test_harness,no_run
5428/// # extern crate hyper;
5429/// # extern crate hyper_rustls;
5430/// # extern crate google_memcache1_beta2 as memcache1_beta2;
5431/// # async fn dox() {
5432/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5433///
5434/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5435/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5436/// #     .with_native_roots()
5437/// #     .unwrap()
5438/// #     .https_only()
5439/// #     .enable_http2()
5440/// #     .build();
5441///
5442/// # let executor = hyper_util::rt::TokioExecutor::new();
5443/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5444/// #     secret,
5445/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5446/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5447/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5448/// #     ),
5449/// # ).build().await.unwrap();
5450///
5451/// # let client = hyper_util::client::legacy::Client::builder(
5452/// #     hyper_util::rt::TokioExecutor::new()
5453/// # )
5454/// # .build(
5455/// #     hyper_rustls::HttpsConnectorBuilder::new()
5456/// #         .with_native_roots()
5457/// #         .unwrap()
5458/// #         .https_or_http()
5459/// #         .enable_http2()
5460/// #         .build()
5461/// # );
5462/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
5463/// // You can configure optional parameters by calling the respective setters at will, and
5464/// // execute the final call using `doit()`.
5465/// // Values shown here are possibly random and not representative !
5466/// let result = hub.projects().locations_operations_list("name")
5467///              .return_partial_success(true)
5468///              .page_token("ipsum")
5469///              .page_size(-50)
5470///              .filter("est")
5471///              .doit().await;
5472/// # }
5473/// ```
5474pub struct ProjectLocationOperationListCall<'a, C>
5475where
5476    C: 'a,
5477{
5478    hub: &'a CloudMemorystoreForMemcached<C>,
5479    _name: String,
5480    _return_partial_success: Option<bool>,
5481    _page_token: Option<String>,
5482    _page_size: Option<i32>,
5483    _filter: Option<String>,
5484    _delegate: Option<&'a mut dyn common::Delegate>,
5485    _additional_params: HashMap<String, String>,
5486    _scopes: BTreeSet<String>,
5487}
5488
5489impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
5490
5491impl<'a, C> ProjectLocationOperationListCall<'a, C>
5492where
5493    C: common::Connector,
5494{
5495    /// Perform the operation you have build so far.
5496    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
5497        use std::borrow::Cow;
5498        use std::io::{Read, Seek};
5499
5500        use common::{url::Params, ToParts};
5501        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5502
5503        let mut dd = common::DefaultDelegate;
5504        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5505        dlg.begin(common::MethodInfo {
5506            id: "memcache.projects.locations.operations.list",
5507            http_method: hyper::Method::GET,
5508        });
5509
5510        for &field in [
5511            "alt",
5512            "name",
5513            "returnPartialSuccess",
5514            "pageToken",
5515            "pageSize",
5516            "filter",
5517        ]
5518        .iter()
5519        {
5520            if self._additional_params.contains_key(field) {
5521                dlg.finished(false);
5522                return Err(common::Error::FieldClash(field));
5523            }
5524        }
5525
5526        let mut params = Params::with_capacity(7 + self._additional_params.len());
5527        params.push("name", self._name);
5528        if let Some(value) = self._return_partial_success.as_ref() {
5529            params.push("returnPartialSuccess", value.to_string());
5530        }
5531        if let Some(value) = self._page_token.as_ref() {
5532            params.push("pageToken", value);
5533        }
5534        if let Some(value) = self._page_size.as_ref() {
5535            params.push("pageSize", value.to_string());
5536        }
5537        if let Some(value) = self._filter.as_ref() {
5538            params.push("filter", value);
5539        }
5540
5541        params.extend(self._additional_params.iter());
5542
5543        params.push("alt", "json");
5544        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}/operations";
5545        if self._scopes.is_empty() {
5546            self._scopes
5547                .insert(Scope::CloudPlatform.as_ref().to_string());
5548        }
5549
5550        #[allow(clippy::single_element_loop)]
5551        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5552            url = params.uri_replacement(url, param_name, find_this, true);
5553        }
5554        {
5555            let to_remove = ["name"];
5556            params.remove_params(&to_remove);
5557        }
5558
5559        let url = params.parse_with_url(&url);
5560
5561        loop {
5562            let token = match self
5563                .hub
5564                .auth
5565                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5566                .await
5567            {
5568                Ok(token) => token,
5569                Err(e) => match dlg.token(e) {
5570                    Ok(token) => token,
5571                    Err(e) => {
5572                        dlg.finished(false);
5573                        return Err(common::Error::MissingToken(e));
5574                    }
5575                },
5576            };
5577            let mut req_result = {
5578                let client = &self.hub.client;
5579                dlg.pre_request();
5580                let mut req_builder = hyper::Request::builder()
5581                    .method(hyper::Method::GET)
5582                    .uri(url.as_str())
5583                    .header(USER_AGENT, self.hub._user_agent.clone());
5584
5585                if let Some(token) = token.as_ref() {
5586                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5587                }
5588
5589                let request = req_builder
5590                    .header(CONTENT_LENGTH, 0_u64)
5591                    .body(common::to_body::<String>(None));
5592
5593                client.request(request.unwrap()).await
5594            };
5595
5596            match req_result {
5597                Err(err) => {
5598                    if let common::Retry::After(d) = dlg.http_error(&err) {
5599                        sleep(d).await;
5600                        continue;
5601                    }
5602                    dlg.finished(false);
5603                    return Err(common::Error::HttpError(err));
5604                }
5605                Ok(res) => {
5606                    let (mut parts, body) = res.into_parts();
5607                    let mut body = common::Body::new(body);
5608                    if !parts.status.is_success() {
5609                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5610                        let error = serde_json::from_str(&common::to_string(&bytes));
5611                        let response = common::to_response(parts, bytes.into());
5612
5613                        if let common::Retry::After(d) =
5614                            dlg.http_failure(&response, error.as_ref().ok())
5615                        {
5616                            sleep(d).await;
5617                            continue;
5618                        }
5619
5620                        dlg.finished(false);
5621
5622                        return Err(match error {
5623                            Ok(value) => common::Error::BadRequest(value),
5624                            _ => common::Error::Failure(response),
5625                        });
5626                    }
5627                    let response = {
5628                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5629                        let encoded = common::to_string(&bytes);
5630                        match serde_json::from_str(&encoded) {
5631                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5632                            Err(error) => {
5633                                dlg.response_json_decode_error(&encoded, &error);
5634                                return Err(common::Error::JsonDecodeError(
5635                                    encoded.to_string(),
5636                                    error,
5637                                ));
5638                            }
5639                        }
5640                    };
5641
5642                    dlg.finished(true);
5643                    return Ok(response);
5644                }
5645            }
5646        }
5647    }
5648
5649    /// The name of the operation's parent resource.
5650    ///
5651    /// Sets the *name* path property to the given value.
5652    ///
5653    /// Even though the property as already been set when instantiating this call,
5654    /// we provide this method for API completeness.
5655    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5656        self._name = new_value.to_string();
5657        self
5658    }
5659    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the [ListOperationsResponse.unreachable] field. This can only be `true` when reading across collections e.g. when `parent` is set to `"projects/example/locations/-"`. This field is not by default supported and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
5660    ///
5661    /// Sets the *return partial success* query property to the given value.
5662    pub fn return_partial_success(
5663        mut self,
5664        new_value: bool,
5665    ) -> ProjectLocationOperationListCall<'a, C> {
5666        self._return_partial_success = Some(new_value);
5667        self
5668    }
5669    /// The standard list page token.
5670    ///
5671    /// Sets the *page token* query property to the given value.
5672    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5673        self._page_token = Some(new_value.to_string());
5674        self
5675    }
5676    /// The standard list page size.
5677    ///
5678    /// Sets the *page size* query property to the given value.
5679    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
5680        self._page_size = Some(new_value);
5681        self
5682    }
5683    /// The standard list filter.
5684    ///
5685    /// Sets the *filter* query property to the given value.
5686    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5687        self._filter = Some(new_value.to_string());
5688        self
5689    }
5690    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5691    /// while executing the actual API request.
5692    ///
5693    /// ````text
5694    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5695    /// ````
5696    ///
5697    /// Sets the *delegate* property to the given value.
5698    pub fn delegate(
5699        mut self,
5700        new_value: &'a mut dyn common::Delegate,
5701    ) -> ProjectLocationOperationListCall<'a, C> {
5702        self._delegate = Some(new_value);
5703        self
5704    }
5705
5706    /// Set any additional parameter of the query string used in the request.
5707    /// It should be used to set parameters which are not yet available through their own
5708    /// setters.
5709    ///
5710    /// Please note that this method must not be used to set any of the known parameters
5711    /// which have their own setter method. If done anyway, the request will fail.
5712    ///
5713    /// # Additional Parameters
5714    ///
5715    /// * *$.xgafv* (query-string) - V1 error format.
5716    /// * *access_token* (query-string) - OAuth access token.
5717    /// * *alt* (query-string) - Data format for response.
5718    /// * *callback* (query-string) - JSONP
5719    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5720    /// * *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.
5721    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5722    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5723    /// * *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.
5724    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5725    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5726    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
5727    where
5728        T: AsRef<str>,
5729    {
5730        self._additional_params
5731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5732        self
5733    }
5734
5735    /// Identifies the authorization scope for the method you are building.
5736    ///
5737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5738    /// [`Scope::CloudPlatform`].
5739    ///
5740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5741    /// tokens for more than one scope.
5742    ///
5743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5745    /// sufficient, a read-write scope will do as well.
5746    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
5747    where
5748        St: AsRef<str>,
5749    {
5750        self._scopes.insert(String::from(scope.as_ref()));
5751        self
5752    }
5753    /// Identifies the authorization scope(s) for the method you are building.
5754    ///
5755    /// See [`Self::add_scope()`] for details.
5756    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
5757    where
5758        I: IntoIterator<Item = St>,
5759        St: AsRef<str>,
5760    {
5761        self._scopes
5762            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5763        self
5764    }
5765
5766    /// Removes all scopes, and no default scope will be used either.
5767    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5768    /// for details).
5769    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
5770        self._scopes.clear();
5771        self
5772    }
5773}
5774
5775/// Gets information about a location.
5776///
5777/// A builder for the *locations.get* method supported by a *project* resource.
5778/// It is not used directly, but through a [`ProjectMethods`] instance.
5779///
5780/// # Example
5781///
5782/// Instantiate a resource method builder
5783///
5784/// ```test_harness,no_run
5785/// # extern crate hyper;
5786/// # extern crate hyper_rustls;
5787/// # extern crate google_memcache1_beta2 as memcache1_beta2;
5788/// # async fn dox() {
5789/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5790///
5791/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5792/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5793/// #     .with_native_roots()
5794/// #     .unwrap()
5795/// #     .https_only()
5796/// #     .enable_http2()
5797/// #     .build();
5798///
5799/// # let executor = hyper_util::rt::TokioExecutor::new();
5800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5801/// #     secret,
5802/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5803/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5804/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5805/// #     ),
5806/// # ).build().await.unwrap();
5807///
5808/// # let client = hyper_util::client::legacy::Client::builder(
5809/// #     hyper_util::rt::TokioExecutor::new()
5810/// # )
5811/// # .build(
5812/// #     hyper_rustls::HttpsConnectorBuilder::new()
5813/// #         .with_native_roots()
5814/// #         .unwrap()
5815/// #         .https_or_http()
5816/// #         .enable_http2()
5817/// #         .build()
5818/// # );
5819/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
5820/// // You can configure optional parameters by calling the respective setters at will, and
5821/// // execute the final call using `doit()`.
5822/// // Values shown here are possibly random and not representative !
5823/// let result = hub.projects().locations_get("name")
5824///              .doit().await;
5825/// # }
5826/// ```
5827pub struct ProjectLocationGetCall<'a, C>
5828where
5829    C: 'a,
5830{
5831    hub: &'a CloudMemorystoreForMemcached<C>,
5832    _name: String,
5833    _delegate: Option<&'a mut dyn common::Delegate>,
5834    _additional_params: HashMap<String, String>,
5835    _scopes: BTreeSet<String>,
5836}
5837
5838impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
5839
5840impl<'a, C> ProjectLocationGetCall<'a, C>
5841where
5842    C: common::Connector,
5843{
5844    /// Perform the operation you have build so far.
5845    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
5846        use std::borrow::Cow;
5847        use std::io::{Read, Seek};
5848
5849        use common::{url::Params, ToParts};
5850        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5851
5852        let mut dd = common::DefaultDelegate;
5853        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5854        dlg.begin(common::MethodInfo {
5855            id: "memcache.projects.locations.get",
5856            http_method: hyper::Method::GET,
5857        });
5858
5859        for &field in ["alt", "name"].iter() {
5860            if self._additional_params.contains_key(field) {
5861                dlg.finished(false);
5862                return Err(common::Error::FieldClash(field));
5863            }
5864        }
5865
5866        let mut params = Params::with_capacity(3 + self._additional_params.len());
5867        params.push("name", self._name);
5868
5869        params.extend(self._additional_params.iter());
5870
5871        params.push("alt", "json");
5872        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
5873        if self._scopes.is_empty() {
5874            self._scopes
5875                .insert(Scope::CloudPlatform.as_ref().to_string());
5876        }
5877
5878        #[allow(clippy::single_element_loop)]
5879        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5880            url = params.uri_replacement(url, param_name, find_this, true);
5881        }
5882        {
5883            let to_remove = ["name"];
5884            params.remove_params(&to_remove);
5885        }
5886
5887        let url = params.parse_with_url(&url);
5888
5889        loop {
5890            let token = match self
5891                .hub
5892                .auth
5893                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5894                .await
5895            {
5896                Ok(token) => token,
5897                Err(e) => match dlg.token(e) {
5898                    Ok(token) => token,
5899                    Err(e) => {
5900                        dlg.finished(false);
5901                        return Err(common::Error::MissingToken(e));
5902                    }
5903                },
5904            };
5905            let mut req_result = {
5906                let client = &self.hub.client;
5907                dlg.pre_request();
5908                let mut req_builder = hyper::Request::builder()
5909                    .method(hyper::Method::GET)
5910                    .uri(url.as_str())
5911                    .header(USER_AGENT, self.hub._user_agent.clone());
5912
5913                if let Some(token) = token.as_ref() {
5914                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5915                }
5916
5917                let request = req_builder
5918                    .header(CONTENT_LENGTH, 0_u64)
5919                    .body(common::to_body::<String>(None));
5920
5921                client.request(request.unwrap()).await
5922            };
5923
5924            match req_result {
5925                Err(err) => {
5926                    if let common::Retry::After(d) = dlg.http_error(&err) {
5927                        sleep(d).await;
5928                        continue;
5929                    }
5930                    dlg.finished(false);
5931                    return Err(common::Error::HttpError(err));
5932                }
5933                Ok(res) => {
5934                    let (mut parts, body) = res.into_parts();
5935                    let mut body = common::Body::new(body);
5936                    if !parts.status.is_success() {
5937                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5938                        let error = serde_json::from_str(&common::to_string(&bytes));
5939                        let response = common::to_response(parts, bytes.into());
5940
5941                        if let common::Retry::After(d) =
5942                            dlg.http_failure(&response, error.as_ref().ok())
5943                        {
5944                            sleep(d).await;
5945                            continue;
5946                        }
5947
5948                        dlg.finished(false);
5949
5950                        return Err(match error {
5951                            Ok(value) => common::Error::BadRequest(value),
5952                            _ => common::Error::Failure(response),
5953                        });
5954                    }
5955                    let response = {
5956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5957                        let encoded = common::to_string(&bytes);
5958                        match serde_json::from_str(&encoded) {
5959                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5960                            Err(error) => {
5961                                dlg.response_json_decode_error(&encoded, &error);
5962                                return Err(common::Error::JsonDecodeError(
5963                                    encoded.to_string(),
5964                                    error,
5965                                ));
5966                            }
5967                        }
5968                    };
5969
5970                    dlg.finished(true);
5971                    return Ok(response);
5972                }
5973            }
5974        }
5975    }
5976
5977    /// Resource name for the location.
5978    ///
5979    /// Sets the *name* path property to the given value.
5980    ///
5981    /// Even though the property as already been set when instantiating this call,
5982    /// we provide this method for API completeness.
5983    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
5984        self._name = new_value.to_string();
5985        self
5986    }
5987    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5988    /// while executing the actual API request.
5989    ///
5990    /// ````text
5991    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5992    /// ````
5993    ///
5994    /// Sets the *delegate* property to the given value.
5995    pub fn delegate(
5996        mut self,
5997        new_value: &'a mut dyn common::Delegate,
5998    ) -> ProjectLocationGetCall<'a, C> {
5999        self._delegate = Some(new_value);
6000        self
6001    }
6002
6003    /// Set any additional parameter of the query string used in the request.
6004    /// It should be used to set parameters which are not yet available through their own
6005    /// setters.
6006    ///
6007    /// Please note that this method must not be used to set any of the known parameters
6008    /// which have their own setter method. If done anyway, the request will fail.
6009    ///
6010    /// # Additional Parameters
6011    ///
6012    /// * *$.xgafv* (query-string) - V1 error format.
6013    /// * *access_token* (query-string) - OAuth access token.
6014    /// * *alt* (query-string) - Data format for response.
6015    /// * *callback* (query-string) - JSONP
6016    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6017    /// * *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.
6018    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6019    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6020    /// * *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.
6021    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6022    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6023    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
6024    where
6025        T: AsRef<str>,
6026    {
6027        self._additional_params
6028            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6029        self
6030    }
6031
6032    /// Identifies the authorization scope for the method you are building.
6033    ///
6034    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6035    /// [`Scope::CloudPlatform`].
6036    ///
6037    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6038    /// tokens for more than one scope.
6039    ///
6040    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6041    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6042    /// sufficient, a read-write scope will do as well.
6043    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
6044    where
6045        St: AsRef<str>,
6046    {
6047        self._scopes.insert(String::from(scope.as_ref()));
6048        self
6049    }
6050    /// Identifies the authorization scope(s) for the method you are building.
6051    ///
6052    /// See [`Self::add_scope()`] for details.
6053    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
6054    where
6055        I: IntoIterator<Item = St>,
6056        St: AsRef<str>,
6057    {
6058        self._scopes
6059            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6060        self
6061    }
6062
6063    /// Removes all scopes, and no default scope will be used either.
6064    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6065    /// for details).
6066    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
6067        self._scopes.clear();
6068        self
6069    }
6070}
6071
6072/// Lists information about the supported locations for this service.
6073///
6074/// A builder for the *locations.list* method supported by a *project* resource.
6075/// It is not used directly, but through a [`ProjectMethods`] instance.
6076///
6077/// # Example
6078///
6079/// Instantiate a resource method builder
6080///
6081/// ```test_harness,no_run
6082/// # extern crate hyper;
6083/// # extern crate hyper_rustls;
6084/// # extern crate google_memcache1_beta2 as memcache1_beta2;
6085/// # async fn dox() {
6086/// # use memcache1_beta2::{CloudMemorystoreForMemcached, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6087///
6088/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6089/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6090/// #     .with_native_roots()
6091/// #     .unwrap()
6092/// #     .https_only()
6093/// #     .enable_http2()
6094/// #     .build();
6095///
6096/// # let executor = hyper_util::rt::TokioExecutor::new();
6097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6098/// #     secret,
6099/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6100/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6101/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6102/// #     ),
6103/// # ).build().await.unwrap();
6104///
6105/// # let client = hyper_util::client::legacy::Client::builder(
6106/// #     hyper_util::rt::TokioExecutor::new()
6107/// # )
6108/// # .build(
6109/// #     hyper_rustls::HttpsConnectorBuilder::new()
6110/// #         .with_native_roots()
6111/// #         .unwrap()
6112/// #         .https_or_http()
6113/// #         .enable_http2()
6114/// #         .build()
6115/// # );
6116/// # let mut hub = CloudMemorystoreForMemcached::new(client, auth);
6117/// // You can configure optional parameters by calling the respective setters at will, and
6118/// // execute the final call using `doit()`.
6119/// // Values shown here are possibly random and not representative !
6120/// let result = hub.projects().locations_list("name")
6121///              .page_token("dolor")
6122///              .page_size(-56)
6123///              .filter("eos")
6124///              .add_extra_location_types("labore")
6125///              .doit().await;
6126/// # }
6127/// ```
6128pub struct ProjectLocationListCall<'a, C>
6129where
6130    C: 'a,
6131{
6132    hub: &'a CloudMemorystoreForMemcached<C>,
6133    _name: String,
6134    _page_token: Option<String>,
6135    _page_size: Option<i32>,
6136    _filter: Option<String>,
6137    _extra_location_types: Vec<String>,
6138    _delegate: Option<&'a mut dyn common::Delegate>,
6139    _additional_params: HashMap<String, String>,
6140    _scopes: BTreeSet<String>,
6141}
6142
6143impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
6144
6145impl<'a, C> ProjectLocationListCall<'a, C>
6146where
6147    C: common::Connector,
6148{
6149    /// Perform the operation you have build so far.
6150    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
6151        use std::borrow::Cow;
6152        use std::io::{Read, Seek};
6153
6154        use common::{url::Params, ToParts};
6155        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6156
6157        let mut dd = common::DefaultDelegate;
6158        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6159        dlg.begin(common::MethodInfo {
6160            id: "memcache.projects.locations.list",
6161            http_method: hyper::Method::GET,
6162        });
6163
6164        for &field in [
6165            "alt",
6166            "name",
6167            "pageToken",
6168            "pageSize",
6169            "filter",
6170            "extraLocationTypes",
6171        ]
6172        .iter()
6173        {
6174            if self._additional_params.contains_key(field) {
6175                dlg.finished(false);
6176                return Err(common::Error::FieldClash(field));
6177            }
6178        }
6179
6180        let mut params = Params::with_capacity(7 + self._additional_params.len());
6181        params.push("name", self._name);
6182        if let Some(value) = self._page_token.as_ref() {
6183            params.push("pageToken", value);
6184        }
6185        if let Some(value) = self._page_size.as_ref() {
6186            params.push("pageSize", value.to_string());
6187        }
6188        if let Some(value) = self._filter.as_ref() {
6189            params.push("filter", value);
6190        }
6191        if !self._extra_location_types.is_empty() {
6192            for f in self._extra_location_types.iter() {
6193                params.push("extraLocationTypes", f);
6194            }
6195        }
6196
6197        params.extend(self._additional_params.iter());
6198
6199        params.push("alt", "json");
6200        let mut url = self.hub._base_url.clone() + "v1beta2/{+name}/locations";
6201        if self._scopes.is_empty() {
6202            self._scopes
6203                .insert(Scope::CloudPlatform.as_ref().to_string());
6204        }
6205
6206        #[allow(clippy::single_element_loop)]
6207        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6208            url = params.uri_replacement(url, param_name, find_this, true);
6209        }
6210        {
6211            let to_remove = ["name"];
6212            params.remove_params(&to_remove);
6213        }
6214
6215        let url = params.parse_with_url(&url);
6216
6217        loop {
6218            let token = match self
6219                .hub
6220                .auth
6221                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6222                .await
6223            {
6224                Ok(token) => token,
6225                Err(e) => match dlg.token(e) {
6226                    Ok(token) => token,
6227                    Err(e) => {
6228                        dlg.finished(false);
6229                        return Err(common::Error::MissingToken(e));
6230                    }
6231                },
6232            };
6233            let mut req_result = {
6234                let client = &self.hub.client;
6235                dlg.pre_request();
6236                let mut req_builder = hyper::Request::builder()
6237                    .method(hyper::Method::GET)
6238                    .uri(url.as_str())
6239                    .header(USER_AGENT, self.hub._user_agent.clone());
6240
6241                if let Some(token) = token.as_ref() {
6242                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6243                }
6244
6245                let request = req_builder
6246                    .header(CONTENT_LENGTH, 0_u64)
6247                    .body(common::to_body::<String>(None));
6248
6249                client.request(request.unwrap()).await
6250            };
6251
6252            match req_result {
6253                Err(err) => {
6254                    if let common::Retry::After(d) = dlg.http_error(&err) {
6255                        sleep(d).await;
6256                        continue;
6257                    }
6258                    dlg.finished(false);
6259                    return Err(common::Error::HttpError(err));
6260                }
6261                Ok(res) => {
6262                    let (mut parts, body) = res.into_parts();
6263                    let mut body = common::Body::new(body);
6264                    if !parts.status.is_success() {
6265                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6266                        let error = serde_json::from_str(&common::to_string(&bytes));
6267                        let response = common::to_response(parts, bytes.into());
6268
6269                        if let common::Retry::After(d) =
6270                            dlg.http_failure(&response, error.as_ref().ok())
6271                        {
6272                            sleep(d).await;
6273                            continue;
6274                        }
6275
6276                        dlg.finished(false);
6277
6278                        return Err(match error {
6279                            Ok(value) => common::Error::BadRequest(value),
6280                            _ => common::Error::Failure(response),
6281                        });
6282                    }
6283                    let response = {
6284                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6285                        let encoded = common::to_string(&bytes);
6286                        match serde_json::from_str(&encoded) {
6287                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6288                            Err(error) => {
6289                                dlg.response_json_decode_error(&encoded, &error);
6290                                return Err(common::Error::JsonDecodeError(
6291                                    encoded.to_string(),
6292                                    error,
6293                                ));
6294                            }
6295                        }
6296                    };
6297
6298                    dlg.finished(true);
6299                    return Ok(response);
6300                }
6301            }
6302        }
6303    }
6304
6305    /// The resource that owns the locations collection, if applicable.
6306    ///
6307    /// Sets the *name* path property to the given value.
6308    ///
6309    /// Even though the property as already been set when instantiating this call,
6310    /// we provide this method for API completeness.
6311    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6312        self._name = new_value.to_string();
6313        self
6314    }
6315    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
6316    ///
6317    /// Sets the *page token* query property to the given value.
6318    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6319        self._page_token = Some(new_value.to_string());
6320        self
6321    }
6322    /// The maximum number of results to return. If not set, the service selects a default.
6323    ///
6324    /// Sets the *page size* query property to the given value.
6325    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
6326        self._page_size = Some(new_value);
6327        self
6328    }
6329    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
6330    ///
6331    /// Sets the *filter* query property to the given value.
6332    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6333        self._filter = Some(new_value.to_string());
6334        self
6335    }
6336    /// Optional. Unless explicitly documented otherwise, don't use this unsupported field which is primarily intended for internal usage.
6337    ///
6338    /// Append the given value to the *extra location types* query property.
6339    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6340    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6341        self._extra_location_types.push(new_value.to_string());
6342        self
6343    }
6344    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6345    /// while executing the actual API request.
6346    ///
6347    /// ````text
6348    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6349    /// ````
6350    ///
6351    /// Sets the *delegate* property to the given value.
6352    pub fn delegate(
6353        mut self,
6354        new_value: &'a mut dyn common::Delegate,
6355    ) -> ProjectLocationListCall<'a, C> {
6356        self._delegate = Some(new_value);
6357        self
6358    }
6359
6360    /// Set any additional parameter of the query string used in the request.
6361    /// It should be used to set parameters which are not yet available through their own
6362    /// setters.
6363    ///
6364    /// Please note that this method must not be used to set any of the known parameters
6365    /// which have their own setter method. If done anyway, the request will fail.
6366    ///
6367    /// # Additional Parameters
6368    ///
6369    /// * *$.xgafv* (query-string) - V1 error format.
6370    /// * *access_token* (query-string) - OAuth access token.
6371    /// * *alt* (query-string) - Data format for response.
6372    /// * *callback* (query-string) - JSONP
6373    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6374    /// * *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.
6375    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6376    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6377    /// * *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.
6378    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6379    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6380    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
6381    where
6382        T: AsRef<str>,
6383    {
6384        self._additional_params
6385            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6386        self
6387    }
6388
6389    /// Identifies the authorization scope for the method you are building.
6390    ///
6391    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6392    /// [`Scope::CloudPlatform`].
6393    ///
6394    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6395    /// tokens for more than one scope.
6396    ///
6397    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6398    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6399    /// sufficient, a read-write scope will do as well.
6400    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
6401    where
6402        St: AsRef<str>,
6403    {
6404        self._scopes.insert(String::from(scope.as_ref()));
6405        self
6406    }
6407    /// Identifies the authorization scope(s) for the method you are building.
6408    ///
6409    /// See [`Self::add_scope()`] for details.
6410    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
6411    where
6412        I: IntoIterator<Item = St>,
6413        St: AsRef<str>,
6414    {
6415        self._scopes
6416            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6417        self
6418    }
6419
6420    /// Removes all scopes, and no default scope will be used either.
6421    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6422    /// for details).
6423    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
6424        self._scopes.clear();
6425        self
6426    }
6427}