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