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