google_redis1/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 CloudRedis 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_redis1 as redis1;
49/// use redis1::api::Cluster;
50/// use redis1::{Result, Error};
51/// # async fn dox() {
52/// use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = CloudRedis::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Cluster::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_clusters_create(req, "parent")
88/// .request_id("sed")
89/// .cluster_id("amet.")
90/// .doit().await;
91///
92/// match result {
93/// Err(e) => match e {
94/// // The Error enum provides details about what exactly happened.
95/// // You can also just use its `Debug`, `Display` or `Error` traits
96/// Error::HttpError(_)
97/// |Error::Io(_)
98/// |Error::MissingAPIKey
99/// |Error::MissingToken(_)
100/// |Error::Cancelled
101/// |Error::UploadSizeLimitExceeded(_, _)
102/// |Error::Failure(_)
103/// |Error::BadRequest(_)
104/// |Error::FieldClash(_)
105/// |Error::JsonDecodeError(_, _) => println!("{}", e),
106/// },
107/// Ok(res) => println!("Success: {:?}", res),
108/// }
109/// # }
110/// ```
111#[derive(Clone)]
112pub struct CloudRedis<C> {
113 pub client: common::Client<C>,
114 pub auth: Box<dyn common::GetToken>,
115 _user_agent: String,
116 _base_url: String,
117 _root_url: String,
118}
119
120impl<C> common::Hub for CloudRedis<C> {}
121
122impl<'a, C> CloudRedis<C> {
123 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudRedis<C> {
124 CloudRedis {
125 client,
126 auth: Box::new(auth),
127 _user_agent: "google-api-rust-client/6.0.0".to_string(),
128 _base_url: "https://redis.googleapis.com/".to_string(),
129 _root_url: "https://redis.googleapis.com/".to_string(),
130 }
131 }
132
133 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
134 ProjectMethods { hub: self }
135 }
136
137 /// Set the user-agent header field to use in all requests to the server.
138 /// It defaults to `google-api-rust-client/6.0.0`.
139 ///
140 /// Returns the previously set user-agent.
141 pub fn user_agent(&mut self, agent_name: String) -> String {
142 std::mem::replace(&mut self._user_agent, agent_name)
143 }
144
145 /// Set the base url to use in all requests to the server.
146 /// It defaults to `https://redis.googleapis.com/`.
147 ///
148 /// Returns the previously set base url.
149 pub fn base_url(&mut self, new_base_url: String) -> String {
150 std::mem::replace(&mut self._base_url, new_base_url)
151 }
152
153 /// Set the root url to use in all requests to the server.
154 /// It defaults to `https://redis.googleapis.com/`.
155 ///
156 /// Returns the previously set root url.
157 pub fn root_url(&mut self, new_root_url: String) -> String {
158 std::mem::replace(&mut self._root_url, new_root_url)
159 }
160}
161
162// ############
163// SCHEMAS ###
164// ##########
165/// Configuration of the AOF based persistence.
166///
167/// This type is not used in any activity, and only used as *part* of another schema.
168///
169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
170#[serde_with::serde_as]
171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
172pub struct AOFConfig {
173 /// Optional. fsync configuration.
174 #[serde(rename = "appendFsync")]
175 pub append_fsync: Option<String>,
176}
177
178impl common::Part for AOFConfig {}
179
180/// There is no detailed description.
181///
182/// This type is not used in any activity, and only used as *part* of another schema.
183///
184#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
185#[serde_with::serde_as]
186#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
187pub struct CertChain {
188 /// The certificates that form the CA chain, from leaf to root order.
189 pub certificates: Option<Vec<String>>,
190}
191
192impl common::Part for CertChain {}
193
194/// Redis cluster certificate authority
195///
196/// # Activities
197///
198/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
199/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
200///
201/// * [locations clusters get certificate authority projects](ProjectLocationClusterGetCertificateAuthorityCall) (response)
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct CertificateAuthority {
206 /// no description provided
207 #[serde(rename = "managedServerCa")]
208 pub managed_server_ca: Option<ManagedCertificateAuthority>,
209 /// Identifier. Unique name of the resource in this scope including project, location and cluster using the form: `projects/{project}/locations/{location}/clusters/{cluster}/certificateAuthority`
210 pub name: Option<String>,
211}
212
213impl common::ResponseResult for CertificateAuthority {}
214
215/// A cluster instance.
216///
217/// # Activities
218///
219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
221///
222/// * [locations clusters create projects](ProjectLocationClusterCreateCall) (request)
223/// * [locations clusters get projects](ProjectLocationClusterGetCall) (response)
224/// * [locations clusters patch projects](ProjectLocationClusterPatchCall) (request)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct Cluster {
229 /// Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster.
230 #[serde(rename = "authorizationMode")]
231 pub authorization_mode: Option<String>,
232 /// Output only. The timestamp associated with the cluster creation request.
233 #[serde(rename = "createTime")]
234 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
235 /// Optional. The delete operation will fail when the value is set to true.
236 #[serde(rename = "deletionProtectionEnabled")]
237 pub deletion_protection_enabled: Option<bool>,
238 /// Output only. Endpoints created on each given network, for Redis clients to connect to the cluster. Currently only one discovery endpoint is supported.
239 #[serde(rename = "discoveryEndpoints")]
240 pub discovery_endpoints: Option<Vec<DiscoveryEndpoint>>,
241 /// Required. Identifier. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
242 pub name: Option<String>,
243 /// Optional. The type of a redis node in the cluster. NodeType determines the underlying machine-type of a redis node.
244 #[serde(rename = "nodeType")]
245 pub node_type: Option<String>,
246 /// Optional. Persistence config (RDB, AOF) for the cluster.
247 #[serde(rename = "persistenceConfig")]
248 pub persistence_config: Option<ClusterPersistenceConfig>,
249 /// Output only. Precise value of redis memory size in GB for the entire cluster.
250 #[serde(rename = "preciseSizeGb")]
251 pub precise_size_gb: Option<f64>,
252 /// Required. Each PscConfig configures the consumer network where IPs will be designated to the cluster for client access through Private Service Connect Automation. Currently, only one PscConfig is supported.
253 #[serde(rename = "pscConfigs")]
254 pub psc_configs: Option<Vec<PscConfig>>,
255 /// Output only. PSC connections for discovery of the cluster topology and accessing the cluster.
256 #[serde(rename = "pscConnections")]
257 pub psc_connections: Option<Vec<PscConnection>>,
258 /// Optional. Key/Value pairs of customer overrides for mutable Redis Configs
259 #[serde(rename = "redisConfigs")]
260 pub redis_configs: Option<HashMap<String, String>>,
261 /// Optional. The number of replica nodes per shard.
262 #[serde(rename = "replicaCount")]
263 pub replica_count: Option<i32>,
264 /// Required. Number of shards for the Redis cluster.
265 #[serde(rename = "shardCount")]
266 pub shard_count: Option<i32>,
267 /// Output only. Redis memory size in GB for the entire cluster rounded up to the next integer.
268 #[serde(rename = "sizeGb")]
269 pub size_gb: Option<i32>,
270 /// Output only. The current state of this cluster. Can be CREATING, READY, UPDATING, DELETING and SUSPENDED
271 pub state: Option<String>,
272 /// Output only. Additional information about the current state of the cluster.
273 #[serde(rename = "stateInfo")]
274 pub state_info: Option<StateInfo>,
275 /// Optional. The in-transit encryption for the Redis cluster. If not provided, encryption is disabled for the cluster.
276 #[serde(rename = "transitEncryptionMode")]
277 pub transit_encryption_mode: Option<String>,
278 /// Output only. System assigned, unique identifier for the cluster.
279 pub uid: Option<String>,
280 /// Optional. This config will be used to determine how the customer wants us to distribute cluster resources within the region.
281 #[serde(rename = "zoneDistributionConfig")]
282 pub zone_distribution_config: Option<ZoneDistributionConfig>,
283}
284
285impl common::RequestValue for Cluster {}
286impl common::ResponseResult for Cluster {}
287
288/// Configuration of the persistence functionality.
289///
290/// This type is not used in any activity, and only used as *part* of another schema.
291///
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct ClusterPersistenceConfig {
296 /// Optional. AOF configuration. This field will be ignored if mode is not AOF.
297 #[serde(rename = "aofConfig")]
298 pub aof_config: Option<AOFConfig>,
299 /// Optional. The mode of persistence.
300 pub mode: Option<String>,
301 /// Optional. RDB configuration. This field will be ignored if mode is not RDB.
302 #[serde(rename = "rdbConfig")]
303 pub rdb_config: Option<RDBConfig>,
304}
305
306impl common::Part for ClusterPersistenceConfig {}
307
308/// Endpoints on each network, for Redis clients to connect to the cluster.
309///
310/// This type is not used in any activity, and only used as *part* of another schema.
311///
312#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
313#[serde_with::serde_as]
314#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
315pub struct DiscoveryEndpoint {
316 /// Output only. Address of the exposed Redis endpoint used by clients to connect to the service. The address could be either IP or hostname.
317 pub address: Option<String>,
318 /// Output only. The port number of the exposed Redis endpoint.
319 pub port: Option<i32>,
320 /// Output only. Customer configuration for where the endpoint is created and accessed from.
321 #[serde(rename = "pscConfig")]
322 pub psc_config: Option<PscConfig>,
323}
324
325impl common::Part for DiscoveryEndpoint {}
326
327/// 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); }
328///
329/// # Activities
330///
331/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
332/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
333///
334/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
335/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
337#[serde_with::serde_as]
338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
339pub struct Empty {
340 _never_set: Option<bool>,
341}
342
343impl common::ResponseResult for Empty {}
344
345/// Request for Export.
346///
347/// # Activities
348///
349/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
350/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
351///
352/// * [locations instances export projects](ProjectLocationInstanceExportCall) (request)
353#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
354#[serde_with::serde_as]
355#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
356pub struct ExportInstanceRequest {
357 /// Required. Specify data to be exported.
358 #[serde(rename = "outputConfig")]
359 pub output_config: Option<OutputConfig>,
360}
361
362impl common::RequestValue for ExportInstanceRequest {}
363
364/// Request for Failover.
365///
366/// # Activities
367///
368/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
369/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
370///
371/// * [locations instances failover projects](ProjectLocationInstanceFailoverCall) (request)
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct FailoverInstanceRequest {
376 /// Optional. Available data protection modes that the user can choose. If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
377 #[serde(rename = "dataProtectionMode")]
378 pub data_protection_mode: Option<String>,
379}
380
381impl common::RequestValue for FailoverInstanceRequest {}
382
383/// The Cloud Storage location for the output content
384///
385/// This type is not used in any activity, and only used as *part* of another schema.
386///
387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
388#[serde_with::serde_as]
389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
390pub struct GcsDestination {
391 /// Required. Data destination URI (e.g. 'gs://my_bucket/my_object'). Existing files will be overwritten.
392 pub uri: Option<String>,
393}
394
395impl common::Part for GcsDestination {}
396
397/// The Cloud Storage location for the input content
398///
399/// This type is not used in any activity, and only used as *part* of another schema.
400///
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as]
403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
404pub struct GcsSource {
405 /// Required. Source data URI. (e.g. 'gs://my_bucket/my_object').
406 pub uri: Option<String>,
407}
408
409impl common::Part for GcsSource {}
410
411/// Request for Import.
412///
413/// # Activities
414///
415/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
416/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
417///
418/// * [locations instances import projects](ProjectLocationInstanceImportCall) (request)
419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
420#[serde_with::serde_as]
421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
422pub struct ImportInstanceRequest {
423 /// Required. Specify data to be imported.
424 #[serde(rename = "inputConfig")]
425 pub input_config: Option<InputConfig>,
426}
427
428impl common::RequestValue for ImportInstanceRequest {}
429
430/// The input content
431///
432/// This type is not used in any activity, and only used as *part* of another schema.
433///
434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
435#[serde_with::serde_as]
436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
437pub struct InputConfig {
438 /// Google Cloud Storage location where input content is located.
439 #[serde(rename = "gcsSource")]
440 pub gcs_source: Option<GcsSource>,
441}
442
443impl common::Part for InputConfig {}
444
445/// A Memorystore for Redis instance.
446///
447/// # Activities
448///
449/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
450/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
451///
452/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request)
453/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
454/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
455#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
456#[serde_with::serde_as]
457#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
458pub struct Instance {
459 /// Optional. If specified, at least one node will be provisioned in this zone in addition to the zone specified in location_id. Only applicable to standard tier. If provided, it must be a different zone from the one provided in [location_id]. Additional nodes beyond the first 2 will be placed in zones selected by the service.
460 #[serde(rename = "alternativeLocationId")]
461 pub alternative_location_id: Option<String>,
462 /// Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to "true" AUTH is enabled on the instance. Default value is "false" meaning AUTH is disabled.
463 #[serde(rename = "authEnabled")]
464 pub auth_enabled: Option<bool>,
465 /// Optional. The full name of the Google Compute Engine [network](https://cloud.google.com/vpc/docs/vpc) to which the instance is connected. If left unspecified, the `default` network will be used.
466 #[serde(rename = "authorizedNetwork")]
467 pub authorized_network: Option<String>,
468 /// Optional. The available maintenance versions that an instance could update to.
469 #[serde(rename = "availableMaintenanceVersions")]
470 pub available_maintenance_versions: Option<Vec<String>>,
471 /// Optional. The network connect mode of the Redis instance. If not provided, the connect mode defaults to DIRECT_PEERING.
472 #[serde(rename = "connectMode")]
473 pub connect_mode: Option<String>,
474 /// Output only. The time the instance was created.
475 #[serde(rename = "createTime")]
476 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
477 /// Output only. The current zone where the Redis primary node is located. In basic tier, this will always be the same as [location_id]. In standard tier, this can be the zone of any node in the instance.
478 #[serde(rename = "currentLocationId")]
479 pub current_location_id: Option<String>,
480 /// Optional. The KMS key reference that the customer provides when trying to create the instance.
481 #[serde(rename = "customerManagedKey")]
482 pub customer_managed_key: Option<String>,
483 /// An arbitrary and optional user-provided name for the instance.
484 #[serde(rename = "displayName")]
485 pub display_name: Option<String>,
486 /// Output only. Hostname or IP address of the exposed Redis endpoint used by clients to connect to the service.
487 pub host: Option<String>,
488 /// Resource labels to represent user provided metadata
489 pub labels: Option<HashMap<String, String>>,
490 /// Optional. The zone where the instance will be provisioned. If not provided, the service will choose a zone from the specified region for the instance. For standard tier, additional nodes will be added across multiple zones for protection against zonal failures. If specified, at least one node will be provisioned in this zone.
491 #[serde(rename = "locationId")]
492 pub location_id: Option<String>,
493 /// Optional. The maintenance policy for the instance. If not provided, maintenance events can be performed at any time.
494 #[serde(rename = "maintenancePolicy")]
495 pub maintenance_policy: Option<MaintenancePolicy>,
496 /// Output only. Date and time of upcoming maintenance events which have been scheduled.
497 #[serde(rename = "maintenanceSchedule")]
498 pub maintenance_schedule: Option<MaintenanceSchedule>,
499 /// Optional. The self service update maintenance version. The version is date based such as "20210712_00_00".
500 #[serde(rename = "maintenanceVersion")]
501 pub maintenance_version: Option<String>,
502 /// Required. Redis memory size in GiB.
503 #[serde(rename = "memorySizeGb")]
504 pub memory_size_gb: Option<i32>,
505 /// 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: Redis instances are managed and addressed at regional level so location_id here refers to a GCP region; however, users may choose which specific zone (or collection of zones for cross-zone instances) an instance should be provisioned in. Refer to location_id and alternative_location_id fields for more details.
506 pub name: Option<String>,
507 /// Output only. Info per node.
508 pub nodes: Option<Vec<NodeInfo>>,
509 /// Optional. Persistence configuration parameters
510 #[serde(rename = "persistenceConfig")]
511 pub persistence_config: Option<PersistenceConfig>,
512 /// Output only. Cloud IAM identity used by import / export operations to transfer data to/from Cloud Storage. Format is "serviceAccount:". The value may change over time for a given instance so should be checked before each import/export operation.
513 #[serde(rename = "persistenceIamIdentity")]
514 pub persistence_iam_identity: Option<String>,
515 /// Output only. The port number of the exposed Redis endpoint.
516 pub port: Option<i32>,
517 /// Output only. Hostname or IP address of the exposed readonly Redis endpoint. Standard tier only. Targets all healthy replica nodes in instance. Replication is asynchronous and replica nodes will exhibit some lag behind the primary. Write requests must target 'host'.
518 #[serde(rename = "readEndpoint")]
519 pub read_endpoint: Option<String>,
520 /// Output only. The port number of the exposed readonly redis endpoint. Standard tier only. Write requests should target 'port'.
521 #[serde(rename = "readEndpointPort")]
522 pub read_endpoint_port: Option<i32>,
523 /// Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED.
524 #[serde(rename = "readReplicasMode")]
525 pub read_replicas_mode: Option<String>,
526 /// Optional. Redis configuration parameters, according to http://redis.io/topics/config. Currently, the only supported parameters are: Redis version 3.2 and newer: * maxmemory-policy * notify-keyspace-events Redis version 4.0 and newer: * activedefrag * lfu-decay-time * lfu-log-factor * maxmemory-gb Redis version 5.0 and newer: * stream-node-max-bytes * stream-node-max-entries
527 #[serde(rename = "redisConfigs")]
528 pub redis_configs: Option<HashMap<String, String>>,
529 /// Optional. The version of Redis software. If not provided, latest supported version will be used. Currently, the supported values are: * `REDIS_3_2` for Redis 3.2 compatibility * `REDIS_4_0` for Redis 4.0 compatibility (default) * `REDIS_5_0` for Redis 5.0 compatibility * `REDIS_6_X` for Redis 6.x compatibility * `REDIS_7_0` for Redis 7.0 compatibility
530 #[serde(rename = "redisVersion")]
531 pub redis_version: Option<String>,
532 /// Optional. The number of replica nodes. The valid range for the Standard Tier with read replicas enabled is [1-5] and defaults to 2. If read replicas are not enabled for a Standard Tier instance, the only valid value is 1 and the default is 1. The valid value for basic tier is 0 and the default is also 0.
533 #[serde(rename = "replicaCount")]
534 pub replica_count: Option<i32>,
535 /// Optional. For DIRECT_PEERING mode, the CIDR range of internal addresses that are reserved for this instance. Range must be unique and non-overlapping with existing subnets in an authorized network. For PRIVATE_SERVICE_ACCESS mode, the name of one allocated IP address ranges associated with this private service access connection. If not provided, the service will choose an unused /29 block, for example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED the default block size is /28.
536 #[serde(rename = "reservedIpRange")]
537 pub reserved_ip_range: Option<String>,
538 /// Optional. Output only. Reserved for future use.
539 #[serde(rename = "satisfiesPzi")]
540 pub satisfies_pzi: Option<bool>,
541 /// Optional. Output only. Reserved for future use.
542 #[serde(rename = "satisfiesPzs")]
543 pub satisfies_pzs: Option<bool>,
544 /// Optional. Additional IP range for node placement. Required when enabling read replicas on an existing instance. For DIRECT_PEERING mode value must be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value must be the name of an allocated address range associated with the private service access connection, or "auto".
545 #[serde(rename = "secondaryIpRange")]
546 pub secondary_ip_range: Option<String>,
547 /// Output only. List of server CA certificates for the instance.
548 #[serde(rename = "serverCaCerts")]
549 pub server_ca_certs: Option<Vec<TlsCertificate>>,
550 /// Output only. The current state of this instance.
551 pub state: Option<String>,
552 /// Output only. Additional information about the current status of this instance, if available.
553 #[serde(rename = "statusMessage")]
554 pub status_message: Option<String>,
555 /// Optional. reasons that causes instance in "SUSPENDED" state.
556 #[serde(rename = "suspensionReasons")]
557 pub suspension_reasons: Option<Vec<String>>,
558 /// Required. The service tier of the instance.
559 pub tier: Option<String>,
560 /// Optional. The TLS mode of the Redis instance. If not provided, TLS is disabled for the instance.
561 #[serde(rename = "transitEncryptionMode")]
562 pub transit_encryption_mode: Option<String>,
563}
564
565impl common::RequestValue for Instance {}
566impl common::ResponseResult for Instance {}
567
568/// Instance AUTH string details.
569///
570/// # Activities
571///
572/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
573/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
574///
575/// * [locations instances get auth string projects](ProjectLocationInstanceGetAuthStringCall) (response)
576#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
577#[serde_with::serde_as]
578#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
579pub struct InstanceAuthString {
580 /// AUTH string set on the instance.
581 #[serde(rename = "authString")]
582 pub auth_string: Option<String>,
583}
584
585impl common::ResponseResult for InstanceAuthString {}
586
587/// Response for ListClusters.
588///
589/// # Activities
590///
591/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
592/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
593///
594/// * [locations clusters list projects](ProjectLocationClusterListCall) (response)
595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
596#[serde_with::serde_as]
597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
598pub struct ListClustersResponse {
599 /// A list of Redis clusters 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. If in such an aggregated query a location is unavailable, a placeholder Redis entry is included in the response with the `name` field set to a value of the form `projects/{project_id}/locations/{location_id}/clusters/`- and the `status` field set to ERROR and `status_message` field set to "location not available for ListClusters".
600 pub clusters: Option<Vec<Cluster>>,
601 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
602 #[serde(rename = "nextPageToken")]
603 pub next_page_token: Option<String>,
604 /// Locations that could not be reached.
605 pub unreachable: Option<Vec<String>>,
606}
607
608impl common::ResponseResult for ListClustersResponse {}
609
610/// Response for ListInstances.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
619#[serde_with::serde_as]
620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
621pub struct ListInstancesResponse {
622 /// A list of Redis 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. If in such an aggregated query a location is unavailable, a placeholder Redis entry is included in the response with the `name` field set to a value of the form `projects/{project_id}/locations/{location_id}/instances/`- and the `status` field set to ERROR and `status_message` field set to "location not available for ListInstances".
623 pub instances: Option<Vec<Instance>>,
624 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
625 #[serde(rename = "nextPageToken")]
626 pub next_page_token: Option<String>,
627 /// Locations that could not be reached.
628 pub unreachable: Option<Vec<String>>,
629}
630
631impl common::ResponseResult for ListInstancesResponse {}
632
633/// The response message for Locations.ListLocations.
634///
635/// # Activities
636///
637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
639///
640/// * [locations list projects](ProjectLocationListCall) (response)
641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
642#[serde_with::serde_as]
643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
644pub struct ListLocationsResponse {
645 /// A list of locations that matches the specified filter in the request.
646 pub locations: Option<Vec<Location>>,
647 /// The standard List next-page token.
648 #[serde(rename = "nextPageToken")]
649 pub next_page_token: Option<String>,
650}
651
652impl common::ResponseResult for ListLocationsResponse {}
653
654/// The response message for Operations.ListOperations.
655///
656/// # Activities
657///
658/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
659/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
660///
661/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
662#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
663#[serde_with::serde_as]
664#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
665pub struct ListOperationsResponse {
666 /// The standard List next-page token.
667 #[serde(rename = "nextPageToken")]
668 pub next_page_token: Option<String>,
669 /// A list of operations that matches the specified filter in the request.
670 pub operations: Option<Vec<Operation>>,
671}
672
673impl common::ResponseResult for ListOperationsResponse {}
674
675/// A resource that represents a Google Cloud location.
676///
677/// # Activities
678///
679/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
680/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
681///
682/// * [locations get projects](ProjectLocationGetCall) (response)
683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
684#[serde_with::serde_as]
685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
686pub struct Location {
687 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
688 #[serde(rename = "displayName")]
689 pub display_name: Option<String>,
690 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
691 pub labels: Option<HashMap<String, String>>,
692 /// Resource ID for the region. For example: "us-east1".
693 #[serde(rename = "locationId")]
694 pub location_id: Option<String>,
695 /// Output only. The set of available zones in the location. The map is keyed by the lowercase ID of each zone, as defined by Compute Engine. These keys can be specified in `location_id` or `alternative_location_id` fields when creating a Redis instance.
696 pub metadata: Option<HashMap<String, serde_json::Value>>,
697 /// Full resource name for the region. For example: "projects/example-project/locations/us-east1".
698 pub name: Option<String>,
699}
700
701impl common::ResponseResult for Location {}
702
703/// Maintenance policy for an instance.
704///
705/// This type is not used in any activity, and only used as *part* of another schema.
706///
707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
708#[serde_with::serde_as]
709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
710pub struct MaintenancePolicy {
711 /// Output only. The time when the policy was created.
712 #[serde(rename = "createTime")]
713 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
714 /// Optional. Description of what this policy is for. Create/Update methods return INVALID_ARGUMENT if the length is greater than 512.
715 pub description: Option<String>,
716 /// Output only. The time when the policy was last updated.
717 #[serde(rename = "updateTime")]
718 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
719 /// Optional. Maintenance window that is applied to resources covered by this policy. Minimum 1. For the current version, the maximum number of weekly_window is expected to be one.
720 #[serde(rename = "weeklyMaintenanceWindow")]
721 pub weekly_maintenance_window: Option<Vec<WeeklyMaintenanceWindow>>,
722}
723
724impl common::Part for MaintenancePolicy {}
725
726/// Upcoming maintenance schedule. If no maintenance is scheduled, fields are not populated.
727///
728/// This type is not used in any activity, and only used as *part* of another schema.
729///
730#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
731#[serde_with::serde_as]
732#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
733pub struct MaintenanceSchedule {
734 /// If the scheduled maintenance can be rescheduled, default is true.
735 #[serde(rename = "canReschedule")]
736 pub can_reschedule: Option<bool>,
737 /// Output only. The end time of any upcoming scheduled maintenance for this instance.
738 #[serde(rename = "endTime")]
739 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
740 /// Output only. The deadline that the maintenance schedule start time can not go beyond, including reschedule.
741 #[serde(rename = "scheduleDeadlineTime")]
742 pub schedule_deadline_time: Option<chrono::DateTime<chrono::offset::Utc>>,
743 /// Output only. The start time of any upcoming scheduled maintenance for this instance.
744 #[serde(rename = "startTime")]
745 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
746}
747
748impl common::Part for MaintenanceSchedule {}
749
750/// There is no detailed description.
751///
752/// This type is not used in any activity, and only used as *part* of another schema.
753///
754#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
755#[serde_with::serde_as]
756#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
757pub struct ManagedCertificateAuthority {
758 /// The PEM encoded CA certificate chains for redis managed server authentication
759 #[serde(rename = "caCerts")]
760 pub ca_certs: Option<Vec<CertChain>>,
761}
762
763impl common::Part for ManagedCertificateAuthority {}
764
765/// Node specific properties.
766///
767/// This type is not used in any activity, and only used as *part* of another schema.
768///
769#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
770#[serde_with::serde_as]
771#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
772pub struct NodeInfo {
773 /// Output only. Node identifying string. e.g. 'node-0', 'node-1'
774 pub id: Option<String>,
775 /// Output only. Location of the node.
776 pub zone: Option<String>,
777}
778
779impl common::Part for NodeInfo {}
780
781/// This resource represents a long-running operation that is the result of a network API call.
782///
783/// # Activities
784///
785/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
786/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
787///
788/// * [locations clusters create projects](ProjectLocationClusterCreateCall) (response)
789/// * [locations clusters delete projects](ProjectLocationClusterDeleteCall) (response)
790/// * [locations clusters patch projects](ProjectLocationClusterPatchCall) (response)
791/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
792/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
793/// * [locations instances export projects](ProjectLocationInstanceExportCall) (response)
794/// * [locations instances failover projects](ProjectLocationInstanceFailoverCall) (response)
795/// * [locations instances import projects](ProjectLocationInstanceImportCall) (response)
796/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
797/// * [locations instances reschedule maintenance projects](ProjectLocationInstanceRescheduleMaintenanceCall) (response)
798/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (response)
799/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
800#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
801#[serde_with::serde_as]
802#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
803pub struct Operation {
804 /// 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.
805 pub done: Option<bool>,
806 /// The error result of the operation in case of failure or cancellation.
807 pub error: Option<Status>,
808 /// { `createTime`: The time the operation was created. `endTime`: The time the operation finished running. `target`: Server-defined resource path for the target of the operation. `verb`: Name of the verb executed by the operation. `statusDetail`: Human-readable status of the operation, if any. `cancelRequested`: Identifies whether the user has requested cancellation of the operation. Operations that have successfully been cancelled have Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. `apiVersion`: API version used to start the operation. }
809 pub metadata: Option<HashMap<String, serde_json::Value>>,
810 /// 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}`.
811 pub name: Option<String>,
812 /// 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`.
813 pub response: Option<HashMap<String, serde_json::Value>>,
814}
815
816impl common::ResponseResult for Operation {}
817
818/// The output content
819///
820/// This type is not used in any activity, and only used as *part* of another schema.
821///
822#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
823#[serde_with::serde_as]
824#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
825pub struct OutputConfig {
826 /// Google Cloud Storage destination for output content.
827 #[serde(rename = "gcsDestination")]
828 pub gcs_destination: Option<GcsDestination>,
829}
830
831impl common::Part for OutputConfig {}
832
833/// Configuration of the persistence functionality.
834///
835/// This type is not used in any activity, and only used as *part* of another schema.
836///
837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
838#[serde_with::serde_as]
839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
840pub struct PersistenceConfig {
841 /// Optional. Controls whether Persistence features are enabled. If not provided, the existing value will be used.
842 #[serde(rename = "persistenceMode")]
843 pub persistence_mode: Option<String>,
844 /// Output only. The next time that a snapshot attempt is scheduled to occur.
845 #[serde(rename = "rdbNextSnapshotTime")]
846 pub rdb_next_snapshot_time: Option<chrono::DateTime<chrono::offset::Utc>>,
847 /// Optional. Period between RDB snapshots. Snapshots will be attempted every period starting from the provided snapshot start time. For example, a start time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, 18:45, and 00:45 the next day, and so on. If not provided, TWENTY_FOUR_HOURS will be used as default.
848 #[serde(rename = "rdbSnapshotPeriod")]
849 pub rdb_snapshot_period: Option<String>,
850 /// Optional. Date and time that the first snapshot was/will be attempted, and to which future snapshots will be aligned. If not provided, the current time will be used.
851 #[serde(rename = "rdbSnapshotStartTime")]
852 pub rdb_snapshot_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
853}
854
855impl common::Part for PersistenceConfig {}
856
857/// There is no detailed description.
858///
859/// This type is not used in any activity, and only used as *part* of another schema.
860///
861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
862#[serde_with::serde_as]
863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
864pub struct PscConfig {
865 /// Required. The network where the IP address of the discovery endpoint will be reserved, in the form of projects/{network_project}/global/networks/{network_id}.
866 pub network: Option<String>,
867}
868
869impl common::Part for PscConfig {}
870
871/// Details of consumer resources in a PSC connection.
872///
873/// This type is not used in any activity, and only used as *part* of another schema.
874///
875#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
876#[serde_with::serde_as]
877#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
878pub struct PscConnection {
879 /// Output only. The IP allocated on the consumer network for the PSC forwarding rule.
880 pub address: Option<String>,
881 /// Output only. The URI of the consumer side forwarding rule. Example: projects/{projectNumOrId}/regions/us-east1/forwardingRules/{resourceId}.
882 #[serde(rename = "forwardingRule")]
883 pub forwarding_rule: Option<String>,
884 /// The consumer network where the IP address resides, in the form of projects/{project_id}/global/networks/{network_id}.
885 pub network: Option<String>,
886 /// Output only. The consumer project_id where the forwarding rule is created from.
887 #[serde(rename = "projectId")]
888 pub project_id: Option<String>,
889 /// Output only. The PSC connection id of the forwarding rule connected to the service attachment.
890 #[serde(rename = "pscConnectionId")]
891 pub psc_connection_id: Option<String>,
892}
893
894impl common::Part for PscConnection {}
895
896/// Configuration of the RDB based persistence.
897///
898/// This type is not used in any activity, and only used as *part* of another schema.
899///
900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
901#[serde_with::serde_as]
902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
903pub struct RDBConfig {
904 /// Optional. Period between RDB snapshots.
905 #[serde(rename = "rdbSnapshotPeriod")]
906 pub rdb_snapshot_period: Option<String>,
907 /// Optional. The time that the first snapshot was/will be attempted, and to which future snapshots will be aligned. If not provided, the current time will be used.
908 #[serde(rename = "rdbSnapshotStartTime")]
909 pub rdb_snapshot_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
910}
911
912impl common::Part for RDBConfig {}
913
914/// Request for RescheduleMaintenance.
915///
916/// # Activities
917///
918/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
919/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
920///
921/// * [locations instances reschedule maintenance projects](ProjectLocationInstanceRescheduleMaintenanceCall) (request)
922#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
923#[serde_with::serde_as]
924#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
925pub struct RescheduleMaintenanceRequest {
926 /// Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.
927 #[serde(rename = "rescheduleType")]
928 pub reschedule_type: Option<String>,
929 /// Optional. 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`.
930 #[serde(rename = "scheduleTime")]
931 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
932}
933
934impl common::RequestValue for RescheduleMaintenanceRequest {}
935
936/// Represents additional information about the state of the cluster.
937///
938/// This type is not used in any activity, and only used as *part* of another schema.
939///
940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
941#[serde_with::serde_as]
942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
943pub struct StateInfo {
944 /// Describes ongoing update on the cluster when cluster state is UPDATING.
945 #[serde(rename = "updateInfo")]
946 pub update_info: Option<UpdateInfo>,
947}
948
949impl common::Part for StateInfo {}
950
951/// 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).
952///
953/// This type is not used in any activity, and only used as *part* of another schema.
954///
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct Status {
959 /// The status code, which should be an enum value of google.rpc.Code.
960 pub code: Option<i32>,
961 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
962 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
963 /// 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.
964 pub message: Option<String>,
965}
966
967impl common::Part for Status {}
968
969/// 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`.
970///
971/// This type is not used in any activity, and only used as *part* of another schema.
972///
973#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
974#[serde_with::serde_as]
975#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
976pub struct TimeOfDay {
977 /// Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
978 pub hours: Option<i32>,
979 /// Minutes of hour of day. Must be from 0 to 59.
980 pub minutes: Option<i32>,
981 /// Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
982 pub nanos: Option<i32>,
983 /// Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
984 pub seconds: Option<i32>,
985}
986
987impl common::Part for TimeOfDay {}
988
989/// TlsCertificate Resource
990///
991/// This type is not used in any activity, and only used as *part* of another schema.
992///
993#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
994#[serde_with::serde_as]
995#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
996pub struct TlsCertificate {
997 /// PEM representation.
998 pub cert: Option<String>,
999 /// Output only. The time when the certificate was created in [RFC 3339](https://tools.ietf.org/html/rfc3339) format, for example `2020-05-18T00:00:00.094Z`.
1000 #[serde(rename = "createTime")]
1001 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1002 /// Output only. The time when the certificate expires in [RFC 3339](https://tools.ietf.org/html/rfc3339) format, for example `2020-05-18T00:00:00.094Z`.
1003 #[serde(rename = "expireTime")]
1004 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1005 /// Serial number, as extracted from the certificate.
1006 #[serde(rename = "serialNumber")]
1007 pub serial_number: Option<String>,
1008 /// Sha1 Fingerprint of the certificate.
1009 #[serde(rename = "sha1Fingerprint")]
1010 pub sha1_fingerprint: Option<String>,
1011}
1012
1013impl common::Part for TlsCertificate {}
1014
1015/// Represents information about an updating cluster.
1016///
1017/// This type is not used in any activity, and only used as *part* of another schema.
1018///
1019#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1020#[serde_with::serde_as]
1021#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1022pub struct UpdateInfo {
1023 /// Target number of replica nodes per shard.
1024 #[serde(rename = "targetReplicaCount")]
1025 pub target_replica_count: Option<i32>,
1026 /// Target number of shards for redis cluster
1027 #[serde(rename = "targetShardCount")]
1028 pub target_shard_count: Option<i32>,
1029}
1030
1031impl common::Part for UpdateInfo {}
1032
1033/// Request for UpgradeInstance.
1034///
1035/// # Activities
1036///
1037/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1038/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1039///
1040/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (request)
1041#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1042#[serde_with::serde_as]
1043#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1044pub struct UpgradeInstanceRequest {
1045 /// Required. Specifies the target version of Redis software to upgrade to.
1046 #[serde(rename = "redisVersion")]
1047 pub redis_version: Option<String>,
1048}
1049
1050impl common::RequestValue for UpgradeInstanceRequest {}
1051
1052/// Time window in which disruptive maintenance updates occur. Non-disruptive updates can occur inside or outside this window.
1053///
1054/// This type is not used in any activity, and only used as *part* of another schema.
1055///
1056#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1057#[serde_with::serde_as]
1058#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1059pub struct WeeklyMaintenanceWindow {
1060 /// Required. The day of week that maintenance updates occur.
1061 pub day: Option<String>,
1062 /// Output only. Duration of the maintenance window. The current window is fixed at 1 hour.
1063 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1064 pub duration: Option<chrono::Duration>,
1065 /// Required. Start time of the window in UTC time.
1066 #[serde(rename = "startTime")]
1067 pub start_time: Option<TimeOfDay>,
1068}
1069
1070impl common::Part for WeeklyMaintenanceWindow {}
1071
1072/// Zone distribution config for allocation of cluster resources.
1073///
1074/// This type is not used in any activity, and only used as *part* of another schema.
1075///
1076#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1077#[serde_with::serde_as]
1078#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1079pub struct ZoneDistributionConfig {
1080 /// Optional. The mode of zone distribution. Defaults to MULTI_ZONE, when not specified.
1081 pub mode: Option<String>,
1082 /// Optional. When SINGLE ZONE distribution is selected, zone field would be used to allocate all resources in that zone. This is not applicable to MULTI_ZONE, and would be ignored for MULTI_ZONE clusters.
1083 pub zone: Option<String>,
1084}
1085
1086impl common::Part for ZoneDistributionConfig {}
1087
1088// ###################
1089// MethodBuilders ###
1090// #################
1091
1092/// A builder providing access to all methods supported on *project* resources.
1093/// It is not used directly, but through the [`CloudRedis`] hub.
1094///
1095/// # Example
1096///
1097/// Instantiate a resource builder
1098///
1099/// ```test_harness,no_run
1100/// extern crate hyper;
1101/// extern crate hyper_rustls;
1102/// extern crate google_redis1 as redis1;
1103///
1104/// # async fn dox() {
1105/// use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1106///
1107/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1108/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1109/// secret,
1110/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1111/// ).build().await.unwrap();
1112///
1113/// let client = hyper_util::client::legacy::Client::builder(
1114/// hyper_util::rt::TokioExecutor::new()
1115/// )
1116/// .build(
1117/// hyper_rustls::HttpsConnectorBuilder::new()
1118/// .with_native_roots()
1119/// .unwrap()
1120/// .https_or_http()
1121/// .enable_http1()
1122/// .build()
1123/// );
1124/// let mut hub = CloudRedis::new(client, auth);
1125/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1126/// // like `locations_clusters_create(...)`, `locations_clusters_delete(...)`, `locations_clusters_get(...)`, `locations_clusters_get_certificate_authority(...)`, `locations_clusters_list(...)`, `locations_clusters_patch(...)`, `locations_get(...)`, `locations_instances_create(...)`, `locations_instances_delete(...)`, `locations_instances_export(...)`, `locations_instances_failover(...)`, `locations_instances_get(...)`, `locations_instances_get_auth_string(...)`, `locations_instances_import(...)`, `locations_instances_list(...)`, `locations_instances_patch(...)`, `locations_instances_reschedule_maintenance(...)`, `locations_instances_upgrade(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
1127/// // to build up your call.
1128/// let rb = hub.projects();
1129/// # }
1130/// ```
1131pub struct ProjectMethods<'a, C>
1132where
1133 C: 'a,
1134{
1135 hub: &'a CloudRedis<C>,
1136}
1137
1138impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1139
1140impl<'a, C> ProjectMethods<'a, C> {
1141 /// Create a builder to help you perform the following task:
1142 ///
1143 /// Creates a Redis cluster based on the specified properties. The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis cluster will be fully functional. The completed longrunning.Operation will contain the new cluster object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1144 ///
1145 /// # Arguments
1146 ///
1147 /// * `request` - No description provided.
1148 /// * `parent` - Required. The resource name of the cluster location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
1149 pub fn locations_clusters_create(
1150 &self,
1151 request: Cluster,
1152 parent: &str,
1153 ) -> ProjectLocationClusterCreateCall<'a, C> {
1154 ProjectLocationClusterCreateCall {
1155 hub: self.hub,
1156 _request: request,
1157 _parent: parent.to_string(),
1158 _request_id: Default::default(),
1159 _cluster_id: Default::default(),
1160 _delegate: Default::default(),
1161 _additional_params: Default::default(),
1162 _scopes: Default::default(),
1163 }
1164 }
1165
1166 /// Create a builder to help you perform the following task:
1167 ///
1168 /// Deletes a specific Redis cluster. Cluster stops serving and data is deleted.
1169 ///
1170 /// # Arguments
1171 ///
1172 /// * `name` - Required. Redis cluster resource name using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}` where `location_id` refers to a GCP region.
1173 pub fn locations_clusters_delete(&self, name: &str) -> ProjectLocationClusterDeleteCall<'a, C> {
1174 ProjectLocationClusterDeleteCall {
1175 hub: self.hub,
1176 _name: name.to_string(),
1177 _request_id: Default::default(),
1178 _delegate: Default::default(),
1179 _additional_params: Default::default(),
1180 _scopes: Default::default(),
1181 }
1182 }
1183
1184 /// Create a builder to help you perform the following task:
1185 ///
1186 /// Gets the details of a specific Redis cluster.
1187 ///
1188 /// # Arguments
1189 ///
1190 /// * `name` - Required. Redis cluster resource name using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}` where `location_id` refers to a GCP region.
1191 pub fn locations_clusters_get(&self, name: &str) -> ProjectLocationClusterGetCall<'a, C> {
1192 ProjectLocationClusterGetCall {
1193 hub: self.hub,
1194 _name: name.to_string(),
1195 _delegate: Default::default(),
1196 _additional_params: Default::default(),
1197 _scopes: Default::default(),
1198 }
1199 }
1200
1201 /// Create a builder to help you perform the following task:
1202 ///
1203 /// Gets the details of certificate authority information for Redis cluster.
1204 ///
1205 /// # Arguments
1206 ///
1207 /// * `name` - Required. Redis cluster certificate authority resource name using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}/certificateAuthority` where `location_id` refers to a GCP region.
1208 pub fn locations_clusters_get_certificate_authority(
1209 &self,
1210 name: &str,
1211 ) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C> {
1212 ProjectLocationClusterGetCertificateAuthorityCall {
1213 hub: self.hub,
1214 _name: name.to_string(),
1215 _delegate: Default::default(),
1216 _additional_params: Default::default(),
1217 _scopes: Default::default(),
1218 }
1219 }
1220
1221 /// Create a builder to help you perform the following task:
1222 ///
1223 /// Lists all Redis clusters owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
1224 ///
1225 /// # Arguments
1226 ///
1227 /// * `parent` - Required. The resource name of the cluster location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
1228 pub fn locations_clusters_list(&self, parent: &str) -> ProjectLocationClusterListCall<'a, C> {
1229 ProjectLocationClusterListCall {
1230 hub: self.hub,
1231 _parent: parent.to_string(),
1232 _page_token: Default::default(),
1233 _page_size: Default::default(),
1234 _delegate: Default::default(),
1235 _additional_params: Default::default(),
1236 _scopes: Default::default(),
1237 }
1238 }
1239
1240 /// Create a builder to help you perform the following task:
1241 ///
1242 /// Updates the metadata and configuration of a specific Redis cluster. Completed longrunning.Operation will contain the new cluster object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1243 ///
1244 /// # Arguments
1245 ///
1246 /// * `request` - No description provided.
1247 /// * `name` - Required. Identifier. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
1248 pub fn locations_clusters_patch(
1249 &self,
1250 request: Cluster,
1251 name: &str,
1252 ) -> ProjectLocationClusterPatchCall<'a, C> {
1253 ProjectLocationClusterPatchCall {
1254 hub: self.hub,
1255 _request: request,
1256 _name: name.to_string(),
1257 _update_mask: Default::default(),
1258 _request_id: Default::default(),
1259 _delegate: Default::default(),
1260 _additional_params: Default::default(),
1261 _scopes: Default::default(),
1262 }
1263 }
1264
1265 /// Create a builder to help you perform the following task:
1266 ///
1267 /// Creates a Redis instance based on the specified tier and memory size. By default, the instance is accessible from the project's [default network](https://cloud.google.com/vpc/docs/vpc). The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1268 ///
1269 /// # Arguments
1270 ///
1271 /// * `request` - No description provided.
1272 /// * `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.
1273 pub fn locations_instances_create(
1274 &self,
1275 request: Instance,
1276 parent: &str,
1277 ) -> ProjectLocationInstanceCreateCall<'a, C> {
1278 ProjectLocationInstanceCreateCall {
1279 hub: self.hub,
1280 _request: request,
1281 _parent: parent.to_string(),
1282 _instance_id: Default::default(),
1283 _delegate: Default::default(),
1284 _additional_params: Default::default(),
1285 _scopes: Default::default(),
1286 }
1287 }
1288
1289 /// Create a builder to help you perform the following task:
1290 ///
1291 /// Deletes a specific Redis instance. Instance stops serving and data is deleted.
1292 ///
1293 /// # Arguments
1294 ///
1295 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1296 pub fn locations_instances_delete(
1297 &self,
1298 name: &str,
1299 ) -> ProjectLocationInstanceDeleteCall<'a, C> {
1300 ProjectLocationInstanceDeleteCall {
1301 hub: self.hub,
1302 _name: name.to_string(),
1303 _delegate: Default::default(),
1304 _additional_params: Default::default(),
1305 _scopes: Default::default(),
1306 }
1307 }
1308
1309 /// Create a builder to help you perform the following task:
1310 ///
1311 /// Export Redis instance data into a Redis RDB format file in Cloud Storage. Redis will continue serving during this operation. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1312 ///
1313 /// # Arguments
1314 ///
1315 /// * `request` - No description provided.
1316 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1317 pub fn locations_instances_export(
1318 &self,
1319 request: ExportInstanceRequest,
1320 name: &str,
1321 ) -> ProjectLocationInstanceExportCall<'a, C> {
1322 ProjectLocationInstanceExportCall {
1323 hub: self.hub,
1324 _request: request,
1325 _name: name.to_string(),
1326 _delegate: Default::default(),
1327 _additional_params: Default::default(),
1328 _scopes: Default::default(),
1329 }
1330 }
1331
1332 /// Create a builder to help you perform the following task:
1333 ///
1334 /// Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud Memorystore for Redis instance.
1335 ///
1336 /// # Arguments
1337 ///
1338 /// * `request` - No description provided.
1339 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1340 pub fn locations_instances_failover(
1341 &self,
1342 request: FailoverInstanceRequest,
1343 name: &str,
1344 ) -> ProjectLocationInstanceFailoverCall<'a, C> {
1345 ProjectLocationInstanceFailoverCall {
1346 hub: self.hub,
1347 _request: request,
1348 _name: name.to_string(),
1349 _delegate: Default::default(),
1350 _additional_params: Default::default(),
1351 _scopes: Default::default(),
1352 }
1353 }
1354
1355 /// Create a builder to help you perform the following task:
1356 ///
1357 /// Gets the details of a specific Redis instance.
1358 ///
1359 /// # Arguments
1360 ///
1361 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1362 pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
1363 ProjectLocationInstanceGetCall {
1364 hub: self.hub,
1365 _name: name.to_string(),
1366 _delegate: Default::default(),
1367 _additional_params: Default::default(),
1368 _scopes: Default::default(),
1369 }
1370 }
1371
1372 /// Create a builder to help you perform the following task:
1373 ///
1374 /// Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. This information is not included in the details returned to GetInstance.
1375 ///
1376 /// # Arguments
1377 ///
1378 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1379 pub fn locations_instances_get_auth_string(
1380 &self,
1381 name: &str,
1382 ) -> ProjectLocationInstanceGetAuthStringCall<'a, C> {
1383 ProjectLocationInstanceGetAuthStringCall {
1384 hub: self.hub,
1385 _name: name.to_string(),
1386 _delegate: Default::default(),
1387 _additional_params: Default::default(),
1388 _scopes: Default::default(),
1389 }
1390 }
1391
1392 /// Create a builder to help you perform the following task:
1393 ///
1394 /// Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1395 ///
1396 /// # Arguments
1397 ///
1398 /// * `request` - No description provided.
1399 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1400 pub fn locations_instances_import(
1401 &self,
1402 request: ImportInstanceRequest,
1403 name: &str,
1404 ) -> ProjectLocationInstanceImportCall<'a, C> {
1405 ProjectLocationInstanceImportCall {
1406 hub: self.hub,
1407 _request: request,
1408 _name: name.to_string(),
1409 _delegate: Default::default(),
1410 _additional_params: Default::default(),
1411 _scopes: Default::default(),
1412 }
1413 }
1414
1415 /// Create a builder to help you perform the following task:
1416 ///
1417 /// Lists all Redis instances owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
1418 ///
1419 /// # Arguments
1420 ///
1421 /// * `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.
1422 pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
1423 ProjectLocationInstanceListCall {
1424 hub: self.hub,
1425 _parent: parent.to_string(),
1426 _page_token: Default::default(),
1427 _page_size: Default::default(),
1428 _delegate: Default::default(),
1429 _additional_params: Default::default(),
1430 _scopes: Default::default(),
1431 }
1432 }
1433
1434 /// Create a builder to help you perform the following task:
1435 ///
1436 /// Updates the metadata and configuration of a specific Redis instance. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1437 ///
1438 /// # Arguments
1439 ///
1440 /// * `request` - No description provided.
1441 /// * `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: Redis instances are managed and addressed at regional level so location_id here refers to a GCP region; however, users may choose which specific zone (or collection of zones for cross-zone instances) an instance should be provisioned in. Refer to location_id and alternative_location_id fields for more details.
1442 pub fn locations_instances_patch(
1443 &self,
1444 request: Instance,
1445 name: &str,
1446 ) -> ProjectLocationInstancePatchCall<'a, C> {
1447 ProjectLocationInstancePatchCall {
1448 hub: self.hub,
1449 _request: request,
1450 _name: name.to_string(),
1451 _update_mask: Default::default(),
1452 _delegate: Default::default(),
1453 _additional_params: Default::default(),
1454 _scopes: Default::default(),
1455 }
1456 }
1457
1458 /// Create a builder to help you perform the following task:
1459 ///
1460 /// Reschedule maintenance for a given instance in a given project and location.
1461 ///
1462 /// # Arguments
1463 ///
1464 /// * `request` - No description provided.
1465 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1466 pub fn locations_instances_reschedule_maintenance(
1467 &self,
1468 request: RescheduleMaintenanceRequest,
1469 name: &str,
1470 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
1471 ProjectLocationInstanceRescheduleMaintenanceCall {
1472 hub: self.hub,
1473 _request: request,
1474 _name: name.to_string(),
1475 _delegate: Default::default(),
1476 _additional_params: Default::default(),
1477 _scopes: Default::default(),
1478 }
1479 }
1480
1481 /// Create a builder to help you perform the following task:
1482 ///
1483 /// Upgrades Redis instance to the newer Redis version specified in the request.
1484 ///
1485 /// # Arguments
1486 ///
1487 /// * `request` - No description provided.
1488 /// * `name` - Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
1489 pub fn locations_instances_upgrade(
1490 &self,
1491 request: UpgradeInstanceRequest,
1492 name: &str,
1493 ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
1494 ProjectLocationInstanceUpgradeCall {
1495 hub: self.hub,
1496 _request: request,
1497 _name: name.to_string(),
1498 _delegate: Default::default(),
1499 _additional_params: Default::default(),
1500 _scopes: Default::default(),
1501 }
1502 }
1503
1504 /// Create a builder to help you perform the following task:
1505 ///
1506 /// 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`.
1507 ///
1508 /// # Arguments
1509 ///
1510 /// * `name` - The name of the operation resource to be cancelled.
1511 pub fn locations_operations_cancel(
1512 &self,
1513 name: &str,
1514 ) -> ProjectLocationOperationCancelCall<'a, C> {
1515 ProjectLocationOperationCancelCall {
1516 hub: self.hub,
1517 _name: name.to_string(),
1518 _delegate: Default::default(),
1519 _additional_params: Default::default(),
1520 _scopes: Default::default(),
1521 }
1522 }
1523
1524 /// Create a builder to help you perform the following task:
1525 ///
1526 /// 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`.
1527 ///
1528 /// # Arguments
1529 ///
1530 /// * `name` - The name of the operation resource to be deleted.
1531 pub fn locations_operations_delete(
1532 &self,
1533 name: &str,
1534 ) -> ProjectLocationOperationDeleteCall<'a, C> {
1535 ProjectLocationOperationDeleteCall {
1536 hub: self.hub,
1537 _name: name.to_string(),
1538 _delegate: Default::default(),
1539 _additional_params: Default::default(),
1540 _scopes: Default::default(),
1541 }
1542 }
1543
1544 /// Create a builder to help you perform the following task:
1545 ///
1546 /// 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.
1547 ///
1548 /// # Arguments
1549 ///
1550 /// * `name` - The name of the operation resource.
1551 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
1552 ProjectLocationOperationGetCall {
1553 hub: self.hub,
1554 _name: name.to_string(),
1555 _delegate: Default::default(),
1556 _additional_params: Default::default(),
1557 _scopes: Default::default(),
1558 }
1559 }
1560
1561 /// Create a builder to help you perform the following task:
1562 ///
1563 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1564 ///
1565 /// # Arguments
1566 ///
1567 /// * `name` - The name of the operation's parent resource.
1568 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
1569 ProjectLocationOperationListCall {
1570 hub: self.hub,
1571 _name: name.to_string(),
1572 _page_token: Default::default(),
1573 _page_size: Default::default(),
1574 _filter: Default::default(),
1575 _delegate: Default::default(),
1576 _additional_params: Default::default(),
1577 _scopes: Default::default(),
1578 }
1579 }
1580
1581 /// Create a builder to help you perform the following task:
1582 ///
1583 /// Gets information about a location.
1584 ///
1585 /// # Arguments
1586 ///
1587 /// * `name` - Resource name for the location.
1588 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1589 ProjectLocationGetCall {
1590 hub: self.hub,
1591 _name: name.to_string(),
1592 _delegate: Default::default(),
1593 _additional_params: Default::default(),
1594 _scopes: Default::default(),
1595 }
1596 }
1597
1598 /// Create a builder to help you perform the following task:
1599 ///
1600 /// Lists information about the supported locations for this service.
1601 ///
1602 /// # Arguments
1603 ///
1604 /// * `name` - The resource that owns the locations collection, if applicable.
1605 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1606 ProjectLocationListCall {
1607 hub: self.hub,
1608 _name: name.to_string(),
1609 _page_token: Default::default(),
1610 _page_size: Default::default(),
1611 _filter: Default::default(),
1612 _delegate: Default::default(),
1613 _additional_params: Default::default(),
1614 _scopes: Default::default(),
1615 }
1616 }
1617}
1618
1619// ###################
1620// CallBuilders ###
1621// #################
1622
1623/// Creates a Redis cluster based on the specified properties. The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis cluster will be fully functional. The completed longrunning.Operation will contain the new cluster object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
1624///
1625/// A builder for the *locations.clusters.create* method supported by a *project* resource.
1626/// It is not used directly, but through a [`ProjectMethods`] instance.
1627///
1628/// # Example
1629///
1630/// Instantiate a resource method builder
1631///
1632/// ```test_harness,no_run
1633/// # extern crate hyper;
1634/// # extern crate hyper_rustls;
1635/// # extern crate google_redis1 as redis1;
1636/// use redis1::api::Cluster;
1637/// # async fn dox() {
1638/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1639///
1640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1641/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1642/// # secret,
1643/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1644/// # ).build().await.unwrap();
1645///
1646/// # let client = hyper_util::client::legacy::Client::builder(
1647/// # hyper_util::rt::TokioExecutor::new()
1648/// # )
1649/// # .build(
1650/// # hyper_rustls::HttpsConnectorBuilder::new()
1651/// # .with_native_roots()
1652/// # .unwrap()
1653/// # .https_or_http()
1654/// # .enable_http1()
1655/// # .build()
1656/// # );
1657/// # let mut hub = CloudRedis::new(client, auth);
1658/// // As the method needs a request, you would usually fill it with the desired information
1659/// // into the respective structure. Some of the parts shown here might not be applicable !
1660/// // Values shown here are possibly random and not representative !
1661/// let mut req = Cluster::default();
1662///
1663/// // You can configure optional parameters by calling the respective setters at will, and
1664/// // execute the final call using `doit()`.
1665/// // Values shown here are possibly random and not representative !
1666/// let result = hub.projects().locations_clusters_create(req, "parent")
1667/// .request_id("amet.")
1668/// .cluster_id("duo")
1669/// .doit().await;
1670/// # }
1671/// ```
1672pub struct ProjectLocationClusterCreateCall<'a, C>
1673where
1674 C: 'a,
1675{
1676 hub: &'a CloudRedis<C>,
1677 _request: Cluster,
1678 _parent: String,
1679 _request_id: Option<String>,
1680 _cluster_id: Option<String>,
1681 _delegate: Option<&'a mut dyn common::Delegate>,
1682 _additional_params: HashMap<String, String>,
1683 _scopes: BTreeSet<String>,
1684}
1685
1686impl<'a, C> common::CallBuilder for ProjectLocationClusterCreateCall<'a, C> {}
1687
1688impl<'a, C> ProjectLocationClusterCreateCall<'a, C>
1689where
1690 C: common::Connector,
1691{
1692 /// Perform the operation you have build so far.
1693 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1694 use std::borrow::Cow;
1695 use std::io::{Read, Seek};
1696
1697 use common::{url::Params, ToParts};
1698 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1699
1700 let mut dd = common::DefaultDelegate;
1701 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1702 dlg.begin(common::MethodInfo {
1703 id: "redis.projects.locations.clusters.create",
1704 http_method: hyper::Method::POST,
1705 });
1706
1707 for &field in ["alt", "parent", "requestId", "clusterId"].iter() {
1708 if self._additional_params.contains_key(field) {
1709 dlg.finished(false);
1710 return Err(common::Error::FieldClash(field));
1711 }
1712 }
1713
1714 let mut params = Params::with_capacity(6 + self._additional_params.len());
1715 params.push("parent", self._parent);
1716 if let Some(value) = self._request_id.as_ref() {
1717 params.push("requestId", value);
1718 }
1719 if let Some(value) = self._cluster_id.as_ref() {
1720 params.push("clusterId", value);
1721 }
1722
1723 params.extend(self._additional_params.iter());
1724
1725 params.push("alt", "json");
1726 let mut url = self.hub._base_url.clone() + "v1/{+parent}/clusters";
1727 if self._scopes.is_empty() {
1728 self._scopes
1729 .insert(Scope::CloudPlatform.as_ref().to_string());
1730 }
1731
1732 #[allow(clippy::single_element_loop)]
1733 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1734 url = params.uri_replacement(url, param_name, find_this, true);
1735 }
1736 {
1737 let to_remove = ["parent"];
1738 params.remove_params(&to_remove);
1739 }
1740
1741 let url = params.parse_with_url(&url);
1742
1743 let mut json_mime_type = mime::APPLICATION_JSON;
1744 let mut request_value_reader = {
1745 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1746 common::remove_json_null_values(&mut value);
1747 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1748 serde_json::to_writer(&mut dst, &value).unwrap();
1749 dst
1750 };
1751 let request_size = request_value_reader
1752 .seek(std::io::SeekFrom::End(0))
1753 .unwrap();
1754 request_value_reader
1755 .seek(std::io::SeekFrom::Start(0))
1756 .unwrap();
1757
1758 loop {
1759 let token = match self
1760 .hub
1761 .auth
1762 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1763 .await
1764 {
1765 Ok(token) => token,
1766 Err(e) => match dlg.token(e) {
1767 Ok(token) => token,
1768 Err(e) => {
1769 dlg.finished(false);
1770 return Err(common::Error::MissingToken(e));
1771 }
1772 },
1773 };
1774 request_value_reader
1775 .seek(std::io::SeekFrom::Start(0))
1776 .unwrap();
1777 let mut req_result = {
1778 let client = &self.hub.client;
1779 dlg.pre_request();
1780 let mut req_builder = hyper::Request::builder()
1781 .method(hyper::Method::POST)
1782 .uri(url.as_str())
1783 .header(USER_AGENT, self.hub._user_agent.clone());
1784
1785 if let Some(token) = token.as_ref() {
1786 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1787 }
1788
1789 let request = req_builder
1790 .header(CONTENT_TYPE, json_mime_type.to_string())
1791 .header(CONTENT_LENGTH, request_size as u64)
1792 .body(common::to_body(
1793 request_value_reader.get_ref().clone().into(),
1794 ));
1795
1796 client.request(request.unwrap()).await
1797 };
1798
1799 match req_result {
1800 Err(err) => {
1801 if let common::Retry::After(d) = dlg.http_error(&err) {
1802 sleep(d).await;
1803 continue;
1804 }
1805 dlg.finished(false);
1806 return Err(common::Error::HttpError(err));
1807 }
1808 Ok(res) => {
1809 let (mut parts, body) = res.into_parts();
1810 let mut body = common::Body::new(body);
1811 if !parts.status.is_success() {
1812 let bytes = common::to_bytes(body).await.unwrap_or_default();
1813 let error = serde_json::from_str(&common::to_string(&bytes));
1814 let response = common::to_response(parts, bytes.into());
1815
1816 if let common::Retry::After(d) =
1817 dlg.http_failure(&response, error.as_ref().ok())
1818 {
1819 sleep(d).await;
1820 continue;
1821 }
1822
1823 dlg.finished(false);
1824
1825 return Err(match error {
1826 Ok(value) => common::Error::BadRequest(value),
1827 _ => common::Error::Failure(response),
1828 });
1829 }
1830 let response = {
1831 let bytes = common::to_bytes(body).await.unwrap_or_default();
1832 let encoded = common::to_string(&bytes);
1833 match serde_json::from_str(&encoded) {
1834 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1835 Err(error) => {
1836 dlg.response_json_decode_error(&encoded, &error);
1837 return Err(common::Error::JsonDecodeError(
1838 encoded.to_string(),
1839 error,
1840 ));
1841 }
1842 }
1843 };
1844
1845 dlg.finished(true);
1846 return Ok(response);
1847 }
1848 }
1849 }
1850 }
1851
1852 ///
1853 /// Sets the *request* property to the given value.
1854 ///
1855 /// Even though the property as already been set when instantiating this call,
1856 /// we provide this method for API completeness.
1857 pub fn request(mut self, new_value: Cluster) -> ProjectLocationClusterCreateCall<'a, C> {
1858 self._request = new_value;
1859 self
1860 }
1861 /// Required. The resource name of the cluster location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
1862 ///
1863 /// Sets the *parent* path property to the given value.
1864 ///
1865 /// Even though the property as already been set when instantiating this call,
1866 /// we provide this method for API completeness.
1867 pub fn parent(mut self, new_value: &str) -> ProjectLocationClusterCreateCall<'a, C> {
1868 self._parent = new_value.to_string();
1869 self
1870 }
1871 /// Idempotent request UUID.
1872 ///
1873 /// Sets the *request id* query property to the given value.
1874 pub fn request_id(mut self, new_value: &str) -> ProjectLocationClusterCreateCall<'a, C> {
1875 self._request_id = Some(new_value.to_string());
1876 self
1877 }
1878 /// Required. The logical name of the Redis cluster in the customer project with the following restrictions: * Must contain only lowercase letters, numbers, and hyphens. * Must start with a letter. * Must be between 1-63 characters. * Must end with a number or a letter. * Must be unique within the customer project / location
1879 ///
1880 /// Sets the *cluster id* query property to the given value.
1881 pub fn cluster_id(mut self, new_value: &str) -> ProjectLocationClusterCreateCall<'a, C> {
1882 self._cluster_id = Some(new_value.to_string());
1883 self
1884 }
1885 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1886 /// while executing the actual API request.
1887 ///
1888 /// ````text
1889 /// It should be used to handle progress information, and to implement a certain level of resilience.
1890 /// ````
1891 ///
1892 /// Sets the *delegate* property to the given value.
1893 pub fn delegate(
1894 mut self,
1895 new_value: &'a mut dyn common::Delegate,
1896 ) -> ProjectLocationClusterCreateCall<'a, C> {
1897 self._delegate = Some(new_value);
1898 self
1899 }
1900
1901 /// Set any additional parameter of the query string used in the request.
1902 /// It should be used to set parameters which are not yet available through their own
1903 /// setters.
1904 ///
1905 /// Please note that this method must not be used to set any of the known parameters
1906 /// which have their own setter method. If done anyway, the request will fail.
1907 ///
1908 /// # Additional Parameters
1909 ///
1910 /// * *$.xgafv* (query-string) - V1 error format.
1911 /// * *access_token* (query-string) - OAuth access token.
1912 /// * *alt* (query-string) - Data format for response.
1913 /// * *callback* (query-string) - JSONP
1914 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1915 /// * *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.
1916 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1917 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1918 /// * *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.
1919 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1920 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1921 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClusterCreateCall<'a, C>
1922 where
1923 T: AsRef<str>,
1924 {
1925 self._additional_params
1926 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1927 self
1928 }
1929
1930 /// Identifies the authorization scope for the method you are building.
1931 ///
1932 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1933 /// [`Scope::CloudPlatform`].
1934 ///
1935 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1936 /// tokens for more than one scope.
1937 ///
1938 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1939 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1940 /// sufficient, a read-write scope will do as well.
1941 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClusterCreateCall<'a, C>
1942 where
1943 St: AsRef<str>,
1944 {
1945 self._scopes.insert(String::from(scope.as_ref()));
1946 self
1947 }
1948 /// Identifies the authorization scope(s) for the method you are building.
1949 ///
1950 /// See [`Self::add_scope()`] for details.
1951 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClusterCreateCall<'a, C>
1952 where
1953 I: IntoIterator<Item = St>,
1954 St: AsRef<str>,
1955 {
1956 self._scopes
1957 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1958 self
1959 }
1960
1961 /// Removes all scopes, and no default scope will be used either.
1962 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1963 /// for details).
1964 pub fn clear_scopes(mut self) -> ProjectLocationClusterCreateCall<'a, C> {
1965 self._scopes.clear();
1966 self
1967 }
1968}
1969
1970/// Deletes a specific Redis cluster. Cluster stops serving and data is deleted.
1971///
1972/// A builder for the *locations.clusters.delete* method supported by a *project* resource.
1973/// It is not used directly, but through a [`ProjectMethods`] instance.
1974///
1975/// # Example
1976///
1977/// Instantiate a resource method builder
1978///
1979/// ```test_harness,no_run
1980/// # extern crate hyper;
1981/// # extern crate hyper_rustls;
1982/// # extern crate google_redis1 as redis1;
1983/// # async fn dox() {
1984/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1985///
1986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1988/// # secret,
1989/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1990/// # ).build().await.unwrap();
1991///
1992/// # let client = hyper_util::client::legacy::Client::builder(
1993/// # hyper_util::rt::TokioExecutor::new()
1994/// # )
1995/// # .build(
1996/// # hyper_rustls::HttpsConnectorBuilder::new()
1997/// # .with_native_roots()
1998/// # .unwrap()
1999/// # .https_or_http()
2000/// # .enable_http1()
2001/// # .build()
2002/// # );
2003/// # let mut hub = CloudRedis::new(client, auth);
2004/// // You can configure optional parameters by calling the respective setters at will, and
2005/// // execute the final call using `doit()`.
2006/// // Values shown here are possibly random and not representative !
2007/// let result = hub.projects().locations_clusters_delete("name")
2008/// .request_id("gubergren")
2009/// .doit().await;
2010/// # }
2011/// ```
2012pub struct ProjectLocationClusterDeleteCall<'a, C>
2013where
2014 C: 'a,
2015{
2016 hub: &'a CloudRedis<C>,
2017 _name: String,
2018 _request_id: Option<String>,
2019 _delegate: Option<&'a mut dyn common::Delegate>,
2020 _additional_params: HashMap<String, String>,
2021 _scopes: BTreeSet<String>,
2022}
2023
2024impl<'a, C> common::CallBuilder for ProjectLocationClusterDeleteCall<'a, C> {}
2025
2026impl<'a, C> ProjectLocationClusterDeleteCall<'a, C>
2027where
2028 C: common::Connector,
2029{
2030 /// Perform the operation you have build so far.
2031 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2032 use std::borrow::Cow;
2033 use std::io::{Read, Seek};
2034
2035 use common::{url::Params, ToParts};
2036 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2037
2038 let mut dd = common::DefaultDelegate;
2039 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2040 dlg.begin(common::MethodInfo {
2041 id: "redis.projects.locations.clusters.delete",
2042 http_method: hyper::Method::DELETE,
2043 });
2044
2045 for &field in ["alt", "name", "requestId"].iter() {
2046 if self._additional_params.contains_key(field) {
2047 dlg.finished(false);
2048 return Err(common::Error::FieldClash(field));
2049 }
2050 }
2051
2052 let mut params = Params::with_capacity(4 + self._additional_params.len());
2053 params.push("name", self._name);
2054 if let Some(value) = self._request_id.as_ref() {
2055 params.push("requestId", value);
2056 }
2057
2058 params.extend(self._additional_params.iter());
2059
2060 params.push("alt", "json");
2061 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2062 if self._scopes.is_empty() {
2063 self._scopes
2064 .insert(Scope::CloudPlatform.as_ref().to_string());
2065 }
2066
2067 #[allow(clippy::single_element_loop)]
2068 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2069 url = params.uri_replacement(url, param_name, find_this, true);
2070 }
2071 {
2072 let to_remove = ["name"];
2073 params.remove_params(&to_remove);
2074 }
2075
2076 let url = params.parse_with_url(&url);
2077
2078 loop {
2079 let token = match self
2080 .hub
2081 .auth
2082 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2083 .await
2084 {
2085 Ok(token) => token,
2086 Err(e) => match dlg.token(e) {
2087 Ok(token) => token,
2088 Err(e) => {
2089 dlg.finished(false);
2090 return Err(common::Error::MissingToken(e));
2091 }
2092 },
2093 };
2094 let mut req_result = {
2095 let client = &self.hub.client;
2096 dlg.pre_request();
2097 let mut req_builder = hyper::Request::builder()
2098 .method(hyper::Method::DELETE)
2099 .uri(url.as_str())
2100 .header(USER_AGENT, self.hub._user_agent.clone());
2101
2102 if let Some(token) = token.as_ref() {
2103 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2104 }
2105
2106 let request = req_builder
2107 .header(CONTENT_LENGTH, 0_u64)
2108 .body(common::to_body::<String>(None));
2109
2110 client.request(request.unwrap()).await
2111 };
2112
2113 match req_result {
2114 Err(err) => {
2115 if let common::Retry::After(d) = dlg.http_error(&err) {
2116 sleep(d).await;
2117 continue;
2118 }
2119 dlg.finished(false);
2120 return Err(common::Error::HttpError(err));
2121 }
2122 Ok(res) => {
2123 let (mut parts, body) = res.into_parts();
2124 let mut body = common::Body::new(body);
2125 if !parts.status.is_success() {
2126 let bytes = common::to_bytes(body).await.unwrap_or_default();
2127 let error = serde_json::from_str(&common::to_string(&bytes));
2128 let response = common::to_response(parts, bytes.into());
2129
2130 if let common::Retry::After(d) =
2131 dlg.http_failure(&response, error.as_ref().ok())
2132 {
2133 sleep(d).await;
2134 continue;
2135 }
2136
2137 dlg.finished(false);
2138
2139 return Err(match error {
2140 Ok(value) => common::Error::BadRequest(value),
2141 _ => common::Error::Failure(response),
2142 });
2143 }
2144 let response = {
2145 let bytes = common::to_bytes(body).await.unwrap_or_default();
2146 let encoded = common::to_string(&bytes);
2147 match serde_json::from_str(&encoded) {
2148 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2149 Err(error) => {
2150 dlg.response_json_decode_error(&encoded, &error);
2151 return Err(common::Error::JsonDecodeError(
2152 encoded.to_string(),
2153 error,
2154 ));
2155 }
2156 }
2157 };
2158
2159 dlg.finished(true);
2160 return Ok(response);
2161 }
2162 }
2163 }
2164 }
2165
2166 /// Required. Redis cluster resource name using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}` where `location_id` refers to a GCP region.
2167 ///
2168 /// Sets the *name* path property to the given value.
2169 ///
2170 /// Even though the property as already been set when instantiating this call,
2171 /// we provide this method for API completeness.
2172 pub fn name(mut self, new_value: &str) -> ProjectLocationClusterDeleteCall<'a, C> {
2173 self._name = new_value.to_string();
2174 self
2175 }
2176 /// Idempotent request UUID.
2177 ///
2178 /// Sets the *request id* query property to the given value.
2179 pub fn request_id(mut self, new_value: &str) -> ProjectLocationClusterDeleteCall<'a, C> {
2180 self._request_id = Some(new_value.to_string());
2181 self
2182 }
2183 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2184 /// while executing the actual API request.
2185 ///
2186 /// ````text
2187 /// It should be used to handle progress information, and to implement a certain level of resilience.
2188 /// ````
2189 ///
2190 /// Sets the *delegate* property to the given value.
2191 pub fn delegate(
2192 mut self,
2193 new_value: &'a mut dyn common::Delegate,
2194 ) -> ProjectLocationClusterDeleteCall<'a, C> {
2195 self._delegate = Some(new_value);
2196 self
2197 }
2198
2199 /// Set any additional parameter of the query string used in the request.
2200 /// It should be used to set parameters which are not yet available through their own
2201 /// setters.
2202 ///
2203 /// Please note that this method must not be used to set any of the known parameters
2204 /// which have their own setter method. If done anyway, the request will fail.
2205 ///
2206 /// # Additional Parameters
2207 ///
2208 /// * *$.xgafv* (query-string) - V1 error format.
2209 /// * *access_token* (query-string) - OAuth access token.
2210 /// * *alt* (query-string) - Data format for response.
2211 /// * *callback* (query-string) - JSONP
2212 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2213 /// * *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.
2214 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2215 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2216 /// * *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.
2217 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2218 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2219 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClusterDeleteCall<'a, C>
2220 where
2221 T: AsRef<str>,
2222 {
2223 self._additional_params
2224 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2225 self
2226 }
2227
2228 /// Identifies the authorization scope for the method you are building.
2229 ///
2230 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2231 /// [`Scope::CloudPlatform`].
2232 ///
2233 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2234 /// tokens for more than one scope.
2235 ///
2236 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2237 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2238 /// sufficient, a read-write scope will do as well.
2239 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClusterDeleteCall<'a, C>
2240 where
2241 St: AsRef<str>,
2242 {
2243 self._scopes.insert(String::from(scope.as_ref()));
2244 self
2245 }
2246 /// Identifies the authorization scope(s) for the method you are building.
2247 ///
2248 /// See [`Self::add_scope()`] for details.
2249 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClusterDeleteCall<'a, C>
2250 where
2251 I: IntoIterator<Item = St>,
2252 St: AsRef<str>,
2253 {
2254 self._scopes
2255 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2256 self
2257 }
2258
2259 /// Removes all scopes, and no default scope will be used either.
2260 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2261 /// for details).
2262 pub fn clear_scopes(mut self) -> ProjectLocationClusterDeleteCall<'a, C> {
2263 self._scopes.clear();
2264 self
2265 }
2266}
2267
2268/// Gets the details of a specific Redis cluster.
2269///
2270/// A builder for the *locations.clusters.get* method supported by a *project* resource.
2271/// It is not used directly, but through a [`ProjectMethods`] instance.
2272///
2273/// # Example
2274///
2275/// Instantiate a resource method builder
2276///
2277/// ```test_harness,no_run
2278/// # extern crate hyper;
2279/// # extern crate hyper_rustls;
2280/// # extern crate google_redis1 as redis1;
2281/// # async fn dox() {
2282/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2283///
2284/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2285/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2286/// # secret,
2287/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2288/// # ).build().await.unwrap();
2289///
2290/// # let client = hyper_util::client::legacy::Client::builder(
2291/// # hyper_util::rt::TokioExecutor::new()
2292/// # )
2293/// # .build(
2294/// # hyper_rustls::HttpsConnectorBuilder::new()
2295/// # .with_native_roots()
2296/// # .unwrap()
2297/// # .https_or_http()
2298/// # .enable_http1()
2299/// # .build()
2300/// # );
2301/// # let mut hub = CloudRedis::new(client, auth);
2302/// // You can configure optional parameters by calling the respective setters at will, and
2303/// // execute the final call using `doit()`.
2304/// // Values shown here are possibly random and not representative !
2305/// let result = hub.projects().locations_clusters_get("name")
2306/// .doit().await;
2307/// # }
2308/// ```
2309pub struct ProjectLocationClusterGetCall<'a, C>
2310where
2311 C: 'a,
2312{
2313 hub: &'a CloudRedis<C>,
2314 _name: String,
2315 _delegate: Option<&'a mut dyn common::Delegate>,
2316 _additional_params: HashMap<String, String>,
2317 _scopes: BTreeSet<String>,
2318}
2319
2320impl<'a, C> common::CallBuilder for ProjectLocationClusterGetCall<'a, C> {}
2321
2322impl<'a, C> ProjectLocationClusterGetCall<'a, C>
2323where
2324 C: common::Connector,
2325{
2326 /// Perform the operation you have build so far.
2327 pub async fn doit(mut self) -> common::Result<(common::Response, Cluster)> {
2328 use std::borrow::Cow;
2329 use std::io::{Read, Seek};
2330
2331 use common::{url::Params, ToParts};
2332 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2333
2334 let mut dd = common::DefaultDelegate;
2335 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2336 dlg.begin(common::MethodInfo {
2337 id: "redis.projects.locations.clusters.get",
2338 http_method: hyper::Method::GET,
2339 });
2340
2341 for &field in ["alt", "name"].iter() {
2342 if self._additional_params.contains_key(field) {
2343 dlg.finished(false);
2344 return Err(common::Error::FieldClash(field));
2345 }
2346 }
2347
2348 let mut params = Params::with_capacity(3 + self._additional_params.len());
2349 params.push("name", self._name);
2350
2351 params.extend(self._additional_params.iter());
2352
2353 params.push("alt", "json");
2354 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2355 if self._scopes.is_empty() {
2356 self._scopes
2357 .insert(Scope::CloudPlatform.as_ref().to_string());
2358 }
2359
2360 #[allow(clippy::single_element_loop)]
2361 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2362 url = params.uri_replacement(url, param_name, find_this, true);
2363 }
2364 {
2365 let to_remove = ["name"];
2366 params.remove_params(&to_remove);
2367 }
2368
2369 let url = params.parse_with_url(&url);
2370
2371 loop {
2372 let token = match self
2373 .hub
2374 .auth
2375 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2376 .await
2377 {
2378 Ok(token) => token,
2379 Err(e) => match dlg.token(e) {
2380 Ok(token) => token,
2381 Err(e) => {
2382 dlg.finished(false);
2383 return Err(common::Error::MissingToken(e));
2384 }
2385 },
2386 };
2387 let mut req_result = {
2388 let client = &self.hub.client;
2389 dlg.pre_request();
2390 let mut req_builder = hyper::Request::builder()
2391 .method(hyper::Method::GET)
2392 .uri(url.as_str())
2393 .header(USER_AGENT, self.hub._user_agent.clone());
2394
2395 if let Some(token) = token.as_ref() {
2396 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2397 }
2398
2399 let request = req_builder
2400 .header(CONTENT_LENGTH, 0_u64)
2401 .body(common::to_body::<String>(None));
2402
2403 client.request(request.unwrap()).await
2404 };
2405
2406 match req_result {
2407 Err(err) => {
2408 if let common::Retry::After(d) = dlg.http_error(&err) {
2409 sleep(d).await;
2410 continue;
2411 }
2412 dlg.finished(false);
2413 return Err(common::Error::HttpError(err));
2414 }
2415 Ok(res) => {
2416 let (mut parts, body) = res.into_parts();
2417 let mut body = common::Body::new(body);
2418 if !parts.status.is_success() {
2419 let bytes = common::to_bytes(body).await.unwrap_or_default();
2420 let error = serde_json::from_str(&common::to_string(&bytes));
2421 let response = common::to_response(parts, bytes.into());
2422
2423 if let common::Retry::After(d) =
2424 dlg.http_failure(&response, error.as_ref().ok())
2425 {
2426 sleep(d).await;
2427 continue;
2428 }
2429
2430 dlg.finished(false);
2431
2432 return Err(match error {
2433 Ok(value) => common::Error::BadRequest(value),
2434 _ => common::Error::Failure(response),
2435 });
2436 }
2437 let response = {
2438 let bytes = common::to_bytes(body).await.unwrap_or_default();
2439 let encoded = common::to_string(&bytes);
2440 match serde_json::from_str(&encoded) {
2441 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2442 Err(error) => {
2443 dlg.response_json_decode_error(&encoded, &error);
2444 return Err(common::Error::JsonDecodeError(
2445 encoded.to_string(),
2446 error,
2447 ));
2448 }
2449 }
2450 };
2451
2452 dlg.finished(true);
2453 return Ok(response);
2454 }
2455 }
2456 }
2457 }
2458
2459 /// Required. Redis cluster resource name using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}` where `location_id` refers to a GCP region.
2460 ///
2461 /// Sets the *name* path property to the given value.
2462 ///
2463 /// Even though the property as already been set when instantiating this call,
2464 /// we provide this method for API completeness.
2465 pub fn name(mut self, new_value: &str) -> ProjectLocationClusterGetCall<'a, C> {
2466 self._name = new_value.to_string();
2467 self
2468 }
2469 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2470 /// while executing the actual API request.
2471 ///
2472 /// ````text
2473 /// It should be used to handle progress information, and to implement a certain level of resilience.
2474 /// ````
2475 ///
2476 /// Sets the *delegate* property to the given value.
2477 pub fn delegate(
2478 mut self,
2479 new_value: &'a mut dyn common::Delegate,
2480 ) -> ProjectLocationClusterGetCall<'a, C> {
2481 self._delegate = Some(new_value);
2482 self
2483 }
2484
2485 /// Set any additional parameter of the query string used in the request.
2486 /// It should be used to set parameters which are not yet available through their own
2487 /// setters.
2488 ///
2489 /// Please note that this method must not be used to set any of the known parameters
2490 /// which have their own setter method. If done anyway, the request will fail.
2491 ///
2492 /// # Additional Parameters
2493 ///
2494 /// * *$.xgafv* (query-string) - V1 error format.
2495 /// * *access_token* (query-string) - OAuth access token.
2496 /// * *alt* (query-string) - Data format for response.
2497 /// * *callback* (query-string) - JSONP
2498 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2499 /// * *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.
2500 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2501 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2502 /// * *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.
2503 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2504 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2505 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClusterGetCall<'a, C>
2506 where
2507 T: AsRef<str>,
2508 {
2509 self._additional_params
2510 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2511 self
2512 }
2513
2514 /// Identifies the authorization scope for the method you are building.
2515 ///
2516 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2517 /// [`Scope::CloudPlatform`].
2518 ///
2519 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2520 /// tokens for more than one scope.
2521 ///
2522 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2523 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2524 /// sufficient, a read-write scope will do as well.
2525 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClusterGetCall<'a, C>
2526 where
2527 St: AsRef<str>,
2528 {
2529 self._scopes.insert(String::from(scope.as_ref()));
2530 self
2531 }
2532 /// Identifies the authorization scope(s) for the method you are building.
2533 ///
2534 /// See [`Self::add_scope()`] for details.
2535 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClusterGetCall<'a, C>
2536 where
2537 I: IntoIterator<Item = St>,
2538 St: AsRef<str>,
2539 {
2540 self._scopes
2541 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2542 self
2543 }
2544
2545 /// Removes all scopes, and no default scope will be used either.
2546 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2547 /// for details).
2548 pub fn clear_scopes(mut self) -> ProjectLocationClusterGetCall<'a, C> {
2549 self._scopes.clear();
2550 self
2551 }
2552}
2553
2554/// Gets the details of certificate authority information for Redis cluster.
2555///
2556/// A builder for the *locations.clusters.getCertificateAuthority* method supported by a *project* resource.
2557/// It is not used directly, but through a [`ProjectMethods`] instance.
2558///
2559/// # Example
2560///
2561/// Instantiate a resource method builder
2562///
2563/// ```test_harness,no_run
2564/// # extern crate hyper;
2565/// # extern crate hyper_rustls;
2566/// # extern crate google_redis1 as redis1;
2567/// # async fn dox() {
2568/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2569///
2570/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2571/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2572/// # secret,
2573/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2574/// # ).build().await.unwrap();
2575///
2576/// # let client = hyper_util::client::legacy::Client::builder(
2577/// # hyper_util::rt::TokioExecutor::new()
2578/// # )
2579/// # .build(
2580/// # hyper_rustls::HttpsConnectorBuilder::new()
2581/// # .with_native_roots()
2582/// # .unwrap()
2583/// # .https_or_http()
2584/// # .enable_http1()
2585/// # .build()
2586/// # );
2587/// # let mut hub = CloudRedis::new(client, auth);
2588/// // You can configure optional parameters by calling the respective setters at will, and
2589/// // execute the final call using `doit()`.
2590/// // Values shown here are possibly random and not representative !
2591/// let result = hub.projects().locations_clusters_get_certificate_authority("name")
2592/// .doit().await;
2593/// # }
2594/// ```
2595pub struct ProjectLocationClusterGetCertificateAuthorityCall<'a, C>
2596where
2597 C: 'a,
2598{
2599 hub: &'a CloudRedis<C>,
2600 _name: String,
2601 _delegate: Option<&'a mut dyn common::Delegate>,
2602 _additional_params: HashMap<String, String>,
2603 _scopes: BTreeSet<String>,
2604}
2605
2606impl<'a, C> common::CallBuilder for ProjectLocationClusterGetCertificateAuthorityCall<'a, C> {}
2607
2608impl<'a, C> ProjectLocationClusterGetCertificateAuthorityCall<'a, C>
2609where
2610 C: common::Connector,
2611{
2612 /// Perform the operation you have build so far.
2613 pub async fn doit(mut self) -> common::Result<(common::Response, CertificateAuthority)> {
2614 use std::borrow::Cow;
2615 use std::io::{Read, Seek};
2616
2617 use common::{url::Params, ToParts};
2618 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2619
2620 let mut dd = common::DefaultDelegate;
2621 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2622 dlg.begin(common::MethodInfo {
2623 id: "redis.projects.locations.clusters.getCertificateAuthority",
2624 http_method: hyper::Method::GET,
2625 });
2626
2627 for &field in ["alt", "name"].iter() {
2628 if self._additional_params.contains_key(field) {
2629 dlg.finished(false);
2630 return Err(common::Error::FieldClash(field));
2631 }
2632 }
2633
2634 let mut params = Params::with_capacity(3 + self._additional_params.len());
2635 params.push("name", self._name);
2636
2637 params.extend(self._additional_params.iter());
2638
2639 params.push("alt", "json");
2640 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2641 if self._scopes.is_empty() {
2642 self._scopes
2643 .insert(Scope::CloudPlatform.as_ref().to_string());
2644 }
2645
2646 #[allow(clippy::single_element_loop)]
2647 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2648 url = params.uri_replacement(url, param_name, find_this, true);
2649 }
2650 {
2651 let to_remove = ["name"];
2652 params.remove_params(&to_remove);
2653 }
2654
2655 let url = params.parse_with_url(&url);
2656
2657 loop {
2658 let token = match self
2659 .hub
2660 .auth
2661 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2662 .await
2663 {
2664 Ok(token) => token,
2665 Err(e) => match dlg.token(e) {
2666 Ok(token) => token,
2667 Err(e) => {
2668 dlg.finished(false);
2669 return Err(common::Error::MissingToken(e));
2670 }
2671 },
2672 };
2673 let mut req_result = {
2674 let client = &self.hub.client;
2675 dlg.pre_request();
2676 let mut req_builder = hyper::Request::builder()
2677 .method(hyper::Method::GET)
2678 .uri(url.as_str())
2679 .header(USER_AGENT, self.hub._user_agent.clone());
2680
2681 if let Some(token) = token.as_ref() {
2682 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2683 }
2684
2685 let request = req_builder
2686 .header(CONTENT_LENGTH, 0_u64)
2687 .body(common::to_body::<String>(None));
2688
2689 client.request(request.unwrap()).await
2690 };
2691
2692 match req_result {
2693 Err(err) => {
2694 if let common::Retry::After(d) = dlg.http_error(&err) {
2695 sleep(d).await;
2696 continue;
2697 }
2698 dlg.finished(false);
2699 return Err(common::Error::HttpError(err));
2700 }
2701 Ok(res) => {
2702 let (mut parts, body) = res.into_parts();
2703 let mut body = common::Body::new(body);
2704 if !parts.status.is_success() {
2705 let bytes = common::to_bytes(body).await.unwrap_or_default();
2706 let error = serde_json::from_str(&common::to_string(&bytes));
2707 let response = common::to_response(parts, bytes.into());
2708
2709 if let common::Retry::After(d) =
2710 dlg.http_failure(&response, error.as_ref().ok())
2711 {
2712 sleep(d).await;
2713 continue;
2714 }
2715
2716 dlg.finished(false);
2717
2718 return Err(match error {
2719 Ok(value) => common::Error::BadRequest(value),
2720 _ => common::Error::Failure(response),
2721 });
2722 }
2723 let response = {
2724 let bytes = common::to_bytes(body).await.unwrap_or_default();
2725 let encoded = common::to_string(&bytes);
2726 match serde_json::from_str(&encoded) {
2727 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2728 Err(error) => {
2729 dlg.response_json_decode_error(&encoded, &error);
2730 return Err(common::Error::JsonDecodeError(
2731 encoded.to_string(),
2732 error,
2733 ));
2734 }
2735 }
2736 };
2737
2738 dlg.finished(true);
2739 return Ok(response);
2740 }
2741 }
2742 }
2743 }
2744
2745 /// Required. Redis cluster certificate authority resource name using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}/certificateAuthority` where `location_id` refers to a GCP region.
2746 ///
2747 /// Sets the *name* path property to the given value.
2748 ///
2749 /// Even though the property as already been set when instantiating this call,
2750 /// we provide this method for API completeness.
2751 pub fn name(
2752 mut self,
2753 new_value: &str,
2754 ) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C> {
2755 self._name = new_value.to_string();
2756 self
2757 }
2758 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2759 /// while executing the actual API request.
2760 ///
2761 /// ````text
2762 /// It should be used to handle progress information, and to implement a certain level of resilience.
2763 /// ````
2764 ///
2765 /// Sets the *delegate* property to the given value.
2766 pub fn delegate(
2767 mut self,
2768 new_value: &'a mut dyn common::Delegate,
2769 ) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C> {
2770 self._delegate = Some(new_value);
2771 self
2772 }
2773
2774 /// Set any additional parameter of the query string used in the request.
2775 /// It should be used to set parameters which are not yet available through their own
2776 /// setters.
2777 ///
2778 /// Please note that this method must not be used to set any of the known parameters
2779 /// which have their own setter method. If done anyway, the request will fail.
2780 ///
2781 /// # Additional Parameters
2782 ///
2783 /// * *$.xgafv* (query-string) - V1 error format.
2784 /// * *access_token* (query-string) - OAuth access token.
2785 /// * *alt* (query-string) - Data format for response.
2786 /// * *callback* (query-string) - JSONP
2787 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2788 /// * *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.
2789 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2790 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2791 /// * *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.
2792 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2793 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2794 pub fn param<T>(
2795 mut self,
2796 name: T,
2797 value: T,
2798 ) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C>
2799 where
2800 T: AsRef<str>,
2801 {
2802 self._additional_params
2803 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2804 self
2805 }
2806
2807 /// Identifies the authorization scope for the method you are building.
2808 ///
2809 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2810 /// [`Scope::CloudPlatform`].
2811 ///
2812 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2813 /// tokens for more than one scope.
2814 ///
2815 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2816 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2817 /// sufficient, a read-write scope will do as well.
2818 pub fn add_scope<St>(
2819 mut self,
2820 scope: St,
2821 ) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C>
2822 where
2823 St: AsRef<str>,
2824 {
2825 self._scopes.insert(String::from(scope.as_ref()));
2826 self
2827 }
2828 /// Identifies the authorization scope(s) for the method you are building.
2829 ///
2830 /// See [`Self::add_scope()`] for details.
2831 pub fn add_scopes<I, St>(
2832 mut self,
2833 scopes: I,
2834 ) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C>
2835 where
2836 I: IntoIterator<Item = St>,
2837 St: AsRef<str>,
2838 {
2839 self._scopes
2840 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2841 self
2842 }
2843
2844 /// Removes all scopes, and no default scope will be used either.
2845 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2846 /// for details).
2847 pub fn clear_scopes(mut self) -> ProjectLocationClusterGetCertificateAuthorityCall<'a, C> {
2848 self._scopes.clear();
2849 self
2850 }
2851}
2852
2853/// Lists all Redis clusters owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
2854///
2855/// A builder for the *locations.clusters.list* method supported by a *project* resource.
2856/// It is not used directly, but through a [`ProjectMethods`] instance.
2857///
2858/// # Example
2859///
2860/// Instantiate a resource method builder
2861///
2862/// ```test_harness,no_run
2863/// # extern crate hyper;
2864/// # extern crate hyper_rustls;
2865/// # extern crate google_redis1 as redis1;
2866/// # async fn dox() {
2867/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2868///
2869/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2870/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2871/// # secret,
2872/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2873/// # ).build().await.unwrap();
2874///
2875/// # let client = hyper_util::client::legacy::Client::builder(
2876/// # hyper_util::rt::TokioExecutor::new()
2877/// # )
2878/// # .build(
2879/// # hyper_rustls::HttpsConnectorBuilder::new()
2880/// # .with_native_roots()
2881/// # .unwrap()
2882/// # .https_or_http()
2883/// # .enable_http1()
2884/// # .build()
2885/// # );
2886/// # let mut hub = CloudRedis::new(client, auth);
2887/// // You can configure optional parameters by calling the respective setters at will, and
2888/// // execute the final call using `doit()`.
2889/// // Values shown here are possibly random and not representative !
2890/// let result = hub.projects().locations_clusters_list("parent")
2891/// .page_token("dolor")
2892/// .page_size(-17)
2893/// .doit().await;
2894/// # }
2895/// ```
2896pub struct ProjectLocationClusterListCall<'a, C>
2897where
2898 C: 'a,
2899{
2900 hub: &'a CloudRedis<C>,
2901 _parent: String,
2902 _page_token: Option<String>,
2903 _page_size: Option<i32>,
2904 _delegate: Option<&'a mut dyn common::Delegate>,
2905 _additional_params: HashMap<String, String>,
2906 _scopes: BTreeSet<String>,
2907}
2908
2909impl<'a, C> common::CallBuilder for ProjectLocationClusterListCall<'a, C> {}
2910
2911impl<'a, C> ProjectLocationClusterListCall<'a, C>
2912where
2913 C: common::Connector,
2914{
2915 /// Perform the operation you have build so far.
2916 pub async fn doit(mut self) -> common::Result<(common::Response, ListClustersResponse)> {
2917 use std::borrow::Cow;
2918 use std::io::{Read, Seek};
2919
2920 use common::{url::Params, ToParts};
2921 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2922
2923 let mut dd = common::DefaultDelegate;
2924 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2925 dlg.begin(common::MethodInfo {
2926 id: "redis.projects.locations.clusters.list",
2927 http_method: hyper::Method::GET,
2928 });
2929
2930 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2931 if self._additional_params.contains_key(field) {
2932 dlg.finished(false);
2933 return Err(common::Error::FieldClash(field));
2934 }
2935 }
2936
2937 let mut params = Params::with_capacity(5 + self._additional_params.len());
2938 params.push("parent", self._parent);
2939 if let Some(value) = self._page_token.as_ref() {
2940 params.push("pageToken", value);
2941 }
2942 if let Some(value) = self._page_size.as_ref() {
2943 params.push("pageSize", value.to_string());
2944 }
2945
2946 params.extend(self._additional_params.iter());
2947
2948 params.push("alt", "json");
2949 let mut url = self.hub._base_url.clone() + "v1/{+parent}/clusters";
2950 if self._scopes.is_empty() {
2951 self._scopes
2952 .insert(Scope::CloudPlatform.as_ref().to_string());
2953 }
2954
2955 #[allow(clippy::single_element_loop)]
2956 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2957 url = params.uri_replacement(url, param_name, find_this, true);
2958 }
2959 {
2960 let to_remove = ["parent"];
2961 params.remove_params(&to_remove);
2962 }
2963
2964 let url = params.parse_with_url(&url);
2965
2966 loop {
2967 let token = match self
2968 .hub
2969 .auth
2970 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2971 .await
2972 {
2973 Ok(token) => token,
2974 Err(e) => match dlg.token(e) {
2975 Ok(token) => token,
2976 Err(e) => {
2977 dlg.finished(false);
2978 return Err(common::Error::MissingToken(e));
2979 }
2980 },
2981 };
2982 let mut req_result = {
2983 let client = &self.hub.client;
2984 dlg.pre_request();
2985 let mut req_builder = hyper::Request::builder()
2986 .method(hyper::Method::GET)
2987 .uri(url.as_str())
2988 .header(USER_AGENT, self.hub._user_agent.clone());
2989
2990 if let Some(token) = token.as_ref() {
2991 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2992 }
2993
2994 let request = req_builder
2995 .header(CONTENT_LENGTH, 0_u64)
2996 .body(common::to_body::<String>(None));
2997
2998 client.request(request.unwrap()).await
2999 };
3000
3001 match req_result {
3002 Err(err) => {
3003 if let common::Retry::After(d) = dlg.http_error(&err) {
3004 sleep(d).await;
3005 continue;
3006 }
3007 dlg.finished(false);
3008 return Err(common::Error::HttpError(err));
3009 }
3010 Ok(res) => {
3011 let (mut parts, body) = res.into_parts();
3012 let mut body = common::Body::new(body);
3013 if !parts.status.is_success() {
3014 let bytes = common::to_bytes(body).await.unwrap_or_default();
3015 let error = serde_json::from_str(&common::to_string(&bytes));
3016 let response = common::to_response(parts, bytes.into());
3017
3018 if let common::Retry::After(d) =
3019 dlg.http_failure(&response, error.as_ref().ok())
3020 {
3021 sleep(d).await;
3022 continue;
3023 }
3024
3025 dlg.finished(false);
3026
3027 return Err(match error {
3028 Ok(value) => common::Error::BadRequest(value),
3029 _ => common::Error::Failure(response),
3030 });
3031 }
3032 let response = {
3033 let bytes = common::to_bytes(body).await.unwrap_or_default();
3034 let encoded = common::to_string(&bytes);
3035 match serde_json::from_str(&encoded) {
3036 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3037 Err(error) => {
3038 dlg.response_json_decode_error(&encoded, &error);
3039 return Err(common::Error::JsonDecodeError(
3040 encoded.to_string(),
3041 error,
3042 ));
3043 }
3044 }
3045 };
3046
3047 dlg.finished(true);
3048 return Ok(response);
3049 }
3050 }
3051 }
3052 }
3053
3054 /// Required. The resource name of the cluster location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.
3055 ///
3056 /// Sets the *parent* path property to the given value.
3057 ///
3058 /// Even though the property as already been set when instantiating this call,
3059 /// we provide this method for API completeness.
3060 pub fn parent(mut self, new_value: &str) -> ProjectLocationClusterListCall<'a, C> {
3061 self._parent = new_value.to_string();
3062 self
3063 }
3064 /// The `next_page_token` value returned from a previous ListClusters request, if any.
3065 ///
3066 /// Sets the *page token* query property to the given value.
3067 pub fn page_token(mut self, new_value: &str) -> ProjectLocationClusterListCall<'a, C> {
3068 self._page_token = Some(new_value.to_string());
3069 self
3070 }
3071 /// 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 clusters left to be queried.
3072 ///
3073 /// Sets the *page size* query property to the given value.
3074 pub fn page_size(mut self, new_value: i32) -> ProjectLocationClusterListCall<'a, C> {
3075 self._page_size = Some(new_value);
3076 self
3077 }
3078 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3079 /// while executing the actual API request.
3080 ///
3081 /// ````text
3082 /// It should be used to handle progress information, and to implement a certain level of resilience.
3083 /// ````
3084 ///
3085 /// Sets the *delegate* property to the given value.
3086 pub fn delegate(
3087 mut self,
3088 new_value: &'a mut dyn common::Delegate,
3089 ) -> ProjectLocationClusterListCall<'a, C> {
3090 self._delegate = Some(new_value);
3091 self
3092 }
3093
3094 /// Set any additional parameter of the query string used in the request.
3095 /// It should be used to set parameters which are not yet available through their own
3096 /// setters.
3097 ///
3098 /// Please note that this method must not be used to set any of the known parameters
3099 /// which have their own setter method. If done anyway, the request will fail.
3100 ///
3101 /// # Additional Parameters
3102 ///
3103 /// * *$.xgafv* (query-string) - V1 error format.
3104 /// * *access_token* (query-string) - OAuth access token.
3105 /// * *alt* (query-string) - Data format for response.
3106 /// * *callback* (query-string) - JSONP
3107 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3108 /// * *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.
3109 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3110 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3111 /// * *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.
3112 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3113 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3114 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClusterListCall<'a, C>
3115 where
3116 T: AsRef<str>,
3117 {
3118 self._additional_params
3119 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3120 self
3121 }
3122
3123 /// Identifies the authorization scope for the method you are building.
3124 ///
3125 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3126 /// [`Scope::CloudPlatform`].
3127 ///
3128 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3129 /// tokens for more than one scope.
3130 ///
3131 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3132 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3133 /// sufficient, a read-write scope will do as well.
3134 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClusterListCall<'a, C>
3135 where
3136 St: AsRef<str>,
3137 {
3138 self._scopes.insert(String::from(scope.as_ref()));
3139 self
3140 }
3141 /// Identifies the authorization scope(s) for the method you are building.
3142 ///
3143 /// See [`Self::add_scope()`] for details.
3144 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClusterListCall<'a, C>
3145 where
3146 I: IntoIterator<Item = St>,
3147 St: AsRef<str>,
3148 {
3149 self._scopes
3150 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3151 self
3152 }
3153
3154 /// Removes all scopes, and no default scope will be used either.
3155 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3156 /// for details).
3157 pub fn clear_scopes(mut self) -> ProjectLocationClusterListCall<'a, C> {
3158 self._scopes.clear();
3159 self
3160 }
3161}
3162
3163/// Updates the metadata and configuration of a specific Redis cluster. Completed longrunning.Operation will contain the new cluster object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
3164///
3165/// A builder for the *locations.clusters.patch* method supported by a *project* resource.
3166/// It is not used directly, but through a [`ProjectMethods`] instance.
3167///
3168/// # Example
3169///
3170/// Instantiate a resource method builder
3171///
3172/// ```test_harness,no_run
3173/// # extern crate hyper;
3174/// # extern crate hyper_rustls;
3175/// # extern crate google_redis1 as redis1;
3176/// use redis1::api::Cluster;
3177/// # async fn dox() {
3178/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3179///
3180/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3181/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3182/// # secret,
3183/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3184/// # ).build().await.unwrap();
3185///
3186/// # let client = hyper_util::client::legacy::Client::builder(
3187/// # hyper_util::rt::TokioExecutor::new()
3188/// # )
3189/// # .build(
3190/// # hyper_rustls::HttpsConnectorBuilder::new()
3191/// # .with_native_roots()
3192/// # .unwrap()
3193/// # .https_or_http()
3194/// # .enable_http1()
3195/// # .build()
3196/// # );
3197/// # let mut hub = CloudRedis::new(client, auth);
3198/// // As the method needs a request, you would usually fill it with the desired information
3199/// // into the respective structure. Some of the parts shown here might not be applicable !
3200/// // Values shown here are possibly random and not representative !
3201/// let mut req = Cluster::default();
3202///
3203/// // You can configure optional parameters by calling the respective setters at will, and
3204/// // execute the final call using `doit()`.
3205/// // Values shown here are possibly random and not representative !
3206/// let result = hub.projects().locations_clusters_patch(req, "name")
3207/// .update_mask(FieldMask::new::<&str>(&[]))
3208/// .request_id("invidunt")
3209/// .doit().await;
3210/// # }
3211/// ```
3212pub struct ProjectLocationClusterPatchCall<'a, C>
3213where
3214 C: 'a,
3215{
3216 hub: &'a CloudRedis<C>,
3217 _request: Cluster,
3218 _name: String,
3219 _update_mask: Option<common::FieldMask>,
3220 _request_id: Option<String>,
3221 _delegate: Option<&'a mut dyn common::Delegate>,
3222 _additional_params: HashMap<String, String>,
3223 _scopes: BTreeSet<String>,
3224}
3225
3226impl<'a, C> common::CallBuilder for ProjectLocationClusterPatchCall<'a, C> {}
3227
3228impl<'a, C> ProjectLocationClusterPatchCall<'a, C>
3229where
3230 C: common::Connector,
3231{
3232 /// Perform the operation you have build so far.
3233 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3234 use std::borrow::Cow;
3235 use std::io::{Read, Seek};
3236
3237 use common::{url::Params, ToParts};
3238 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3239
3240 let mut dd = common::DefaultDelegate;
3241 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3242 dlg.begin(common::MethodInfo {
3243 id: "redis.projects.locations.clusters.patch",
3244 http_method: hyper::Method::PATCH,
3245 });
3246
3247 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
3248 if self._additional_params.contains_key(field) {
3249 dlg.finished(false);
3250 return Err(common::Error::FieldClash(field));
3251 }
3252 }
3253
3254 let mut params = Params::with_capacity(6 + self._additional_params.len());
3255 params.push("name", self._name);
3256 if let Some(value) = self._update_mask.as_ref() {
3257 params.push("updateMask", value.to_string());
3258 }
3259 if let Some(value) = self._request_id.as_ref() {
3260 params.push("requestId", value);
3261 }
3262
3263 params.extend(self._additional_params.iter());
3264
3265 params.push("alt", "json");
3266 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3267 if self._scopes.is_empty() {
3268 self._scopes
3269 .insert(Scope::CloudPlatform.as_ref().to_string());
3270 }
3271
3272 #[allow(clippy::single_element_loop)]
3273 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3274 url = params.uri_replacement(url, param_name, find_this, true);
3275 }
3276 {
3277 let to_remove = ["name"];
3278 params.remove_params(&to_remove);
3279 }
3280
3281 let url = params.parse_with_url(&url);
3282
3283 let mut json_mime_type = mime::APPLICATION_JSON;
3284 let mut request_value_reader = {
3285 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3286 common::remove_json_null_values(&mut value);
3287 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3288 serde_json::to_writer(&mut dst, &value).unwrap();
3289 dst
3290 };
3291 let request_size = request_value_reader
3292 .seek(std::io::SeekFrom::End(0))
3293 .unwrap();
3294 request_value_reader
3295 .seek(std::io::SeekFrom::Start(0))
3296 .unwrap();
3297
3298 loop {
3299 let token = match self
3300 .hub
3301 .auth
3302 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3303 .await
3304 {
3305 Ok(token) => token,
3306 Err(e) => match dlg.token(e) {
3307 Ok(token) => token,
3308 Err(e) => {
3309 dlg.finished(false);
3310 return Err(common::Error::MissingToken(e));
3311 }
3312 },
3313 };
3314 request_value_reader
3315 .seek(std::io::SeekFrom::Start(0))
3316 .unwrap();
3317 let mut req_result = {
3318 let client = &self.hub.client;
3319 dlg.pre_request();
3320 let mut req_builder = hyper::Request::builder()
3321 .method(hyper::Method::PATCH)
3322 .uri(url.as_str())
3323 .header(USER_AGENT, self.hub._user_agent.clone());
3324
3325 if let Some(token) = token.as_ref() {
3326 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3327 }
3328
3329 let request = req_builder
3330 .header(CONTENT_TYPE, json_mime_type.to_string())
3331 .header(CONTENT_LENGTH, request_size as u64)
3332 .body(common::to_body(
3333 request_value_reader.get_ref().clone().into(),
3334 ));
3335
3336 client.request(request.unwrap()).await
3337 };
3338
3339 match req_result {
3340 Err(err) => {
3341 if let common::Retry::After(d) = dlg.http_error(&err) {
3342 sleep(d).await;
3343 continue;
3344 }
3345 dlg.finished(false);
3346 return Err(common::Error::HttpError(err));
3347 }
3348 Ok(res) => {
3349 let (mut parts, body) = res.into_parts();
3350 let mut body = common::Body::new(body);
3351 if !parts.status.is_success() {
3352 let bytes = common::to_bytes(body).await.unwrap_or_default();
3353 let error = serde_json::from_str(&common::to_string(&bytes));
3354 let response = common::to_response(parts, bytes.into());
3355
3356 if let common::Retry::After(d) =
3357 dlg.http_failure(&response, error.as_ref().ok())
3358 {
3359 sleep(d).await;
3360 continue;
3361 }
3362
3363 dlg.finished(false);
3364
3365 return Err(match error {
3366 Ok(value) => common::Error::BadRequest(value),
3367 _ => common::Error::Failure(response),
3368 });
3369 }
3370 let response = {
3371 let bytes = common::to_bytes(body).await.unwrap_or_default();
3372 let encoded = common::to_string(&bytes);
3373 match serde_json::from_str(&encoded) {
3374 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3375 Err(error) => {
3376 dlg.response_json_decode_error(&encoded, &error);
3377 return Err(common::Error::JsonDecodeError(
3378 encoded.to_string(),
3379 error,
3380 ));
3381 }
3382 }
3383 };
3384
3385 dlg.finished(true);
3386 return Ok(response);
3387 }
3388 }
3389 }
3390 }
3391
3392 ///
3393 /// Sets the *request* property to the given value.
3394 ///
3395 /// Even though the property as already been set when instantiating this call,
3396 /// we provide this method for API completeness.
3397 pub fn request(mut self, new_value: Cluster) -> ProjectLocationClusterPatchCall<'a, C> {
3398 self._request = new_value;
3399 self
3400 }
3401 /// Required. Identifier. Unique name of the resource in this scope including project and location using the form: `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
3402 ///
3403 /// Sets the *name* path property to the given value.
3404 ///
3405 /// Even though the property as already been set when instantiating this call,
3406 /// we provide this method for API completeness.
3407 pub fn name(mut self, new_value: &str) -> ProjectLocationClusterPatchCall<'a, C> {
3408 self._name = new_value.to_string();
3409 self
3410 }
3411 /// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields from Cluster: * `size_gb` * `replica_count`
3412 ///
3413 /// Sets the *update mask* query property to the given value.
3414 pub fn update_mask(
3415 mut self,
3416 new_value: common::FieldMask,
3417 ) -> ProjectLocationClusterPatchCall<'a, C> {
3418 self._update_mask = Some(new_value);
3419 self
3420 }
3421 /// Idempotent request UUID.
3422 ///
3423 /// Sets the *request id* query property to the given value.
3424 pub fn request_id(mut self, new_value: &str) -> ProjectLocationClusterPatchCall<'a, C> {
3425 self._request_id = Some(new_value.to_string());
3426 self
3427 }
3428 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3429 /// while executing the actual API request.
3430 ///
3431 /// ````text
3432 /// It should be used to handle progress information, and to implement a certain level of resilience.
3433 /// ````
3434 ///
3435 /// Sets the *delegate* property to the given value.
3436 pub fn delegate(
3437 mut self,
3438 new_value: &'a mut dyn common::Delegate,
3439 ) -> ProjectLocationClusterPatchCall<'a, C> {
3440 self._delegate = Some(new_value);
3441 self
3442 }
3443
3444 /// Set any additional parameter of the query string used in the request.
3445 /// It should be used to set parameters which are not yet available through their own
3446 /// setters.
3447 ///
3448 /// Please note that this method must not be used to set any of the known parameters
3449 /// which have their own setter method. If done anyway, the request will fail.
3450 ///
3451 /// # Additional Parameters
3452 ///
3453 /// * *$.xgafv* (query-string) - V1 error format.
3454 /// * *access_token* (query-string) - OAuth access token.
3455 /// * *alt* (query-string) - Data format for response.
3456 /// * *callback* (query-string) - JSONP
3457 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3458 /// * *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.
3459 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3460 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3461 /// * *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.
3462 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3463 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3464 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClusterPatchCall<'a, C>
3465 where
3466 T: AsRef<str>,
3467 {
3468 self._additional_params
3469 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3470 self
3471 }
3472
3473 /// Identifies the authorization scope for the method you are building.
3474 ///
3475 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3476 /// [`Scope::CloudPlatform`].
3477 ///
3478 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3479 /// tokens for more than one scope.
3480 ///
3481 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3482 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3483 /// sufficient, a read-write scope will do as well.
3484 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClusterPatchCall<'a, C>
3485 where
3486 St: AsRef<str>,
3487 {
3488 self._scopes.insert(String::from(scope.as_ref()));
3489 self
3490 }
3491 /// Identifies the authorization scope(s) for the method you are building.
3492 ///
3493 /// See [`Self::add_scope()`] for details.
3494 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClusterPatchCall<'a, C>
3495 where
3496 I: IntoIterator<Item = St>,
3497 St: AsRef<str>,
3498 {
3499 self._scopes
3500 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3501 self
3502 }
3503
3504 /// Removes all scopes, and no default scope will be used either.
3505 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3506 /// for details).
3507 pub fn clear_scopes(mut self) -> ProjectLocationClusterPatchCall<'a, C> {
3508 self._scopes.clear();
3509 self
3510 }
3511}
3512
3513/// Creates a Redis instance based on the specified tier and memory size. By default, the instance is accessible from the project's [default network](https://cloud.google.com/vpc/docs/vpc). The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
3514///
3515/// A builder for the *locations.instances.create* method supported by a *project* resource.
3516/// It is not used directly, but through a [`ProjectMethods`] instance.
3517///
3518/// # Example
3519///
3520/// Instantiate a resource method builder
3521///
3522/// ```test_harness,no_run
3523/// # extern crate hyper;
3524/// # extern crate hyper_rustls;
3525/// # extern crate google_redis1 as redis1;
3526/// use redis1::api::Instance;
3527/// # async fn dox() {
3528/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3529///
3530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3531/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3532/// # secret,
3533/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3534/// # ).build().await.unwrap();
3535///
3536/// # let client = hyper_util::client::legacy::Client::builder(
3537/// # hyper_util::rt::TokioExecutor::new()
3538/// # )
3539/// # .build(
3540/// # hyper_rustls::HttpsConnectorBuilder::new()
3541/// # .with_native_roots()
3542/// # .unwrap()
3543/// # .https_or_http()
3544/// # .enable_http1()
3545/// # .build()
3546/// # );
3547/// # let mut hub = CloudRedis::new(client, auth);
3548/// // As the method needs a request, you would usually fill it with the desired information
3549/// // into the respective structure. Some of the parts shown here might not be applicable !
3550/// // Values shown here are possibly random and not representative !
3551/// let mut req = Instance::default();
3552///
3553/// // You can configure optional parameters by calling the respective setters at will, and
3554/// // execute the final call using `doit()`.
3555/// // Values shown here are possibly random and not representative !
3556/// let result = hub.projects().locations_instances_create(req, "parent")
3557/// .instance_id("duo")
3558/// .doit().await;
3559/// # }
3560/// ```
3561pub struct ProjectLocationInstanceCreateCall<'a, C>
3562where
3563 C: 'a,
3564{
3565 hub: &'a CloudRedis<C>,
3566 _request: Instance,
3567 _parent: String,
3568 _instance_id: Option<String>,
3569 _delegate: Option<&'a mut dyn common::Delegate>,
3570 _additional_params: HashMap<String, String>,
3571 _scopes: BTreeSet<String>,
3572}
3573
3574impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
3575
3576impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
3577where
3578 C: common::Connector,
3579{
3580 /// Perform the operation you have build so far.
3581 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3582 use std::borrow::Cow;
3583 use std::io::{Read, Seek};
3584
3585 use common::{url::Params, ToParts};
3586 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3587
3588 let mut dd = common::DefaultDelegate;
3589 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3590 dlg.begin(common::MethodInfo {
3591 id: "redis.projects.locations.instances.create",
3592 http_method: hyper::Method::POST,
3593 });
3594
3595 for &field in ["alt", "parent", "instanceId"].iter() {
3596 if self._additional_params.contains_key(field) {
3597 dlg.finished(false);
3598 return Err(common::Error::FieldClash(field));
3599 }
3600 }
3601
3602 let mut params = Params::with_capacity(5 + self._additional_params.len());
3603 params.push("parent", self._parent);
3604 if let Some(value) = self._instance_id.as_ref() {
3605 params.push("instanceId", value);
3606 }
3607
3608 params.extend(self._additional_params.iter());
3609
3610 params.push("alt", "json");
3611 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
3612 if self._scopes.is_empty() {
3613 self._scopes
3614 .insert(Scope::CloudPlatform.as_ref().to_string());
3615 }
3616
3617 #[allow(clippy::single_element_loop)]
3618 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3619 url = params.uri_replacement(url, param_name, find_this, true);
3620 }
3621 {
3622 let to_remove = ["parent"];
3623 params.remove_params(&to_remove);
3624 }
3625
3626 let url = params.parse_with_url(&url);
3627
3628 let mut json_mime_type = mime::APPLICATION_JSON;
3629 let mut request_value_reader = {
3630 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3631 common::remove_json_null_values(&mut value);
3632 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3633 serde_json::to_writer(&mut dst, &value).unwrap();
3634 dst
3635 };
3636 let request_size = request_value_reader
3637 .seek(std::io::SeekFrom::End(0))
3638 .unwrap();
3639 request_value_reader
3640 .seek(std::io::SeekFrom::Start(0))
3641 .unwrap();
3642
3643 loop {
3644 let token = match self
3645 .hub
3646 .auth
3647 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3648 .await
3649 {
3650 Ok(token) => token,
3651 Err(e) => match dlg.token(e) {
3652 Ok(token) => token,
3653 Err(e) => {
3654 dlg.finished(false);
3655 return Err(common::Error::MissingToken(e));
3656 }
3657 },
3658 };
3659 request_value_reader
3660 .seek(std::io::SeekFrom::Start(0))
3661 .unwrap();
3662 let mut req_result = {
3663 let client = &self.hub.client;
3664 dlg.pre_request();
3665 let mut req_builder = hyper::Request::builder()
3666 .method(hyper::Method::POST)
3667 .uri(url.as_str())
3668 .header(USER_AGENT, self.hub._user_agent.clone());
3669
3670 if let Some(token) = token.as_ref() {
3671 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3672 }
3673
3674 let request = req_builder
3675 .header(CONTENT_TYPE, json_mime_type.to_string())
3676 .header(CONTENT_LENGTH, request_size as u64)
3677 .body(common::to_body(
3678 request_value_reader.get_ref().clone().into(),
3679 ));
3680
3681 client.request(request.unwrap()).await
3682 };
3683
3684 match req_result {
3685 Err(err) => {
3686 if let common::Retry::After(d) = dlg.http_error(&err) {
3687 sleep(d).await;
3688 continue;
3689 }
3690 dlg.finished(false);
3691 return Err(common::Error::HttpError(err));
3692 }
3693 Ok(res) => {
3694 let (mut parts, body) = res.into_parts();
3695 let mut body = common::Body::new(body);
3696 if !parts.status.is_success() {
3697 let bytes = common::to_bytes(body).await.unwrap_or_default();
3698 let error = serde_json::from_str(&common::to_string(&bytes));
3699 let response = common::to_response(parts, bytes.into());
3700
3701 if let common::Retry::After(d) =
3702 dlg.http_failure(&response, error.as_ref().ok())
3703 {
3704 sleep(d).await;
3705 continue;
3706 }
3707
3708 dlg.finished(false);
3709
3710 return Err(match error {
3711 Ok(value) => common::Error::BadRequest(value),
3712 _ => common::Error::Failure(response),
3713 });
3714 }
3715 let response = {
3716 let bytes = common::to_bytes(body).await.unwrap_or_default();
3717 let encoded = common::to_string(&bytes);
3718 match serde_json::from_str(&encoded) {
3719 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3720 Err(error) => {
3721 dlg.response_json_decode_error(&encoded, &error);
3722 return Err(common::Error::JsonDecodeError(
3723 encoded.to_string(),
3724 error,
3725 ));
3726 }
3727 }
3728 };
3729
3730 dlg.finished(true);
3731 return Ok(response);
3732 }
3733 }
3734 }
3735 }
3736
3737 ///
3738 /// Sets the *request* property to the given value.
3739 ///
3740 /// Even though the property as already been set when instantiating this call,
3741 /// we provide this method for API completeness.
3742 pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, C> {
3743 self._request = new_value;
3744 self
3745 }
3746 /// 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.
3747 ///
3748 /// Sets the *parent* path property to the given value.
3749 ///
3750 /// Even though the property as already been set when instantiating this call,
3751 /// we provide this method for API completeness.
3752 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
3753 self._parent = new_value.to_string();
3754 self
3755 }
3756 /// Required. The logical name of the Redis instance in the customer 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 customer project / location
3757 ///
3758 /// Sets the *instance id* query property to the given value.
3759 pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
3760 self._instance_id = Some(new_value.to_string());
3761 self
3762 }
3763 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3764 /// while executing the actual API request.
3765 ///
3766 /// ````text
3767 /// It should be used to handle progress information, and to implement a certain level of resilience.
3768 /// ````
3769 ///
3770 /// Sets the *delegate* property to the given value.
3771 pub fn delegate(
3772 mut self,
3773 new_value: &'a mut dyn common::Delegate,
3774 ) -> ProjectLocationInstanceCreateCall<'a, C> {
3775 self._delegate = Some(new_value);
3776 self
3777 }
3778
3779 /// Set any additional parameter of the query string used in the request.
3780 /// It should be used to set parameters which are not yet available through their own
3781 /// setters.
3782 ///
3783 /// Please note that this method must not be used to set any of the known parameters
3784 /// which have their own setter method. If done anyway, the request will fail.
3785 ///
3786 /// # Additional Parameters
3787 ///
3788 /// * *$.xgafv* (query-string) - V1 error format.
3789 /// * *access_token* (query-string) - OAuth access token.
3790 /// * *alt* (query-string) - Data format for response.
3791 /// * *callback* (query-string) - JSONP
3792 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3793 /// * *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.
3794 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3795 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3796 /// * *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.
3797 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3798 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3799 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
3800 where
3801 T: AsRef<str>,
3802 {
3803 self._additional_params
3804 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3805 self
3806 }
3807
3808 /// Identifies the authorization scope for the method you are building.
3809 ///
3810 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3811 /// [`Scope::CloudPlatform`].
3812 ///
3813 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3814 /// tokens for more than one scope.
3815 ///
3816 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3817 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3818 /// sufficient, a read-write scope will do as well.
3819 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
3820 where
3821 St: AsRef<str>,
3822 {
3823 self._scopes.insert(String::from(scope.as_ref()));
3824 self
3825 }
3826 /// Identifies the authorization scope(s) for the method you are building.
3827 ///
3828 /// See [`Self::add_scope()`] for details.
3829 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
3830 where
3831 I: IntoIterator<Item = St>,
3832 St: AsRef<str>,
3833 {
3834 self._scopes
3835 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3836 self
3837 }
3838
3839 /// Removes all scopes, and no default scope will be used either.
3840 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3841 /// for details).
3842 pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
3843 self._scopes.clear();
3844 self
3845 }
3846}
3847
3848/// Deletes a specific Redis instance. Instance stops serving and data is deleted.
3849///
3850/// A builder for the *locations.instances.delete* method supported by a *project* resource.
3851/// It is not used directly, but through a [`ProjectMethods`] instance.
3852///
3853/// # Example
3854///
3855/// Instantiate a resource method builder
3856///
3857/// ```test_harness,no_run
3858/// # extern crate hyper;
3859/// # extern crate hyper_rustls;
3860/// # extern crate google_redis1 as redis1;
3861/// # async fn dox() {
3862/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3863///
3864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3866/// # secret,
3867/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3868/// # ).build().await.unwrap();
3869///
3870/// # let client = hyper_util::client::legacy::Client::builder(
3871/// # hyper_util::rt::TokioExecutor::new()
3872/// # )
3873/// # .build(
3874/// # hyper_rustls::HttpsConnectorBuilder::new()
3875/// # .with_native_roots()
3876/// # .unwrap()
3877/// # .https_or_http()
3878/// # .enable_http1()
3879/// # .build()
3880/// # );
3881/// # let mut hub = CloudRedis::new(client, auth);
3882/// // You can configure optional parameters by calling the respective setters at will, and
3883/// // execute the final call using `doit()`.
3884/// // Values shown here are possibly random and not representative !
3885/// let result = hub.projects().locations_instances_delete("name")
3886/// .doit().await;
3887/// # }
3888/// ```
3889pub struct ProjectLocationInstanceDeleteCall<'a, C>
3890where
3891 C: 'a,
3892{
3893 hub: &'a CloudRedis<C>,
3894 _name: String,
3895 _delegate: Option<&'a mut dyn common::Delegate>,
3896 _additional_params: HashMap<String, String>,
3897 _scopes: BTreeSet<String>,
3898}
3899
3900impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
3901
3902impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
3903where
3904 C: common::Connector,
3905{
3906 /// Perform the operation you have build so far.
3907 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3908 use std::borrow::Cow;
3909 use std::io::{Read, Seek};
3910
3911 use common::{url::Params, ToParts};
3912 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3913
3914 let mut dd = common::DefaultDelegate;
3915 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3916 dlg.begin(common::MethodInfo {
3917 id: "redis.projects.locations.instances.delete",
3918 http_method: hyper::Method::DELETE,
3919 });
3920
3921 for &field in ["alt", "name"].iter() {
3922 if self._additional_params.contains_key(field) {
3923 dlg.finished(false);
3924 return Err(common::Error::FieldClash(field));
3925 }
3926 }
3927
3928 let mut params = Params::with_capacity(3 + self._additional_params.len());
3929 params.push("name", self._name);
3930
3931 params.extend(self._additional_params.iter());
3932
3933 params.push("alt", "json");
3934 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3935 if self._scopes.is_empty() {
3936 self._scopes
3937 .insert(Scope::CloudPlatform.as_ref().to_string());
3938 }
3939
3940 #[allow(clippy::single_element_loop)]
3941 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3942 url = params.uri_replacement(url, param_name, find_this, true);
3943 }
3944 {
3945 let to_remove = ["name"];
3946 params.remove_params(&to_remove);
3947 }
3948
3949 let url = params.parse_with_url(&url);
3950
3951 loop {
3952 let token = match self
3953 .hub
3954 .auth
3955 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3956 .await
3957 {
3958 Ok(token) => token,
3959 Err(e) => match dlg.token(e) {
3960 Ok(token) => token,
3961 Err(e) => {
3962 dlg.finished(false);
3963 return Err(common::Error::MissingToken(e));
3964 }
3965 },
3966 };
3967 let mut req_result = {
3968 let client = &self.hub.client;
3969 dlg.pre_request();
3970 let mut req_builder = hyper::Request::builder()
3971 .method(hyper::Method::DELETE)
3972 .uri(url.as_str())
3973 .header(USER_AGENT, self.hub._user_agent.clone());
3974
3975 if let Some(token) = token.as_ref() {
3976 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3977 }
3978
3979 let request = req_builder
3980 .header(CONTENT_LENGTH, 0_u64)
3981 .body(common::to_body::<String>(None));
3982
3983 client.request(request.unwrap()).await
3984 };
3985
3986 match req_result {
3987 Err(err) => {
3988 if let common::Retry::After(d) = dlg.http_error(&err) {
3989 sleep(d).await;
3990 continue;
3991 }
3992 dlg.finished(false);
3993 return Err(common::Error::HttpError(err));
3994 }
3995 Ok(res) => {
3996 let (mut parts, body) = res.into_parts();
3997 let mut body = common::Body::new(body);
3998 if !parts.status.is_success() {
3999 let bytes = common::to_bytes(body).await.unwrap_or_default();
4000 let error = serde_json::from_str(&common::to_string(&bytes));
4001 let response = common::to_response(parts, bytes.into());
4002
4003 if let common::Retry::After(d) =
4004 dlg.http_failure(&response, error.as_ref().ok())
4005 {
4006 sleep(d).await;
4007 continue;
4008 }
4009
4010 dlg.finished(false);
4011
4012 return Err(match error {
4013 Ok(value) => common::Error::BadRequest(value),
4014 _ => common::Error::Failure(response),
4015 });
4016 }
4017 let response = {
4018 let bytes = common::to_bytes(body).await.unwrap_or_default();
4019 let encoded = common::to_string(&bytes);
4020 match serde_json::from_str(&encoded) {
4021 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4022 Err(error) => {
4023 dlg.response_json_decode_error(&encoded, &error);
4024 return Err(common::Error::JsonDecodeError(
4025 encoded.to_string(),
4026 error,
4027 ));
4028 }
4029 }
4030 };
4031
4032 dlg.finished(true);
4033 return Ok(response);
4034 }
4035 }
4036 }
4037 }
4038
4039 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
4040 ///
4041 /// Sets the *name* path property to the given value.
4042 ///
4043 /// Even though the property as already been set when instantiating this call,
4044 /// we provide this method for API completeness.
4045 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
4046 self._name = new_value.to_string();
4047 self
4048 }
4049 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4050 /// while executing the actual API request.
4051 ///
4052 /// ````text
4053 /// It should be used to handle progress information, and to implement a certain level of resilience.
4054 /// ````
4055 ///
4056 /// Sets the *delegate* property to the given value.
4057 pub fn delegate(
4058 mut self,
4059 new_value: &'a mut dyn common::Delegate,
4060 ) -> ProjectLocationInstanceDeleteCall<'a, C> {
4061 self._delegate = Some(new_value);
4062 self
4063 }
4064
4065 /// Set any additional parameter of the query string used in the request.
4066 /// It should be used to set parameters which are not yet available through their own
4067 /// setters.
4068 ///
4069 /// Please note that this method must not be used to set any of the known parameters
4070 /// which have their own setter method. If done anyway, the request will fail.
4071 ///
4072 /// # Additional Parameters
4073 ///
4074 /// * *$.xgafv* (query-string) - V1 error format.
4075 /// * *access_token* (query-string) - OAuth access token.
4076 /// * *alt* (query-string) - Data format for response.
4077 /// * *callback* (query-string) - JSONP
4078 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4079 /// * *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.
4080 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4081 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4082 /// * *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.
4083 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4084 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4085 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
4086 where
4087 T: AsRef<str>,
4088 {
4089 self._additional_params
4090 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4091 self
4092 }
4093
4094 /// Identifies the authorization scope for the method you are building.
4095 ///
4096 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4097 /// [`Scope::CloudPlatform`].
4098 ///
4099 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4100 /// tokens for more than one scope.
4101 ///
4102 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4103 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4104 /// sufficient, a read-write scope will do as well.
4105 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
4106 where
4107 St: AsRef<str>,
4108 {
4109 self._scopes.insert(String::from(scope.as_ref()));
4110 self
4111 }
4112 /// Identifies the authorization scope(s) for the method you are building.
4113 ///
4114 /// See [`Self::add_scope()`] for details.
4115 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
4116 where
4117 I: IntoIterator<Item = St>,
4118 St: AsRef<str>,
4119 {
4120 self._scopes
4121 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4122 self
4123 }
4124
4125 /// Removes all scopes, and no default scope will be used either.
4126 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4127 /// for details).
4128 pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
4129 self._scopes.clear();
4130 self
4131 }
4132}
4133
4134/// Export Redis instance data into a Redis RDB format file in Cloud Storage. Redis will continue serving during this operation. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
4135///
4136/// A builder for the *locations.instances.export* method supported by a *project* resource.
4137/// It is not used directly, but through a [`ProjectMethods`] instance.
4138///
4139/// # Example
4140///
4141/// Instantiate a resource method builder
4142///
4143/// ```test_harness,no_run
4144/// # extern crate hyper;
4145/// # extern crate hyper_rustls;
4146/// # extern crate google_redis1 as redis1;
4147/// use redis1::api::ExportInstanceRequest;
4148/// # async fn dox() {
4149/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4150///
4151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4152/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4153/// # secret,
4154/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4155/// # ).build().await.unwrap();
4156///
4157/// # let client = hyper_util::client::legacy::Client::builder(
4158/// # hyper_util::rt::TokioExecutor::new()
4159/// # )
4160/// # .build(
4161/// # hyper_rustls::HttpsConnectorBuilder::new()
4162/// # .with_native_roots()
4163/// # .unwrap()
4164/// # .https_or_http()
4165/// # .enable_http1()
4166/// # .build()
4167/// # );
4168/// # let mut hub = CloudRedis::new(client, auth);
4169/// // As the method needs a request, you would usually fill it with the desired information
4170/// // into the respective structure. Some of the parts shown here might not be applicable !
4171/// // Values shown here are possibly random and not representative !
4172/// let mut req = ExportInstanceRequest::default();
4173///
4174/// // You can configure optional parameters by calling the respective setters at will, and
4175/// // execute the final call using `doit()`.
4176/// // Values shown here are possibly random and not representative !
4177/// let result = hub.projects().locations_instances_export(req, "name")
4178/// .doit().await;
4179/// # }
4180/// ```
4181pub struct ProjectLocationInstanceExportCall<'a, C>
4182where
4183 C: 'a,
4184{
4185 hub: &'a CloudRedis<C>,
4186 _request: ExportInstanceRequest,
4187 _name: String,
4188 _delegate: Option<&'a mut dyn common::Delegate>,
4189 _additional_params: HashMap<String, String>,
4190 _scopes: BTreeSet<String>,
4191}
4192
4193impl<'a, C> common::CallBuilder for ProjectLocationInstanceExportCall<'a, C> {}
4194
4195impl<'a, C> ProjectLocationInstanceExportCall<'a, C>
4196where
4197 C: common::Connector,
4198{
4199 /// Perform the operation you have build so far.
4200 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4201 use std::borrow::Cow;
4202 use std::io::{Read, Seek};
4203
4204 use common::{url::Params, ToParts};
4205 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4206
4207 let mut dd = common::DefaultDelegate;
4208 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4209 dlg.begin(common::MethodInfo {
4210 id: "redis.projects.locations.instances.export",
4211 http_method: hyper::Method::POST,
4212 });
4213
4214 for &field in ["alt", "name"].iter() {
4215 if self._additional_params.contains_key(field) {
4216 dlg.finished(false);
4217 return Err(common::Error::FieldClash(field));
4218 }
4219 }
4220
4221 let mut params = Params::with_capacity(4 + self._additional_params.len());
4222 params.push("name", self._name);
4223
4224 params.extend(self._additional_params.iter());
4225
4226 params.push("alt", "json");
4227 let mut url = self.hub._base_url.clone() + "v1/{+name}:export";
4228 if self._scopes.is_empty() {
4229 self._scopes
4230 .insert(Scope::CloudPlatform.as_ref().to_string());
4231 }
4232
4233 #[allow(clippy::single_element_loop)]
4234 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4235 url = params.uri_replacement(url, param_name, find_this, true);
4236 }
4237 {
4238 let to_remove = ["name"];
4239 params.remove_params(&to_remove);
4240 }
4241
4242 let url = params.parse_with_url(&url);
4243
4244 let mut json_mime_type = mime::APPLICATION_JSON;
4245 let mut request_value_reader = {
4246 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4247 common::remove_json_null_values(&mut value);
4248 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4249 serde_json::to_writer(&mut dst, &value).unwrap();
4250 dst
4251 };
4252 let request_size = request_value_reader
4253 .seek(std::io::SeekFrom::End(0))
4254 .unwrap();
4255 request_value_reader
4256 .seek(std::io::SeekFrom::Start(0))
4257 .unwrap();
4258
4259 loop {
4260 let token = match self
4261 .hub
4262 .auth
4263 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4264 .await
4265 {
4266 Ok(token) => token,
4267 Err(e) => match dlg.token(e) {
4268 Ok(token) => token,
4269 Err(e) => {
4270 dlg.finished(false);
4271 return Err(common::Error::MissingToken(e));
4272 }
4273 },
4274 };
4275 request_value_reader
4276 .seek(std::io::SeekFrom::Start(0))
4277 .unwrap();
4278 let mut req_result = {
4279 let client = &self.hub.client;
4280 dlg.pre_request();
4281 let mut req_builder = hyper::Request::builder()
4282 .method(hyper::Method::POST)
4283 .uri(url.as_str())
4284 .header(USER_AGENT, self.hub._user_agent.clone());
4285
4286 if let Some(token) = token.as_ref() {
4287 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4288 }
4289
4290 let request = req_builder
4291 .header(CONTENT_TYPE, json_mime_type.to_string())
4292 .header(CONTENT_LENGTH, request_size as u64)
4293 .body(common::to_body(
4294 request_value_reader.get_ref().clone().into(),
4295 ));
4296
4297 client.request(request.unwrap()).await
4298 };
4299
4300 match req_result {
4301 Err(err) => {
4302 if let common::Retry::After(d) = dlg.http_error(&err) {
4303 sleep(d).await;
4304 continue;
4305 }
4306 dlg.finished(false);
4307 return Err(common::Error::HttpError(err));
4308 }
4309 Ok(res) => {
4310 let (mut parts, body) = res.into_parts();
4311 let mut body = common::Body::new(body);
4312 if !parts.status.is_success() {
4313 let bytes = common::to_bytes(body).await.unwrap_or_default();
4314 let error = serde_json::from_str(&common::to_string(&bytes));
4315 let response = common::to_response(parts, bytes.into());
4316
4317 if let common::Retry::After(d) =
4318 dlg.http_failure(&response, error.as_ref().ok())
4319 {
4320 sleep(d).await;
4321 continue;
4322 }
4323
4324 dlg.finished(false);
4325
4326 return Err(match error {
4327 Ok(value) => common::Error::BadRequest(value),
4328 _ => common::Error::Failure(response),
4329 });
4330 }
4331 let response = {
4332 let bytes = common::to_bytes(body).await.unwrap_or_default();
4333 let encoded = common::to_string(&bytes);
4334 match serde_json::from_str(&encoded) {
4335 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4336 Err(error) => {
4337 dlg.response_json_decode_error(&encoded, &error);
4338 return Err(common::Error::JsonDecodeError(
4339 encoded.to_string(),
4340 error,
4341 ));
4342 }
4343 }
4344 };
4345
4346 dlg.finished(true);
4347 return Ok(response);
4348 }
4349 }
4350 }
4351 }
4352
4353 ///
4354 /// Sets the *request* property to the given value.
4355 ///
4356 /// Even though the property as already been set when instantiating this call,
4357 /// we provide this method for API completeness.
4358 pub fn request(
4359 mut self,
4360 new_value: ExportInstanceRequest,
4361 ) -> ProjectLocationInstanceExportCall<'a, C> {
4362 self._request = new_value;
4363 self
4364 }
4365 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
4366 ///
4367 /// Sets the *name* path property to the given value.
4368 ///
4369 /// Even though the property as already been set when instantiating this call,
4370 /// we provide this method for API completeness.
4371 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceExportCall<'a, C> {
4372 self._name = new_value.to_string();
4373 self
4374 }
4375 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4376 /// while executing the actual API request.
4377 ///
4378 /// ````text
4379 /// It should be used to handle progress information, and to implement a certain level of resilience.
4380 /// ````
4381 ///
4382 /// Sets the *delegate* property to the given value.
4383 pub fn delegate(
4384 mut self,
4385 new_value: &'a mut dyn common::Delegate,
4386 ) -> ProjectLocationInstanceExportCall<'a, C> {
4387 self._delegate = Some(new_value);
4388 self
4389 }
4390
4391 /// Set any additional parameter of the query string used in the request.
4392 /// It should be used to set parameters which are not yet available through their own
4393 /// setters.
4394 ///
4395 /// Please note that this method must not be used to set any of the known parameters
4396 /// which have their own setter method. If done anyway, the request will fail.
4397 ///
4398 /// # Additional Parameters
4399 ///
4400 /// * *$.xgafv* (query-string) - V1 error format.
4401 /// * *access_token* (query-string) - OAuth access token.
4402 /// * *alt* (query-string) - Data format for response.
4403 /// * *callback* (query-string) - JSONP
4404 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4405 /// * *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.
4406 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4407 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4408 /// * *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.
4409 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4410 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4411 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceExportCall<'a, C>
4412 where
4413 T: AsRef<str>,
4414 {
4415 self._additional_params
4416 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4417 self
4418 }
4419
4420 /// Identifies the authorization scope for the method you are building.
4421 ///
4422 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4423 /// [`Scope::CloudPlatform`].
4424 ///
4425 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4426 /// tokens for more than one scope.
4427 ///
4428 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4429 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4430 /// sufficient, a read-write scope will do as well.
4431 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceExportCall<'a, C>
4432 where
4433 St: AsRef<str>,
4434 {
4435 self._scopes.insert(String::from(scope.as_ref()));
4436 self
4437 }
4438 /// Identifies the authorization scope(s) for the method you are building.
4439 ///
4440 /// See [`Self::add_scope()`] for details.
4441 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceExportCall<'a, C>
4442 where
4443 I: IntoIterator<Item = St>,
4444 St: AsRef<str>,
4445 {
4446 self._scopes
4447 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4448 self
4449 }
4450
4451 /// Removes all scopes, and no default scope will be used either.
4452 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4453 /// for details).
4454 pub fn clear_scopes(mut self) -> ProjectLocationInstanceExportCall<'a, C> {
4455 self._scopes.clear();
4456 self
4457 }
4458}
4459
4460/// Initiates a failover of the primary node to current replica node for a specific STANDARD tier Cloud Memorystore for Redis instance.
4461///
4462/// A builder for the *locations.instances.failover* method supported by a *project* resource.
4463/// It is not used directly, but through a [`ProjectMethods`] instance.
4464///
4465/// # Example
4466///
4467/// Instantiate a resource method builder
4468///
4469/// ```test_harness,no_run
4470/// # extern crate hyper;
4471/// # extern crate hyper_rustls;
4472/// # extern crate google_redis1 as redis1;
4473/// use redis1::api::FailoverInstanceRequest;
4474/// # async fn dox() {
4475/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4476///
4477/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4478/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4479/// # secret,
4480/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4481/// # ).build().await.unwrap();
4482///
4483/// # let client = hyper_util::client::legacy::Client::builder(
4484/// # hyper_util::rt::TokioExecutor::new()
4485/// # )
4486/// # .build(
4487/// # hyper_rustls::HttpsConnectorBuilder::new()
4488/// # .with_native_roots()
4489/// # .unwrap()
4490/// # .https_or_http()
4491/// # .enable_http1()
4492/// # .build()
4493/// # );
4494/// # let mut hub = CloudRedis::new(client, auth);
4495/// // As the method needs a request, you would usually fill it with the desired information
4496/// // into the respective structure. Some of the parts shown here might not be applicable !
4497/// // Values shown here are possibly random and not representative !
4498/// let mut req = FailoverInstanceRequest::default();
4499///
4500/// // You can configure optional parameters by calling the respective setters at will, and
4501/// // execute the final call using `doit()`.
4502/// // Values shown here are possibly random and not representative !
4503/// let result = hub.projects().locations_instances_failover(req, "name")
4504/// .doit().await;
4505/// # }
4506/// ```
4507pub struct ProjectLocationInstanceFailoverCall<'a, C>
4508where
4509 C: 'a,
4510{
4511 hub: &'a CloudRedis<C>,
4512 _request: FailoverInstanceRequest,
4513 _name: String,
4514 _delegate: Option<&'a mut dyn common::Delegate>,
4515 _additional_params: HashMap<String, String>,
4516 _scopes: BTreeSet<String>,
4517}
4518
4519impl<'a, C> common::CallBuilder for ProjectLocationInstanceFailoverCall<'a, C> {}
4520
4521impl<'a, C> ProjectLocationInstanceFailoverCall<'a, C>
4522where
4523 C: common::Connector,
4524{
4525 /// Perform the operation you have build so far.
4526 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4527 use std::borrow::Cow;
4528 use std::io::{Read, Seek};
4529
4530 use common::{url::Params, ToParts};
4531 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4532
4533 let mut dd = common::DefaultDelegate;
4534 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4535 dlg.begin(common::MethodInfo {
4536 id: "redis.projects.locations.instances.failover",
4537 http_method: hyper::Method::POST,
4538 });
4539
4540 for &field in ["alt", "name"].iter() {
4541 if self._additional_params.contains_key(field) {
4542 dlg.finished(false);
4543 return Err(common::Error::FieldClash(field));
4544 }
4545 }
4546
4547 let mut params = Params::with_capacity(4 + self._additional_params.len());
4548 params.push("name", self._name);
4549
4550 params.extend(self._additional_params.iter());
4551
4552 params.push("alt", "json");
4553 let mut url = self.hub._base_url.clone() + "v1/{+name}:failover";
4554 if self._scopes.is_empty() {
4555 self._scopes
4556 .insert(Scope::CloudPlatform.as_ref().to_string());
4557 }
4558
4559 #[allow(clippy::single_element_loop)]
4560 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4561 url = params.uri_replacement(url, param_name, find_this, true);
4562 }
4563 {
4564 let to_remove = ["name"];
4565 params.remove_params(&to_remove);
4566 }
4567
4568 let url = params.parse_with_url(&url);
4569
4570 let mut json_mime_type = mime::APPLICATION_JSON;
4571 let mut request_value_reader = {
4572 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4573 common::remove_json_null_values(&mut value);
4574 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4575 serde_json::to_writer(&mut dst, &value).unwrap();
4576 dst
4577 };
4578 let request_size = request_value_reader
4579 .seek(std::io::SeekFrom::End(0))
4580 .unwrap();
4581 request_value_reader
4582 .seek(std::io::SeekFrom::Start(0))
4583 .unwrap();
4584
4585 loop {
4586 let token = match self
4587 .hub
4588 .auth
4589 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4590 .await
4591 {
4592 Ok(token) => token,
4593 Err(e) => match dlg.token(e) {
4594 Ok(token) => token,
4595 Err(e) => {
4596 dlg.finished(false);
4597 return Err(common::Error::MissingToken(e));
4598 }
4599 },
4600 };
4601 request_value_reader
4602 .seek(std::io::SeekFrom::Start(0))
4603 .unwrap();
4604 let mut req_result = {
4605 let client = &self.hub.client;
4606 dlg.pre_request();
4607 let mut req_builder = hyper::Request::builder()
4608 .method(hyper::Method::POST)
4609 .uri(url.as_str())
4610 .header(USER_AGENT, self.hub._user_agent.clone());
4611
4612 if let Some(token) = token.as_ref() {
4613 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4614 }
4615
4616 let request = req_builder
4617 .header(CONTENT_TYPE, json_mime_type.to_string())
4618 .header(CONTENT_LENGTH, request_size as u64)
4619 .body(common::to_body(
4620 request_value_reader.get_ref().clone().into(),
4621 ));
4622
4623 client.request(request.unwrap()).await
4624 };
4625
4626 match req_result {
4627 Err(err) => {
4628 if let common::Retry::After(d) = dlg.http_error(&err) {
4629 sleep(d).await;
4630 continue;
4631 }
4632 dlg.finished(false);
4633 return Err(common::Error::HttpError(err));
4634 }
4635 Ok(res) => {
4636 let (mut parts, body) = res.into_parts();
4637 let mut body = common::Body::new(body);
4638 if !parts.status.is_success() {
4639 let bytes = common::to_bytes(body).await.unwrap_or_default();
4640 let error = serde_json::from_str(&common::to_string(&bytes));
4641 let response = common::to_response(parts, bytes.into());
4642
4643 if let common::Retry::After(d) =
4644 dlg.http_failure(&response, error.as_ref().ok())
4645 {
4646 sleep(d).await;
4647 continue;
4648 }
4649
4650 dlg.finished(false);
4651
4652 return Err(match error {
4653 Ok(value) => common::Error::BadRequest(value),
4654 _ => common::Error::Failure(response),
4655 });
4656 }
4657 let response = {
4658 let bytes = common::to_bytes(body).await.unwrap_or_default();
4659 let encoded = common::to_string(&bytes);
4660 match serde_json::from_str(&encoded) {
4661 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4662 Err(error) => {
4663 dlg.response_json_decode_error(&encoded, &error);
4664 return Err(common::Error::JsonDecodeError(
4665 encoded.to_string(),
4666 error,
4667 ));
4668 }
4669 }
4670 };
4671
4672 dlg.finished(true);
4673 return Ok(response);
4674 }
4675 }
4676 }
4677 }
4678
4679 ///
4680 /// Sets the *request* property to the given value.
4681 ///
4682 /// Even though the property as already been set when instantiating this call,
4683 /// we provide this method for API completeness.
4684 pub fn request(
4685 mut self,
4686 new_value: FailoverInstanceRequest,
4687 ) -> ProjectLocationInstanceFailoverCall<'a, C> {
4688 self._request = new_value;
4689 self
4690 }
4691 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
4692 ///
4693 /// Sets the *name* path property to the given value.
4694 ///
4695 /// Even though the property as already been set when instantiating this call,
4696 /// we provide this method for API completeness.
4697 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceFailoverCall<'a, C> {
4698 self._name = new_value.to_string();
4699 self
4700 }
4701 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4702 /// while executing the actual API request.
4703 ///
4704 /// ````text
4705 /// It should be used to handle progress information, and to implement a certain level of resilience.
4706 /// ````
4707 ///
4708 /// Sets the *delegate* property to the given value.
4709 pub fn delegate(
4710 mut self,
4711 new_value: &'a mut dyn common::Delegate,
4712 ) -> ProjectLocationInstanceFailoverCall<'a, C> {
4713 self._delegate = Some(new_value);
4714 self
4715 }
4716
4717 /// Set any additional parameter of the query string used in the request.
4718 /// It should be used to set parameters which are not yet available through their own
4719 /// setters.
4720 ///
4721 /// Please note that this method must not be used to set any of the known parameters
4722 /// which have their own setter method. If done anyway, the request will fail.
4723 ///
4724 /// # Additional Parameters
4725 ///
4726 /// * *$.xgafv* (query-string) - V1 error format.
4727 /// * *access_token* (query-string) - OAuth access token.
4728 /// * *alt* (query-string) - Data format for response.
4729 /// * *callback* (query-string) - JSONP
4730 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4731 /// * *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.
4732 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4733 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4734 /// * *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.
4735 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4736 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4737 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceFailoverCall<'a, C>
4738 where
4739 T: AsRef<str>,
4740 {
4741 self._additional_params
4742 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4743 self
4744 }
4745
4746 /// Identifies the authorization scope for the method you are building.
4747 ///
4748 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4749 /// [`Scope::CloudPlatform`].
4750 ///
4751 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4752 /// tokens for more than one scope.
4753 ///
4754 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4755 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4756 /// sufficient, a read-write scope will do as well.
4757 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceFailoverCall<'a, C>
4758 where
4759 St: AsRef<str>,
4760 {
4761 self._scopes.insert(String::from(scope.as_ref()));
4762 self
4763 }
4764 /// Identifies the authorization scope(s) for the method you are building.
4765 ///
4766 /// See [`Self::add_scope()`] for details.
4767 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceFailoverCall<'a, C>
4768 where
4769 I: IntoIterator<Item = St>,
4770 St: AsRef<str>,
4771 {
4772 self._scopes
4773 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4774 self
4775 }
4776
4777 /// Removes all scopes, and no default scope will be used either.
4778 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4779 /// for details).
4780 pub fn clear_scopes(mut self) -> ProjectLocationInstanceFailoverCall<'a, C> {
4781 self._scopes.clear();
4782 self
4783 }
4784}
4785
4786/// Gets the details of a specific Redis instance.
4787///
4788/// A builder for the *locations.instances.get* method supported by a *project* resource.
4789/// It is not used directly, but through a [`ProjectMethods`] instance.
4790///
4791/// # Example
4792///
4793/// Instantiate a resource method builder
4794///
4795/// ```test_harness,no_run
4796/// # extern crate hyper;
4797/// # extern crate hyper_rustls;
4798/// # extern crate google_redis1 as redis1;
4799/// # async fn dox() {
4800/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4801///
4802/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4804/// # secret,
4805/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4806/// # ).build().await.unwrap();
4807///
4808/// # let client = hyper_util::client::legacy::Client::builder(
4809/// # hyper_util::rt::TokioExecutor::new()
4810/// # )
4811/// # .build(
4812/// # hyper_rustls::HttpsConnectorBuilder::new()
4813/// # .with_native_roots()
4814/// # .unwrap()
4815/// # .https_or_http()
4816/// # .enable_http1()
4817/// # .build()
4818/// # );
4819/// # let mut hub = CloudRedis::new(client, auth);
4820/// // You can configure optional parameters by calling the respective setters at will, and
4821/// // execute the final call using `doit()`.
4822/// // Values shown here are possibly random and not representative !
4823/// let result = hub.projects().locations_instances_get("name")
4824/// .doit().await;
4825/// # }
4826/// ```
4827pub struct ProjectLocationInstanceGetCall<'a, C>
4828where
4829 C: 'a,
4830{
4831 hub: &'a CloudRedis<C>,
4832 _name: String,
4833 _delegate: Option<&'a mut dyn common::Delegate>,
4834 _additional_params: HashMap<String, String>,
4835 _scopes: BTreeSet<String>,
4836}
4837
4838impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
4839
4840impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
4841where
4842 C: common::Connector,
4843{
4844 /// Perform the operation you have build so far.
4845 pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
4846 use std::borrow::Cow;
4847 use std::io::{Read, Seek};
4848
4849 use common::{url::Params, ToParts};
4850 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4851
4852 let mut dd = common::DefaultDelegate;
4853 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4854 dlg.begin(common::MethodInfo {
4855 id: "redis.projects.locations.instances.get",
4856 http_method: hyper::Method::GET,
4857 });
4858
4859 for &field in ["alt", "name"].iter() {
4860 if self._additional_params.contains_key(field) {
4861 dlg.finished(false);
4862 return Err(common::Error::FieldClash(field));
4863 }
4864 }
4865
4866 let mut params = Params::with_capacity(3 + self._additional_params.len());
4867 params.push("name", self._name);
4868
4869 params.extend(self._additional_params.iter());
4870
4871 params.push("alt", "json");
4872 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4873 if self._scopes.is_empty() {
4874 self._scopes
4875 .insert(Scope::CloudPlatform.as_ref().to_string());
4876 }
4877
4878 #[allow(clippy::single_element_loop)]
4879 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4880 url = params.uri_replacement(url, param_name, find_this, true);
4881 }
4882 {
4883 let to_remove = ["name"];
4884 params.remove_params(&to_remove);
4885 }
4886
4887 let url = params.parse_with_url(&url);
4888
4889 loop {
4890 let token = match self
4891 .hub
4892 .auth
4893 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4894 .await
4895 {
4896 Ok(token) => token,
4897 Err(e) => match dlg.token(e) {
4898 Ok(token) => token,
4899 Err(e) => {
4900 dlg.finished(false);
4901 return Err(common::Error::MissingToken(e));
4902 }
4903 },
4904 };
4905 let mut req_result = {
4906 let client = &self.hub.client;
4907 dlg.pre_request();
4908 let mut req_builder = hyper::Request::builder()
4909 .method(hyper::Method::GET)
4910 .uri(url.as_str())
4911 .header(USER_AGENT, self.hub._user_agent.clone());
4912
4913 if let Some(token) = token.as_ref() {
4914 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4915 }
4916
4917 let request = req_builder
4918 .header(CONTENT_LENGTH, 0_u64)
4919 .body(common::to_body::<String>(None));
4920
4921 client.request(request.unwrap()).await
4922 };
4923
4924 match req_result {
4925 Err(err) => {
4926 if let common::Retry::After(d) = dlg.http_error(&err) {
4927 sleep(d).await;
4928 continue;
4929 }
4930 dlg.finished(false);
4931 return Err(common::Error::HttpError(err));
4932 }
4933 Ok(res) => {
4934 let (mut parts, body) = res.into_parts();
4935 let mut body = common::Body::new(body);
4936 if !parts.status.is_success() {
4937 let bytes = common::to_bytes(body).await.unwrap_or_default();
4938 let error = serde_json::from_str(&common::to_string(&bytes));
4939 let response = common::to_response(parts, bytes.into());
4940
4941 if let common::Retry::After(d) =
4942 dlg.http_failure(&response, error.as_ref().ok())
4943 {
4944 sleep(d).await;
4945 continue;
4946 }
4947
4948 dlg.finished(false);
4949
4950 return Err(match error {
4951 Ok(value) => common::Error::BadRequest(value),
4952 _ => common::Error::Failure(response),
4953 });
4954 }
4955 let response = {
4956 let bytes = common::to_bytes(body).await.unwrap_or_default();
4957 let encoded = common::to_string(&bytes);
4958 match serde_json::from_str(&encoded) {
4959 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4960 Err(error) => {
4961 dlg.response_json_decode_error(&encoded, &error);
4962 return Err(common::Error::JsonDecodeError(
4963 encoded.to_string(),
4964 error,
4965 ));
4966 }
4967 }
4968 };
4969
4970 dlg.finished(true);
4971 return Ok(response);
4972 }
4973 }
4974 }
4975 }
4976
4977 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
4978 ///
4979 /// Sets the *name* path property to the given value.
4980 ///
4981 /// Even though the property as already been set when instantiating this call,
4982 /// we provide this method for API completeness.
4983 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
4984 self._name = new_value.to_string();
4985 self
4986 }
4987 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4988 /// while executing the actual API request.
4989 ///
4990 /// ````text
4991 /// It should be used to handle progress information, and to implement a certain level of resilience.
4992 /// ````
4993 ///
4994 /// Sets the *delegate* property to the given value.
4995 pub fn delegate(
4996 mut self,
4997 new_value: &'a mut dyn common::Delegate,
4998 ) -> ProjectLocationInstanceGetCall<'a, C> {
4999 self._delegate = Some(new_value);
5000 self
5001 }
5002
5003 /// Set any additional parameter of the query string used in the request.
5004 /// It should be used to set parameters which are not yet available through their own
5005 /// setters.
5006 ///
5007 /// Please note that this method must not be used to set any of the known parameters
5008 /// which have their own setter method. If done anyway, the request will fail.
5009 ///
5010 /// # Additional Parameters
5011 ///
5012 /// * *$.xgafv* (query-string) - V1 error format.
5013 /// * *access_token* (query-string) - OAuth access token.
5014 /// * *alt* (query-string) - Data format for response.
5015 /// * *callback* (query-string) - JSONP
5016 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5017 /// * *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.
5018 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5019 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5020 /// * *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.
5021 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5022 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5023 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
5024 where
5025 T: AsRef<str>,
5026 {
5027 self._additional_params
5028 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5029 self
5030 }
5031
5032 /// Identifies the authorization scope for the method you are building.
5033 ///
5034 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5035 /// [`Scope::CloudPlatform`].
5036 ///
5037 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5038 /// tokens for more than one scope.
5039 ///
5040 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5041 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5042 /// sufficient, a read-write scope will do as well.
5043 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
5044 where
5045 St: AsRef<str>,
5046 {
5047 self._scopes.insert(String::from(scope.as_ref()));
5048 self
5049 }
5050 /// Identifies the authorization scope(s) for the method you are building.
5051 ///
5052 /// See [`Self::add_scope()`] for details.
5053 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
5054 where
5055 I: IntoIterator<Item = St>,
5056 St: AsRef<str>,
5057 {
5058 self._scopes
5059 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5060 self
5061 }
5062
5063 /// Removes all scopes, and no default scope will be used either.
5064 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5065 /// for details).
5066 pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
5067 self._scopes.clear();
5068 self
5069 }
5070}
5071
5072/// Gets the AUTH string for a Redis instance. If AUTH is not enabled for the instance the response will be empty. This information is not included in the details returned to GetInstance.
5073///
5074/// A builder for the *locations.instances.getAuthString* method supported by a *project* resource.
5075/// It is not used directly, but through a [`ProjectMethods`] instance.
5076///
5077/// # Example
5078///
5079/// Instantiate a resource method builder
5080///
5081/// ```test_harness,no_run
5082/// # extern crate hyper;
5083/// # extern crate hyper_rustls;
5084/// # extern crate google_redis1 as redis1;
5085/// # async fn dox() {
5086/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5087///
5088/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5089/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5090/// # secret,
5091/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5092/// # ).build().await.unwrap();
5093///
5094/// # let client = hyper_util::client::legacy::Client::builder(
5095/// # hyper_util::rt::TokioExecutor::new()
5096/// # )
5097/// # .build(
5098/// # hyper_rustls::HttpsConnectorBuilder::new()
5099/// # .with_native_roots()
5100/// # .unwrap()
5101/// # .https_or_http()
5102/// # .enable_http1()
5103/// # .build()
5104/// # );
5105/// # let mut hub = CloudRedis::new(client, auth);
5106/// // You can configure optional parameters by calling the respective setters at will, and
5107/// // execute the final call using `doit()`.
5108/// // Values shown here are possibly random and not representative !
5109/// let result = hub.projects().locations_instances_get_auth_string("name")
5110/// .doit().await;
5111/// # }
5112/// ```
5113pub struct ProjectLocationInstanceGetAuthStringCall<'a, C>
5114where
5115 C: 'a,
5116{
5117 hub: &'a CloudRedis<C>,
5118 _name: String,
5119 _delegate: Option<&'a mut dyn common::Delegate>,
5120 _additional_params: HashMap<String, String>,
5121 _scopes: BTreeSet<String>,
5122}
5123
5124impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetAuthStringCall<'a, C> {}
5125
5126impl<'a, C> ProjectLocationInstanceGetAuthStringCall<'a, C>
5127where
5128 C: common::Connector,
5129{
5130 /// Perform the operation you have build so far.
5131 pub async fn doit(mut self) -> common::Result<(common::Response, InstanceAuthString)> {
5132 use std::borrow::Cow;
5133 use std::io::{Read, Seek};
5134
5135 use common::{url::Params, ToParts};
5136 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5137
5138 let mut dd = common::DefaultDelegate;
5139 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5140 dlg.begin(common::MethodInfo {
5141 id: "redis.projects.locations.instances.getAuthString",
5142 http_method: hyper::Method::GET,
5143 });
5144
5145 for &field in ["alt", "name"].iter() {
5146 if self._additional_params.contains_key(field) {
5147 dlg.finished(false);
5148 return Err(common::Error::FieldClash(field));
5149 }
5150 }
5151
5152 let mut params = Params::with_capacity(3 + self._additional_params.len());
5153 params.push("name", self._name);
5154
5155 params.extend(self._additional_params.iter());
5156
5157 params.push("alt", "json");
5158 let mut url = self.hub._base_url.clone() + "v1/{+name}/authString";
5159 if self._scopes.is_empty() {
5160 self._scopes
5161 .insert(Scope::CloudPlatform.as_ref().to_string());
5162 }
5163
5164 #[allow(clippy::single_element_loop)]
5165 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5166 url = params.uri_replacement(url, param_name, find_this, true);
5167 }
5168 {
5169 let to_remove = ["name"];
5170 params.remove_params(&to_remove);
5171 }
5172
5173 let url = params.parse_with_url(&url);
5174
5175 loop {
5176 let token = match self
5177 .hub
5178 .auth
5179 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5180 .await
5181 {
5182 Ok(token) => token,
5183 Err(e) => match dlg.token(e) {
5184 Ok(token) => token,
5185 Err(e) => {
5186 dlg.finished(false);
5187 return Err(common::Error::MissingToken(e));
5188 }
5189 },
5190 };
5191 let mut req_result = {
5192 let client = &self.hub.client;
5193 dlg.pre_request();
5194 let mut req_builder = hyper::Request::builder()
5195 .method(hyper::Method::GET)
5196 .uri(url.as_str())
5197 .header(USER_AGENT, self.hub._user_agent.clone());
5198
5199 if let Some(token) = token.as_ref() {
5200 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5201 }
5202
5203 let request = req_builder
5204 .header(CONTENT_LENGTH, 0_u64)
5205 .body(common::to_body::<String>(None));
5206
5207 client.request(request.unwrap()).await
5208 };
5209
5210 match req_result {
5211 Err(err) => {
5212 if let common::Retry::After(d) = dlg.http_error(&err) {
5213 sleep(d).await;
5214 continue;
5215 }
5216 dlg.finished(false);
5217 return Err(common::Error::HttpError(err));
5218 }
5219 Ok(res) => {
5220 let (mut parts, body) = res.into_parts();
5221 let mut body = common::Body::new(body);
5222 if !parts.status.is_success() {
5223 let bytes = common::to_bytes(body).await.unwrap_or_default();
5224 let error = serde_json::from_str(&common::to_string(&bytes));
5225 let response = common::to_response(parts, bytes.into());
5226
5227 if let common::Retry::After(d) =
5228 dlg.http_failure(&response, error.as_ref().ok())
5229 {
5230 sleep(d).await;
5231 continue;
5232 }
5233
5234 dlg.finished(false);
5235
5236 return Err(match error {
5237 Ok(value) => common::Error::BadRequest(value),
5238 _ => common::Error::Failure(response),
5239 });
5240 }
5241 let response = {
5242 let bytes = common::to_bytes(body).await.unwrap_or_default();
5243 let encoded = common::to_string(&bytes);
5244 match serde_json::from_str(&encoded) {
5245 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5246 Err(error) => {
5247 dlg.response_json_decode_error(&encoded, &error);
5248 return Err(common::Error::JsonDecodeError(
5249 encoded.to_string(),
5250 error,
5251 ));
5252 }
5253 }
5254 };
5255
5256 dlg.finished(true);
5257 return Ok(response);
5258 }
5259 }
5260 }
5261 }
5262
5263 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
5264 ///
5265 /// Sets the *name* path property to the given value.
5266 ///
5267 /// Even though the property as already been set when instantiating this call,
5268 /// we provide this method for API completeness.
5269 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetAuthStringCall<'a, C> {
5270 self._name = new_value.to_string();
5271 self
5272 }
5273 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5274 /// while executing the actual API request.
5275 ///
5276 /// ````text
5277 /// It should be used to handle progress information, and to implement a certain level of resilience.
5278 /// ````
5279 ///
5280 /// Sets the *delegate* property to the given value.
5281 pub fn delegate(
5282 mut self,
5283 new_value: &'a mut dyn common::Delegate,
5284 ) -> ProjectLocationInstanceGetAuthStringCall<'a, C> {
5285 self._delegate = Some(new_value);
5286 self
5287 }
5288
5289 /// Set any additional parameter of the query string used in the request.
5290 /// It should be used to set parameters which are not yet available through their own
5291 /// setters.
5292 ///
5293 /// Please note that this method must not be used to set any of the known parameters
5294 /// which have their own setter method. If done anyway, the request will fail.
5295 ///
5296 /// # Additional Parameters
5297 ///
5298 /// * *$.xgafv* (query-string) - V1 error format.
5299 /// * *access_token* (query-string) - OAuth access token.
5300 /// * *alt* (query-string) - Data format for response.
5301 /// * *callback* (query-string) - JSONP
5302 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5303 /// * *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.
5304 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5305 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5306 /// * *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.
5307 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5308 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5309 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetAuthStringCall<'a, C>
5310 where
5311 T: AsRef<str>,
5312 {
5313 self._additional_params
5314 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5315 self
5316 }
5317
5318 /// Identifies the authorization scope for the method you are building.
5319 ///
5320 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5321 /// [`Scope::CloudPlatform`].
5322 ///
5323 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5324 /// tokens for more than one scope.
5325 ///
5326 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5327 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5328 /// sufficient, a read-write scope will do as well.
5329 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetAuthStringCall<'a, C>
5330 where
5331 St: AsRef<str>,
5332 {
5333 self._scopes.insert(String::from(scope.as_ref()));
5334 self
5335 }
5336 /// Identifies the authorization scope(s) for the method you are building.
5337 ///
5338 /// See [`Self::add_scope()`] for details.
5339 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetAuthStringCall<'a, C>
5340 where
5341 I: IntoIterator<Item = St>,
5342 St: AsRef<str>,
5343 {
5344 self._scopes
5345 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5346 self
5347 }
5348
5349 /// Removes all scopes, and no default scope will be used either.
5350 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5351 /// for details).
5352 pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetAuthStringCall<'a, C> {
5353 self._scopes.clear();
5354 self
5355 }
5356}
5357
5358/// Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
5359///
5360/// A builder for the *locations.instances.import* method supported by a *project* resource.
5361/// It is not used directly, but through a [`ProjectMethods`] instance.
5362///
5363/// # Example
5364///
5365/// Instantiate a resource method builder
5366///
5367/// ```test_harness,no_run
5368/// # extern crate hyper;
5369/// # extern crate hyper_rustls;
5370/// # extern crate google_redis1 as redis1;
5371/// use redis1::api::ImportInstanceRequest;
5372/// # async fn dox() {
5373/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5374///
5375/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5376/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5377/// # secret,
5378/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5379/// # ).build().await.unwrap();
5380///
5381/// # let client = hyper_util::client::legacy::Client::builder(
5382/// # hyper_util::rt::TokioExecutor::new()
5383/// # )
5384/// # .build(
5385/// # hyper_rustls::HttpsConnectorBuilder::new()
5386/// # .with_native_roots()
5387/// # .unwrap()
5388/// # .https_or_http()
5389/// # .enable_http1()
5390/// # .build()
5391/// # );
5392/// # let mut hub = CloudRedis::new(client, auth);
5393/// // As the method needs a request, you would usually fill it with the desired information
5394/// // into the respective structure. Some of the parts shown here might not be applicable !
5395/// // Values shown here are possibly random and not representative !
5396/// let mut req = ImportInstanceRequest::default();
5397///
5398/// // You can configure optional parameters by calling the respective setters at will, and
5399/// // execute the final call using `doit()`.
5400/// // Values shown here are possibly random and not representative !
5401/// let result = hub.projects().locations_instances_import(req, "name")
5402/// .doit().await;
5403/// # }
5404/// ```
5405pub struct ProjectLocationInstanceImportCall<'a, C>
5406where
5407 C: 'a,
5408{
5409 hub: &'a CloudRedis<C>,
5410 _request: ImportInstanceRequest,
5411 _name: String,
5412 _delegate: Option<&'a mut dyn common::Delegate>,
5413 _additional_params: HashMap<String, String>,
5414 _scopes: BTreeSet<String>,
5415}
5416
5417impl<'a, C> common::CallBuilder for ProjectLocationInstanceImportCall<'a, C> {}
5418
5419impl<'a, C> ProjectLocationInstanceImportCall<'a, C>
5420where
5421 C: common::Connector,
5422{
5423 /// Perform the operation you have build so far.
5424 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5425 use std::borrow::Cow;
5426 use std::io::{Read, Seek};
5427
5428 use common::{url::Params, ToParts};
5429 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5430
5431 let mut dd = common::DefaultDelegate;
5432 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5433 dlg.begin(common::MethodInfo {
5434 id: "redis.projects.locations.instances.import",
5435 http_method: hyper::Method::POST,
5436 });
5437
5438 for &field in ["alt", "name"].iter() {
5439 if self._additional_params.contains_key(field) {
5440 dlg.finished(false);
5441 return Err(common::Error::FieldClash(field));
5442 }
5443 }
5444
5445 let mut params = Params::with_capacity(4 + self._additional_params.len());
5446 params.push("name", self._name);
5447
5448 params.extend(self._additional_params.iter());
5449
5450 params.push("alt", "json");
5451 let mut url = self.hub._base_url.clone() + "v1/{+name}:import";
5452 if self._scopes.is_empty() {
5453 self._scopes
5454 .insert(Scope::CloudPlatform.as_ref().to_string());
5455 }
5456
5457 #[allow(clippy::single_element_loop)]
5458 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5459 url = params.uri_replacement(url, param_name, find_this, true);
5460 }
5461 {
5462 let to_remove = ["name"];
5463 params.remove_params(&to_remove);
5464 }
5465
5466 let url = params.parse_with_url(&url);
5467
5468 let mut json_mime_type = mime::APPLICATION_JSON;
5469 let mut request_value_reader = {
5470 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5471 common::remove_json_null_values(&mut value);
5472 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5473 serde_json::to_writer(&mut dst, &value).unwrap();
5474 dst
5475 };
5476 let request_size = request_value_reader
5477 .seek(std::io::SeekFrom::End(0))
5478 .unwrap();
5479 request_value_reader
5480 .seek(std::io::SeekFrom::Start(0))
5481 .unwrap();
5482
5483 loop {
5484 let token = match self
5485 .hub
5486 .auth
5487 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5488 .await
5489 {
5490 Ok(token) => token,
5491 Err(e) => match dlg.token(e) {
5492 Ok(token) => token,
5493 Err(e) => {
5494 dlg.finished(false);
5495 return Err(common::Error::MissingToken(e));
5496 }
5497 },
5498 };
5499 request_value_reader
5500 .seek(std::io::SeekFrom::Start(0))
5501 .unwrap();
5502 let mut req_result = {
5503 let client = &self.hub.client;
5504 dlg.pre_request();
5505 let mut req_builder = hyper::Request::builder()
5506 .method(hyper::Method::POST)
5507 .uri(url.as_str())
5508 .header(USER_AGENT, self.hub._user_agent.clone());
5509
5510 if let Some(token) = token.as_ref() {
5511 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5512 }
5513
5514 let request = req_builder
5515 .header(CONTENT_TYPE, json_mime_type.to_string())
5516 .header(CONTENT_LENGTH, request_size as u64)
5517 .body(common::to_body(
5518 request_value_reader.get_ref().clone().into(),
5519 ));
5520
5521 client.request(request.unwrap()).await
5522 };
5523
5524 match req_result {
5525 Err(err) => {
5526 if let common::Retry::After(d) = dlg.http_error(&err) {
5527 sleep(d).await;
5528 continue;
5529 }
5530 dlg.finished(false);
5531 return Err(common::Error::HttpError(err));
5532 }
5533 Ok(res) => {
5534 let (mut parts, body) = res.into_parts();
5535 let mut body = common::Body::new(body);
5536 if !parts.status.is_success() {
5537 let bytes = common::to_bytes(body).await.unwrap_or_default();
5538 let error = serde_json::from_str(&common::to_string(&bytes));
5539 let response = common::to_response(parts, bytes.into());
5540
5541 if let common::Retry::After(d) =
5542 dlg.http_failure(&response, error.as_ref().ok())
5543 {
5544 sleep(d).await;
5545 continue;
5546 }
5547
5548 dlg.finished(false);
5549
5550 return Err(match error {
5551 Ok(value) => common::Error::BadRequest(value),
5552 _ => common::Error::Failure(response),
5553 });
5554 }
5555 let response = {
5556 let bytes = common::to_bytes(body).await.unwrap_or_default();
5557 let encoded = common::to_string(&bytes);
5558 match serde_json::from_str(&encoded) {
5559 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5560 Err(error) => {
5561 dlg.response_json_decode_error(&encoded, &error);
5562 return Err(common::Error::JsonDecodeError(
5563 encoded.to_string(),
5564 error,
5565 ));
5566 }
5567 }
5568 };
5569
5570 dlg.finished(true);
5571 return Ok(response);
5572 }
5573 }
5574 }
5575 }
5576
5577 ///
5578 /// Sets the *request* property to the given value.
5579 ///
5580 /// Even though the property as already been set when instantiating this call,
5581 /// we provide this method for API completeness.
5582 pub fn request(
5583 mut self,
5584 new_value: ImportInstanceRequest,
5585 ) -> ProjectLocationInstanceImportCall<'a, C> {
5586 self._request = new_value;
5587 self
5588 }
5589 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
5590 ///
5591 /// Sets the *name* path property to the given value.
5592 ///
5593 /// Even though the property as already been set when instantiating this call,
5594 /// we provide this method for API completeness.
5595 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceImportCall<'a, C> {
5596 self._name = new_value.to_string();
5597 self
5598 }
5599 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5600 /// while executing the actual API request.
5601 ///
5602 /// ````text
5603 /// It should be used to handle progress information, and to implement a certain level of resilience.
5604 /// ````
5605 ///
5606 /// Sets the *delegate* property to the given value.
5607 pub fn delegate(
5608 mut self,
5609 new_value: &'a mut dyn common::Delegate,
5610 ) -> ProjectLocationInstanceImportCall<'a, C> {
5611 self._delegate = Some(new_value);
5612 self
5613 }
5614
5615 /// Set any additional parameter of the query string used in the request.
5616 /// It should be used to set parameters which are not yet available through their own
5617 /// setters.
5618 ///
5619 /// Please note that this method must not be used to set any of the known parameters
5620 /// which have their own setter method. If done anyway, the request will fail.
5621 ///
5622 /// # Additional Parameters
5623 ///
5624 /// * *$.xgafv* (query-string) - V1 error format.
5625 /// * *access_token* (query-string) - OAuth access token.
5626 /// * *alt* (query-string) - Data format for response.
5627 /// * *callback* (query-string) - JSONP
5628 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5629 /// * *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.
5630 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5631 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5632 /// * *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.
5633 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5634 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5635 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceImportCall<'a, C>
5636 where
5637 T: AsRef<str>,
5638 {
5639 self._additional_params
5640 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5641 self
5642 }
5643
5644 /// Identifies the authorization scope for the method you are building.
5645 ///
5646 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5647 /// [`Scope::CloudPlatform`].
5648 ///
5649 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5650 /// tokens for more than one scope.
5651 ///
5652 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5653 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5654 /// sufficient, a read-write scope will do as well.
5655 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceImportCall<'a, C>
5656 where
5657 St: AsRef<str>,
5658 {
5659 self._scopes.insert(String::from(scope.as_ref()));
5660 self
5661 }
5662 /// Identifies the authorization scope(s) for the method you are building.
5663 ///
5664 /// See [`Self::add_scope()`] for details.
5665 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceImportCall<'a, C>
5666 where
5667 I: IntoIterator<Item = St>,
5668 St: AsRef<str>,
5669 {
5670 self._scopes
5671 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5672 self
5673 }
5674
5675 /// Removes all scopes, and no default scope will be used either.
5676 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5677 /// for details).
5678 pub fn clear_scopes(mut self) -> ProjectLocationInstanceImportCall<'a, C> {
5679 self._scopes.clear();
5680 self
5681 }
5682}
5683
5684/// Lists all Redis instances owned by a project in either the specified location (region) or all locations. The location should have the following format: * `projects/{project_id}/locations/{location_id}` If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
5685///
5686/// A builder for the *locations.instances.list* method supported by a *project* resource.
5687/// It is not used directly, but through a [`ProjectMethods`] instance.
5688///
5689/// # Example
5690///
5691/// Instantiate a resource method builder
5692///
5693/// ```test_harness,no_run
5694/// # extern crate hyper;
5695/// # extern crate hyper_rustls;
5696/// # extern crate google_redis1 as redis1;
5697/// # async fn dox() {
5698/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5699///
5700/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5701/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5702/// # secret,
5703/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5704/// # ).build().await.unwrap();
5705///
5706/// # let client = hyper_util::client::legacy::Client::builder(
5707/// # hyper_util::rt::TokioExecutor::new()
5708/// # )
5709/// # .build(
5710/// # hyper_rustls::HttpsConnectorBuilder::new()
5711/// # .with_native_roots()
5712/// # .unwrap()
5713/// # .https_or_http()
5714/// # .enable_http1()
5715/// # .build()
5716/// # );
5717/// # let mut hub = CloudRedis::new(client, auth);
5718/// // You can configure optional parameters by calling the respective setters at will, and
5719/// // execute the final call using `doit()`.
5720/// // Values shown here are possibly random and not representative !
5721/// let result = hub.projects().locations_instances_list("parent")
5722/// .page_token("ipsum")
5723/// .page_size(-7)
5724/// .doit().await;
5725/// # }
5726/// ```
5727pub struct ProjectLocationInstanceListCall<'a, C>
5728where
5729 C: 'a,
5730{
5731 hub: &'a CloudRedis<C>,
5732 _parent: String,
5733 _page_token: Option<String>,
5734 _page_size: Option<i32>,
5735 _delegate: Option<&'a mut dyn common::Delegate>,
5736 _additional_params: HashMap<String, String>,
5737 _scopes: BTreeSet<String>,
5738}
5739
5740impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
5741
5742impl<'a, C> ProjectLocationInstanceListCall<'a, C>
5743where
5744 C: common::Connector,
5745{
5746 /// Perform the operation you have build so far.
5747 pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
5748 use std::borrow::Cow;
5749 use std::io::{Read, Seek};
5750
5751 use common::{url::Params, ToParts};
5752 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5753
5754 let mut dd = common::DefaultDelegate;
5755 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5756 dlg.begin(common::MethodInfo {
5757 id: "redis.projects.locations.instances.list",
5758 http_method: hyper::Method::GET,
5759 });
5760
5761 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5762 if self._additional_params.contains_key(field) {
5763 dlg.finished(false);
5764 return Err(common::Error::FieldClash(field));
5765 }
5766 }
5767
5768 let mut params = Params::with_capacity(5 + self._additional_params.len());
5769 params.push("parent", self._parent);
5770 if let Some(value) = self._page_token.as_ref() {
5771 params.push("pageToken", value);
5772 }
5773 if let Some(value) = self._page_size.as_ref() {
5774 params.push("pageSize", value.to_string());
5775 }
5776
5777 params.extend(self._additional_params.iter());
5778
5779 params.push("alt", "json");
5780 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
5781 if self._scopes.is_empty() {
5782 self._scopes
5783 .insert(Scope::CloudPlatform.as_ref().to_string());
5784 }
5785
5786 #[allow(clippy::single_element_loop)]
5787 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5788 url = params.uri_replacement(url, param_name, find_this, true);
5789 }
5790 {
5791 let to_remove = ["parent"];
5792 params.remove_params(&to_remove);
5793 }
5794
5795 let url = params.parse_with_url(&url);
5796
5797 loop {
5798 let token = match self
5799 .hub
5800 .auth
5801 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5802 .await
5803 {
5804 Ok(token) => token,
5805 Err(e) => match dlg.token(e) {
5806 Ok(token) => token,
5807 Err(e) => {
5808 dlg.finished(false);
5809 return Err(common::Error::MissingToken(e));
5810 }
5811 },
5812 };
5813 let mut req_result = {
5814 let client = &self.hub.client;
5815 dlg.pre_request();
5816 let mut req_builder = hyper::Request::builder()
5817 .method(hyper::Method::GET)
5818 .uri(url.as_str())
5819 .header(USER_AGENT, self.hub._user_agent.clone());
5820
5821 if let Some(token) = token.as_ref() {
5822 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5823 }
5824
5825 let request = req_builder
5826 .header(CONTENT_LENGTH, 0_u64)
5827 .body(common::to_body::<String>(None));
5828
5829 client.request(request.unwrap()).await
5830 };
5831
5832 match req_result {
5833 Err(err) => {
5834 if let common::Retry::After(d) = dlg.http_error(&err) {
5835 sleep(d).await;
5836 continue;
5837 }
5838 dlg.finished(false);
5839 return Err(common::Error::HttpError(err));
5840 }
5841 Ok(res) => {
5842 let (mut parts, body) = res.into_parts();
5843 let mut body = common::Body::new(body);
5844 if !parts.status.is_success() {
5845 let bytes = common::to_bytes(body).await.unwrap_or_default();
5846 let error = serde_json::from_str(&common::to_string(&bytes));
5847 let response = common::to_response(parts, bytes.into());
5848
5849 if let common::Retry::After(d) =
5850 dlg.http_failure(&response, error.as_ref().ok())
5851 {
5852 sleep(d).await;
5853 continue;
5854 }
5855
5856 dlg.finished(false);
5857
5858 return Err(match error {
5859 Ok(value) => common::Error::BadRequest(value),
5860 _ => common::Error::Failure(response),
5861 });
5862 }
5863 let response = {
5864 let bytes = common::to_bytes(body).await.unwrap_or_default();
5865 let encoded = common::to_string(&bytes);
5866 match serde_json::from_str(&encoded) {
5867 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5868 Err(error) => {
5869 dlg.response_json_decode_error(&encoded, &error);
5870 return Err(common::Error::JsonDecodeError(
5871 encoded.to_string(),
5872 error,
5873 ));
5874 }
5875 }
5876 };
5877
5878 dlg.finished(true);
5879 return Ok(response);
5880 }
5881 }
5882 }
5883 }
5884
5885 /// 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.
5886 ///
5887 /// Sets the *parent* path property to the given value.
5888 ///
5889 /// Even though the property as already been set when instantiating this call,
5890 /// we provide this method for API completeness.
5891 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5892 self._parent = new_value.to_string();
5893 self
5894 }
5895 /// The `next_page_token` value returned from a previous ListInstances request, if any.
5896 ///
5897 /// Sets the *page token* query property to the given value.
5898 pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5899 self._page_token = Some(new_value.to_string());
5900 self
5901 }
5902 /// 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.
5903 ///
5904 /// Sets the *page size* query property to the given value.
5905 pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
5906 self._page_size = Some(new_value);
5907 self
5908 }
5909 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5910 /// while executing the actual API request.
5911 ///
5912 /// ````text
5913 /// It should be used to handle progress information, and to implement a certain level of resilience.
5914 /// ````
5915 ///
5916 /// Sets the *delegate* property to the given value.
5917 pub fn delegate(
5918 mut self,
5919 new_value: &'a mut dyn common::Delegate,
5920 ) -> ProjectLocationInstanceListCall<'a, C> {
5921 self._delegate = Some(new_value);
5922 self
5923 }
5924
5925 /// Set any additional parameter of the query string used in the request.
5926 /// It should be used to set parameters which are not yet available through their own
5927 /// setters.
5928 ///
5929 /// Please note that this method must not be used to set any of the known parameters
5930 /// which have their own setter method. If done anyway, the request will fail.
5931 ///
5932 /// # Additional Parameters
5933 ///
5934 /// * *$.xgafv* (query-string) - V1 error format.
5935 /// * *access_token* (query-string) - OAuth access token.
5936 /// * *alt* (query-string) - Data format for response.
5937 /// * *callback* (query-string) - JSONP
5938 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5939 /// * *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.
5940 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5941 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5942 /// * *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.
5943 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5944 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5945 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
5946 where
5947 T: AsRef<str>,
5948 {
5949 self._additional_params
5950 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5951 self
5952 }
5953
5954 /// Identifies the authorization scope for the method you are building.
5955 ///
5956 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5957 /// [`Scope::CloudPlatform`].
5958 ///
5959 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5960 /// tokens for more than one scope.
5961 ///
5962 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5963 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5964 /// sufficient, a read-write scope will do as well.
5965 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
5966 where
5967 St: AsRef<str>,
5968 {
5969 self._scopes.insert(String::from(scope.as_ref()));
5970 self
5971 }
5972 /// Identifies the authorization scope(s) for the method you are building.
5973 ///
5974 /// See [`Self::add_scope()`] for details.
5975 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
5976 where
5977 I: IntoIterator<Item = St>,
5978 St: AsRef<str>,
5979 {
5980 self._scopes
5981 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5982 self
5983 }
5984
5985 /// Removes all scopes, and no default scope will be used either.
5986 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5987 /// for details).
5988 pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
5989 self._scopes.clear();
5990 self
5991 }
5992}
5993
5994/// Updates the metadata and configuration of a specific Redis instance. Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
5995///
5996/// A builder for the *locations.instances.patch* method supported by a *project* resource.
5997/// It is not used directly, but through a [`ProjectMethods`] instance.
5998///
5999/// # Example
6000///
6001/// Instantiate a resource method builder
6002///
6003/// ```test_harness,no_run
6004/// # extern crate hyper;
6005/// # extern crate hyper_rustls;
6006/// # extern crate google_redis1 as redis1;
6007/// use redis1::api::Instance;
6008/// # async fn dox() {
6009/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6010///
6011/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6012/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6013/// # secret,
6014/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6015/// # ).build().await.unwrap();
6016///
6017/// # let client = hyper_util::client::legacy::Client::builder(
6018/// # hyper_util::rt::TokioExecutor::new()
6019/// # )
6020/// # .build(
6021/// # hyper_rustls::HttpsConnectorBuilder::new()
6022/// # .with_native_roots()
6023/// # .unwrap()
6024/// # .https_or_http()
6025/// # .enable_http1()
6026/// # .build()
6027/// # );
6028/// # let mut hub = CloudRedis::new(client, auth);
6029/// // As the method needs a request, you would usually fill it with the desired information
6030/// // into the respective structure. Some of the parts shown here might not be applicable !
6031/// // Values shown here are possibly random and not representative !
6032/// let mut req = Instance::default();
6033///
6034/// // You can configure optional parameters by calling the respective setters at will, and
6035/// // execute the final call using `doit()`.
6036/// // Values shown here are possibly random and not representative !
6037/// let result = hub.projects().locations_instances_patch(req, "name")
6038/// .update_mask(FieldMask::new::<&str>(&[]))
6039/// .doit().await;
6040/// # }
6041/// ```
6042pub struct ProjectLocationInstancePatchCall<'a, C>
6043where
6044 C: 'a,
6045{
6046 hub: &'a CloudRedis<C>,
6047 _request: Instance,
6048 _name: String,
6049 _update_mask: Option<common::FieldMask>,
6050 _delegate: Option<&'a mut dyn common::Delegate>,
6051 _additional_params: HashMap<String, String>,
6052 _scopes: BTreeSet<String>,
6053}
6054
6055impl<'a, C> common::CallBuilder for ProjectLocationInstancePatchCall<'a, C> {}
6056
6057impl<'a, C> ProjectLocationInstancePatchCall<'a, C>
6058where
6059 C: common::Connector,
6060{
6061 /// Perform the operation you have build so far.
6062 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6063 use std::borrow::Cow;
6064 use std::io::{Read, Seek};
6065
6066 use common::{url::Params, ToParts};
6067 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6068
6069 let mut dd = common::DefaultDelegate;
6070 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6071 dlg.begin(common::MethodInfo {
6072 id: "redis.projects.locations.instances.patch",
6073 http_method: hyper::Method::PATCH,
6074 });
6075
6076 for &field in ["alt", "name", "updateMask"].iter() {
6077 if self._additional_params.contains_key(field) {
6078 dlg.finished(false);
6079 return Err(common::Error::FieldClash(field));
6080 }
6081 }
6082
6083 let mut params = Params::with_capacity(5 + self._additional_params.len());
6084 params.push("name", self._name);
6085 if let Some(value) = self._update_mask.as_ref() {
6086 params.push("updateMask", value.to_string());
6087 }
6088
6089 params.extend(self._additional_params.iter());
6090
6091 params.push("alt", "json");
6092 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6093 if self._scopes.is_empty() {
6094 self._scopes
6095 .insert(Scope::CloudPlatform.as_ref().to_string());
6096 }
6097
6098 #[allow(clippy::single_element_loop)]
6099 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6100 url = params.uri_replacement(url, param_name, find_this, true);
6101 }
6102 {
6103 let to_remove = ["name"];
6104 params.remove_params(&to_remove);
6105 }
6106
6107 let url = params.parse_with_url(&url);
6108
6109 let mut json_mime_type = mime::APPLICATION_JSON;
6110 let mut request_value_reader = {
6111 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6112 common::remove_json_null_values(&mut value);
6113 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6114 serde_json::to_writer(&mut dst, &value).unwrap();
6115 dst
6116 };
6117 let request_size = request_value_reader
6118 .seek(std::io::SeekFrom::End(0))
6119 .unwrap();
6120 request_value_reader
6121 .seek(std::io::SeekFrom::Start(0))
6122 .unwrap();
6123
6124 loop {
6125 let token = match self
6126 .hub
6127 .auth
6128 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6129 .await
6130 {
6131 Ok(token) => token,
6132 Err(e) => match dlg.token(e) {
6133 Ok(token) => token,
6134 Err(e) => {
6135 dlg.finished(false);
6136 return Err(common::Error::MissingToken(e));
6137 }
6138 },
6139 };
6140 request_value_reader
6141 .seek(std::io::SeekFrom::Start(0))
6142 .unwrap();
6143 let mut req_result = {
6144 let client = &self.hub.client;
6145 dlg.pre_request();
6146 let mut req_builder = hyper::Request::builder()
6147 .method(hyper::Method::PATCH)
6148 .uri(url.as_str())
6149 .header(USER_AGENT, self.hub._user_agent.clone());
6150
6151 if let Some(token) = token.as_ref() {
6152 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6153 }
6154
6155 let request = req_builder
6156 .header(CONTENT_TYPE, json_mime_type.to_string())
6157 .header(CONTENT_LENGTH, request_size as u64)
6158 .body(common::to_body(
6159 request_value_reader.get_ref().clone().into(),
6160 ));
6161
6162 client.request(request.unwrap()).await
6163 };
6164
6165 match req_result {
6166 Err(err) => {
6167 if let common::Retry::After(d) = dlg.http_error(&err) {
6168 sleep(d).await;
6169 continue;
6170 }
6171 dlg.finished(false);
6172 return Err(common::Error::HttpError(err));
6173 }
6174 Ok(res) => {
6175 let (mut parts, body) = res.into_parts();
6176 let mut body = common::Body::new(body);
6177 if !parts.status.is_success() {
6178 let bytes = common::to_bytes(body).await.unwrap_or_default();
6179 let error = serde_json::from_str(&common::to_string(&bytes));
6180 let response = common::to_response(parts, bytes.into());
6181
6182 if let common::Retry::After(d) =
6183 dlg.http_failure(&response, error.as_ref().ok())
6184 {
6185 sleep(d).await;
6186 continue;
6187 }
6188
6189 dlg.finished(false);
6190
6191 return Err(match error {
6192 Ok(value) => common::Error::BadRequest(value),
6193 _ => common::Error::Failure(response),
6194 });
6195 }
6196 let response = {
6197 let bytes = common::to_bytes(body).await.unwrap_or_default();
6198 let encoded = common::to_string(&bytes);
6199 match serde_json::from_str(&encoded) {
6200 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6201 Err(error) => {
6202 dlg.response_json_decode_error(&encoded, &error);
6203 return Err(common::Error::JsonDecodeError(
6204 encoded.to_string(),
6205 error,
6206 ));
6207 }
6208 }
6209 };
6210
6211 dlg.finished(true);
6212 return Ok(response);
6213 }
6214 }
6215 }
6216 }
6217
6218 ///
6219 /// Sets the *request* property to the given value.
6220 ///
6221 /// Even though the property as already been set when instantiating this call,
6222 /// we provide this method for API completeness.
6223 pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, C> {
6224 self._request = new_value;
6225 self
6226 }
6227 /// 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: Redis instances are managed and addressed at regional level so location_id here refers to a GCP region; however, users may choose which specific zone (or collection of zones for cross-zone instances) an instance should be provisioned in. Refer to location_id and alternative_location_id fields for more details.
6228 ///
6229 /// Sets the *name* path property to the given value.
6230 ///
6231 /// Even though the property as already been set when instantiating this call,
6232 /// we provide this method for API completeness.
6233 pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, C> {
6234 self._name = new_value.to_string();
6235 self
6236 }
6237 /// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields from Instance: * `displayName` * `labels` * `memorySizeGb` * `redisConfig` * `replica_count`
6238 ///
6239 /// Sets the *update mask* query property to the given value.
6240 pub fn update_mask(
6241 mut self,
6242 new_value: common::FieldMask,
6243 ) -> ProjectLocationInstancePatchCall<'a, C> {
6244 self._update_mask = Some(new_value);
6245 self
6246 }
6247 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6248 /// while executing the actual API request.
6249 ///
6250 /// ````text
6251 /// It should be used to handle progress information, and to implement a certain level of resilience.
6252 /// ````
6253 ///
6254 /// Sets the *delegate* property to the given value.
6255 pub fn delegate(
6256 mut self,
6257 new_value: &'a mut dyn common::Delegate,
6258 ) -> ProjectLocationInstancePatchCall<'a, C> {
6259 self._delegate = Some(new_value);
6260 self
6261 }
6262
6263 /// Set any additional parameter of the query string used in the request.
6264 /// It should be used to set parameters which are not yet available through their own
6265 /// setters.
6266 ///
6267 /// Please note that this method must not be used to set any of the known parameters
6268 /// which have their own setter method. If done anyway, the request will fail.
6269 ///
6270 /// # Additional Parameters
6271 ///
6272 /// * *$.xgafv* (query-string) - V1 error format.
6273 /// * *access_token* (query-string) - OAuth access token.
6274 /// * *alt* (query-string) - Data format for response.
6275 /// * *callback* (query-string) - JSONP
6276 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6277 /// * *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.
6278 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6279 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6280 /// * *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.
6281 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6282 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6283 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, C>
6284 where
6285 T: AsRef<str>,
6286 {
6287 self._additional_params
6288 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6289 self
6290 }
6291
6292 /// Identifies the authorization scope for the method you are building.
6293 ///
6294 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6295 /// [`Scope::CloudPlatform`].
6296 ///
6297 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6298 /// tokens for more than one scope.
6299 ///
6300 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6301 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6302 /// sufficient, a read-write scope will do as well.
6303 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, C>
6304 where
6305 St: AsRef<str>,
6306 {
6307 self._scopes.insert(String::from(scope.as_ref()));
6308 self
6309 }
6310 /// Identifies the authorization scope(s) for the method you are building.
6311 ///
6312 /// See [`Self::add_scope()`] for details.
6313 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, C>
6314 where
6315 I: IntoIterator<Item = St>,
6316 St: AsRef<str>,
6317 {
6318 self._scopes
6319 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6320 self
6321 }
6322
6323 /// Removes all scopes, and no default scope will be used either.
6324 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6325 /// for details).
6326 pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, C> {
6327 self._scopes.clear();
6328 self
6329 }
6330}
6331
6332/// Reschedule maintenance for a given instance in a given project and location.
6333///
6334/// A builder for the *locations.instances.rescheduleMaintenance* method supported by a *project* resource.
6335/// It is not used directly, but through a [`ProjectMethods`] instance.
6336///
6337/// # Example
6338///
6339/// Instantiate a resource method builder
6340///
6341/// ```test_harness,no_run
6342/// # extern crate hyper;
6343/// # extern crate hyper_rustls;
6344/// # extern crate google_redis1 as redis1;
6345/// use redis1::api::RescheduleMaintenanceRequest;
6346/// # async fn dox() {
6347/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6348///
6349/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6350/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6351/// # secret,
6352/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6353/// # ).build().await.unwrap();
6354///
6355/// # let client = hyper_util::client::legacy::Client::builder(
6356/// # hyper_util::rt::TokioExecutor::new()
6357/// # )
6358/// # .build(
6359/// # hyper_rustls::HttpsConnectorBuilder::new()
6360/// # .with_native_roots()
6361/// # .unwrap()
6362/// # .https_or_http()
6363/// # .enable_http1()
6364/// # .build()
6365/// # );
6366/// # let mut hub = CloudRedis::new(client, auth);
6367/// // As the method needs a request, you would usually fill it with the desired information
6368/// // into the respective structure. Some of the parts shown here might not be applicable !
6369/// // Values shown here are possibly random and not representative !
6370/// let mut req = RescheduleMaintenanceRequest::default();
6371///
6372/// // You can configure optional parameters by calling the respective setters at will, and
6373/// // execute the final call using `doit()`.
6374/// // Values shown here are possibly random and not representative !
6375/// let result = hub.projects().locations_instances_reschedule_maintenance(req, "name")
6376/// .doit().await;
6377/// # }
6378/// ```
6379pub struct ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
6380where
6381 C: 'a,
6382{
6383 hub: &'a CloudRedis<C>,
6384 _request: RescheduleMaintenanceRequest,
6385 _name: String,
6386 _delegate: Option<&'a mut dyn common::Delegate>,
6387 _additional_params: HashMap<String, String>,
6388 _scopes: BTreeSet<String>,
6389}
6390
6391impl<'a, C> common::CallBuilder for ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {}
6392
6393impl<'a, C> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
6394where
6395 C: common::Connector,
6396{
6397 /// Perform the operation you have build so far.
6398 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6399 use std::borrow::Cow;
6400 use std::io::{Read, Seek};
6401
6402 use common::{url::Params, ToParts};
6403 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6404
6405 let mut dd = common::DefaultDelegate;
6406 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6407 dlg.begin(common::MethodInfo {
6408 id: "redis.projects.locations.instances.rescheduleMaintenance",
6409 http_method: hyper::Method::POST,
6410 });
6411
6412 for &field in ["alt", "name"].iter() {
6413 if self._additional_params.contains_key(field) {
6414 dlg.finished(false);
6415 return Err(common::Error::FieldClash(field));
6416 }
6417 }
6418
6419 let mut params = Params::with_capacity(4 + self._additional_params.len());
6420 params.push("name", self._name);
6421
6422 params.extend(self._additional_params.iter());
6423
6424 params.push("alt", "json");
6425 let mut url = self.hub._base_url.clone() + "v1/{+name}:rescheduleMaintenance";
6426 if self._scopes.is_empty() {
6427 self._scopes
6428 .insert(Scope::CloudPlatform.as_ref().to_string());
6429 }
6430
6431 #[allow(clippy::single_element_loop)]
6432 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6433 url = params.uri_replacement(url, param_name, find_this, true);
6434 }
6435 {
6436 let to_remove = ["name"];
6437 params.remove_params(&to_remove);
6438 }
6439
6440 let url = params.parse_with_url(&url);
6441
6442 let mut json_mime_type = mime::APPLICATION_JSON;
6443 let mut request_value_reader = {
6444 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6445 common::remove_json_null_values(&mut value);
6446 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6447 serde_json::to_writer(&mut dst, &value).unwrap();
6448 dst
6449 };
6450 let request_size = request_value_reader
6451 .seek(std::io::SeekFrom::End(0))
6452 .unwrap();
6453 request_value_reader
6454 .seek(std::io::SeekFrom::Start(0))
6455 .unwrap();
6456
6457 loop {
6458 let token = match self
6459 .hub
6460 .auth
6461 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6462 .await
6463 {
6464 Ok(token) => token,
6465 Err(e) => match dlg.token(e) {
6466 Ok(token) => token,
6467 Err(e) => {
6468 dlg.finished(false);
6469 return Err(common::Error::MissingToken(e));
6470 }
6471 },
6472 };
6473 request_value_reader
6474 .seek(std::io::SeekFrom::Start(0))
6475 .unwrap();
6476 let mut req_result = {
6477 let client = &self.hub.client;
6478 dlg.pre_request();
6479 let mut req_builder = hyper::Request::builder()
6480 .method(hyper::Method::POST)
6481 .uri(url.as_str())
6482 .header(USER_AGENT, self.hub._user_agent.clone());
6483
6484 if let Some(token) = token.as_ref() {
6485 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6486 }
6487
6488 let request = req_builder
6489 .header(CONTENT_TYPE, json_mime_type.to_string())
6490 .header(CONTENT_LENGTH, request_size as u64)
6491 .body(common::to_body(
6492 request_value_reader.get_ref().clone().into(),
6493 ));
6494
6495 client.request(request.unwrap()).await
6496 };
6497
6498 match req_result {
6499 Err(err) => {
6500 if let common::Retry::After(d) = dlg.http_error(&err) {
6501 sleep(d).await;
6502 continue;
6503 }
6504 dlg.finished(false);
6505 return Err(common::Error::HttpError(err));
6506 }
6507 Ok(res) => {
6508 let (mut parts, body) = res.into_parts();
6509 let mut body = common::Body::new(body);
6510 if !parts.status.is_success() {
6511 let bytes = common::to_bytes(body).await.unwrap_or_default();
6512 let error = serde_json::from_str(&common::to_string(&bytes));
6513 let response = common::to_response(parts, bytes.into());
6514
6515 if let common::Retry::After(d) =
6516 dlg.http_failure(&response, error.as_ref().ok())
6517 {
6518 sleep(d).await;
6519 continue;
6520 }
6521
6522 dlg.finished(false);
6523
6524 return Err(match error {
6525 Ok(value) => common::Error::BadRequest(value),
6526 _ => common::Error::Failure(response),
6527 });
6528 }
6529 let response = {
6530 let bytes = common::to_bytes(body).await.unwrap_or_default();
6531 let encoded = common::to_string(&bytes);
6532 match serde_json::from_str(&encoded) {
6533 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6534 Err(error) => {
6535 dlg.response_json_decode_error(&encoded, &error);
6536 return Err(common::Error::JsonDecodeError(
6537 encoded.to_string(),
6538 error,
6539 ));
6540 }
6541 }
6542 };
6543
6544 dlg.finished(true);
6545 return Ok(response);
6546 }
6547 }
6548 }
6549 }
6550
6551 ///
6552 /// Sets the *request* property to the given value.
6553 ///
6554 /// Even though the property as already been set when instantiating this call,
6555 /// we provide this method for API completeness.
6556 pub fn request(
6557 mut self,
6558 new_value: RescheduleMaintenanceRequest,
6559 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
6560 self._request = new_value;
6561 self
6562 }
6563 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
6564 ///
6565 /// Sets the *name* path property to the given value.
6566 ///
6567 /// Even though the property as already been set when instantiating this call,
6568 /// we provide this method for API completeness.
6569 pub fn name(
6570 mut self,
6571 new_value: &str,
6572 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
6573 self._name = new_value.to_string();
6574 self
6575 }
6576 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6577 /// while executing the actual API request.
6578 ///
6579 /// ````text
6580 /// It should be used to handle progress information, and to implement a certain level of resilience.
6581 /// ````
6582 ///
6583 /// Sets the *delegate* property to the given value.
6584 pub fn delegate(
6585 mut self,
6586 new_value: &'a mut dyn common::Delegate,
6587 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
6588 self._delegate = Some(new_value);
6589 self
6590 }
6591
6592 /// Set any additional parameter of the query string used in the request.
6593 /// It should be used to set parameters which are not yet available through their own
6594 /// setters.
6595 ///
6596 /// Please note that this method must not be used to set any of the known parameters
6597 /// which have their own setter method. If done anyway, the request will fail.
6598 ///
6599 /// # Additional Parameters
6600 ///
6601 /// * *$.xgafv* (query-string) - V1 error format.
6602 /// * *access_token* (query-string) - OAuth access token.
6603 /// * *alt* (query-string) - Data format for response.
6604 /// * *callback* (query-string) - JSONP
6605 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6606 /// * *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.
6607 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6608 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6609 /// * *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.
6610 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6611 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6612 pub fn param<T>(
6613 mut self,
6614 name: T,
6615 value: T,
6616 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
6617 where
6618 T: AsRef<str>,
6619 {
6620 self._additional_params
6621 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6622 self
6623 }
6624
6625 /// Identifies the authorization scope for the method you are building.
6626 ///
6627 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6628 /// [`Scope::CloudPlatform`].
6629 ///
6630 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6631 /// tokens for more than one scope.
6632 ///
6633 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6634 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6635 /// sufficient, a read-write scope will do as well.
6636 pub fn add_scope<St>(
6637 mut self,
6638 scope: St,
6639 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
6640 where
6641 St: AsRef<str>,
6642 {
6643 self._scopes.insert(String::from(scope.as_ref()));
6644 self
6645 }
6646 /// Identifies the authorization scope(s) for the method you are building.
6647 ///
6648 /// See [`Self::add_scope()`] for details.
6649 pub fn add_scopes<I, St>(
6650 mut self,
6651 scopes: I,
6652 ) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C>
6653 where
6654 I: IntoIterator<Item = St>,
6655 St: AsRef<str>,
6656 {
6657 self._scopes
6658 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6659 self
6660 }
6661
6662 /// Removes all scopes, and no default scope will be used either.
6663 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6664 /// for details).
6665 pub fn clear_scopes(mut self) -> ProjectLocationInstanceRescheduleMaintenanceCall<'a, C> {
6666 self._scopes.clear();
6667 self
6668 }
6669}
6670
6671/// Upgrades Redis instance to the newer Redis version specified in the request.
6672///
6673/// A builder for the *locations.instances.upgrade* method supported by a *project* resource.
6674/// It is not used directly, but through a [`ProjectMethods`] instance.
6675///
6676/// # Example
6677///
6678/// Instantiate a resource method builder
6679///
6680/// ```test_harness,no_run
6681/// # extern crate hyper;
6682/// # extern crate hyper_rustls;
6683/// # extern crate google_redis1 as redis1;
6684/// use redis1::api::UpgradeInstanceRequest;
6685/// # async fn dox() {
6686/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6687///
6688/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6689/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6690/// # secret,
6691/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6692/// # ).build().await.unwrap();
6693///
6694/// # let client = hyper_util::client::legacy::Client::builder(
6695/// # hyper_util::rt::TokioExecutor::new()
6696/// # )
6697/// # .build(
6698/// # hyper_rustls::HttpsConnectorBuilder::new()
6699/// # .with_native_roots()
6700/// # .unwrap()
6701/// # .https_or_http()
6702/// # .enable_http1()
6703/// # .build()
6704/// # );
6705/// # let mut hub = CloudRedis::new(client, auth);
6706/// // As the method needs a request, you would usually fill it with the desired information
6707/// // into the respective structure. Some of the parts shown here might not be applicable !
6708/// // Values shown here are possibly random and not representative !
6709/// let mut req = UpgradeInstanceRequest::default();
6710///
6711/// // You can configure optional parameters by calling the respective setters at will, and
6712/// // execute the final call using `doit()`.
6713/// // Values shown here are possibly random and not representative !
6714/// let result = hub.projects().locations_instances_upgrade(req, "name")
6715/// .doit().await;
6716/// # }
6717/// ```
6718pub struct ProjectLocationInstanceUpgradeCall<'a, C>
6719where
6720 C: 'a,
6721{
6722 hub: &'a CloudRedis<C>,
6723 _request: UpgradeInstanceRequest,
6724 _name: String,
6725 _delegate: Option<&'a mut dyn common::Delegate>,
6726 _additional_params: HashMap<String, String>,
6727 _scopes: BTreeSet<String>,
6728}
6729
6730impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpgradeCall<'a, C> {}
6731
6732impl<'a, C> ProjectLocationInstanceUpgradeCall<'a, C>
6733where
6734 C: common::Connector,
6735{
6736 /// Perform the operation you have build so far.
6737 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6738 use std::borrow::Cow;
6739 use std::io::{Read, Seek};
6740
6741 use common::{url::Params, ToParts};
6742 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6743
6744 let mut dd = common::DefaultDelegate;
6745 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6746 dlg.begin(common::MethodInfo {
6747 id: "redis.projects.locations.instances.upgrade",
6748 http_method: hyper::Method::POST,
6749 });
6750
6751 for &field in ["alt", "name"].iter() {
6752 if self._additional_params.contains_key(field) {
6753 dlg.finished(false);
6754 return Err(common::Error::FieldClash(field));
6755 }
6756 }
6757
6758 let mut params = Params::with_capacity(4 + self._additional_params.len());
6759 params.push("name", self._name);
6760
6761 params.extend(self._additional_params.iter());
6762
6763 params.push("alt", "json");
6764 let mut url = self.hub._base_url.clone() + "v1/{+name}:upgrade";
6765 if self._scopes.is_empty() {
6766 self._scopes
6767 .insert(Scope::CloudPlatform.as_ref().to_string());
6768 }
6769
6770 #[allow(clippy::single_element_loop)]
6771 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6772 url = params.uri_replacement(url, param_name, find_this, true);
6773 }
6774 {
6775 let to_remove = ["name"];
6776 params.remove_params(&to_remove);
6777 }
6778
6779 let url = params.parse_with_url(&url);
6780
6781 let mut json_mime_type = mime::APPLICATION_JSON;
6782 let mut request_value_reader = {
6783 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6784 common::remove_json_null_values(&mut value);
6785 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6786 serde_json::to_writer(&mut dst, &value).unwrap();
6787 dst
6788 };
6789 let request_size = request_value_reader
6790 .seek(std::io::SeekFrom::End(0))
6791 .unwrap();
6792 request_value_reader
6793 .seek(std::io::SeekFrom::Start(0))
6794 .unwrap();
6795
6796 loop {
6797 let token = match self
6798 .hub
6799 .auth
6800 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6801 .await
6802 {
6803 Ok(token) => token,
6804 Err(e) => match dlg.token(e) {
6805 Ok(token) => token,
6806 Err(e) => {
6807 dlg.finished(false);
6808 return Err(common::Error::MissingToken(e));
6809 }
6810 },
6811 };
6812 request_value_reader
6813 .seek(std::io::SeekFrom::Start(0))
6814 .unwrap();
6815 let mut req_result = {
6816 let client = &self.hub.client;
6817 dlg.pre_request();
6818 let mut req_builder = hyper::Request::builder()
6819 .method(hyper::Method::POST)
6820 .uri(url.as_str())
6821 .header(USER_AGENT, self.hub._user_agent.clone());
6822
6823 if let Some(token) = token.as_ref() {
6824 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6825 }
6826
6827 let request = req_builder
6828 .header(CONTENT_TYPE, json_mime_type.to_string())
6829 .header(CONTENT_LENGTH, request_size as u64)
6830 .body(common::to_body(
6831 request_value_reader.get_ref().clone().into(),
6832 ));
6833
6834 client.request(request.unwrap()).await
6835 };
6836
6837 match req_result {
6838 Err(err) => {
6839 if let common::Retry::After(d) = dlg.http_error(&err) {
6840 sleep(d).await;
6841 continue;
6842 }
6843 dlg.finished(false);
6844 return Err(common::Error::HttpError(err));
6845 }
6846 Ok(res) => {
6847 let (mut parts, body) = res.into_parts();
6848 let mut body = common::Body::new(body);
6849 if !parts.status.is_success() {
6850 let bytes = common::to_bytes(body).await.unwrap_or_default();
6851 let error = serde_json::from_str(&common::to_string(&bytes));
6852 let response = common::to_response(parts, bytes.into());
6853
6854 if let common::Retry::After(d) =
6855 dlg.http_failure(&response, error.as_ref().ok())
6856 {
6857 sleep(d).await;
6858 continue;
6859 }
6860
6861 dlg.finished(false);
6862
6863 return Err(match error {
6864 Ok(value) => common::Error::BadRequest(value),
6865 _ => common::Error::Failure(response),
6866 });
6867 }
6868 let response = {
6869 let bytes = common::to_bytes(body).await.unwrap_or_default();
6870 let encoded = common::to_string(&bytes);
6871 match serde_json::from_str(&encoded) {
6872 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6873 Err(error) => {
6874 dlg.response_json_decode_error(&encoded, &error);
6875 return Err(common::Error::JsonDecodeError(
6876 encoded.to_string(),
6877 error,
6878 ));
6879 }
6880 }
6881 };
6882
6883 dlg.finished(true);
6884 return Ok(response);
6885 }
6886 }
6887 }
6888 }
6889
6890 ///
6891 /// Sets the *request* property to the given value.
6892 ///
6893 /// Even though the property as already been set when instantiating this call,
6894 /// we provide this method for API completeness.
6895 pub fn request(
6896 mut self,
6897 new_value: UpgradeInstanceRequest,
6898 ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
6899 self._request = new_value;
6900 self
6901 }
6902 /// Required. Redis instance resource name using the form: `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` refers to a GCP region.
6903 ///
6904 /// Sets the *name* path property to the given value.
6905 ///
6906 /// Even though the property as already been set when instantiating this call,
6907 /// we provide this method for API completeness.
6908 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpgradeCall<'a, C> {
6909 self._name = new_value.to_string();
6910 self
6911 }
6912 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6913 /// while executing the actual API request.
6914 ///
6915 /// ````text
6916 /// It should be used to handle progress information, and to implement a certain level of resilience.
6917 /// ````
6918 ///
6919 /// Sets the *delegate* property to the given value.
6920 pub fn delegate(
6921 mut self,
6922 new_value: &'a mut dyn common::Delegate,
6923 ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
6924 self._delegate = Some(new_value);
6925 self
6926 }
6927
6928 /// Set any additional parameter of the query string used in the request.
6929 /// It should be used to set parameters which are not yet available through their own
6930 /// setters.
6931 ///
6932 /// Please note that this method must not be used to set any of the known parameters
6933 /// which have their own setter method. If done anyway, the request will fail.
6934 ///
6935 /// # Additional Parameters
6936 ///
6937 /// * *$.xgafv* (query-string) - V1 error format.
6938 /// * *access_token* (query-string) - OAuth access token.
6939 /// * *alt* (query-string) - Data format for response.
6940 /// * *callback* (query-string) - JSONP
6941 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6942 /// * *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.
6943 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6944 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6945 /// * *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.
6946 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6947 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6948 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUpgradeCall<'a, C>
6949 where
6950 T: AsRef<str>,
6951 {
6952 self._additional_params
6953 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6954 self
6955 }
6956
6957 /// Identifies the authorization scope for the method you are building.
6958 ///
6959 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6960 /// [`Scope::CloudPlatform`].
6961 ///
6962 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6963 /// tokens for more than one scope.
6964 ///
6965 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6966 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6967 /// sufficient, a read-write scope will do as well.
6968 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpgradeCall<'a, C>
6969 where
6970 St: AsRef<str>,
6971 {
6972 self._scopes.insert(String::from(scope.as_ref()));
6973 self
6974 }
6975 /// Identifies the authorization scope(s) for the method you are building.
6976 ///
6977 /// See [`Self::add_scope()`] for details.
6978 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUpgradeCall<'a, C>
6979 where
6980 I: IntoIterator<Item = St>,
6981 St: AsRef<str>,
6982 {
6983 self._scopes
6984 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6985 self
6986 }
6987
6988 /// Removes all scopes, and no default scope will be used either.
6989 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6990 /// for details).
6991 pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpgradeCall<'a, C> {
6992 self._scopes.clear();
6993 self
6994 }
6995}
6996
6997/// 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`.
6998///
6999/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
7000/// It is not used directly, but through a [`ProjectMethods`] instance.
7001///
7002/// # Example
7003///
7004/// Instantiate a resource method builder
7005///
7006/// ```test_harness,no_run
7007/// # extern crate hyper;
7008/// # extern crate hyper_rustls;
7009/// # extern crate google_redis1 as redis1;
7010/// # async fn dox() {
7011/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7012///
7013/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7014/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7015/// # secret,
7016/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7017/// # ).build().await.unwrap();
7018///
7019/// # let client = hyper_util::client::legacy::Client::builder(
7020/// # hyper_util::rt::TokioExecutor::new()
7021/// # )
7022/// # .build(
7023/// # hyper_rustls::HttpsConnectorBuilder::new()
7024/// # .with_native_roots()
7025/// # .unwrap()
7026/// # .https_or_http()
7027/// # .enable_http1()
7028/// # .build()
7029/// # );
7030/// # let mut hub = CloudRedis::new(client, auth);
7031/// // You can configure optional parameters by calling the respective setters at will, and
7032/// // execute the final call using `doit()`.
7033/// // Values shown here are possibly random and not representative !
7034/// let result = hub.projects().locations_operations_cancel("name")
7035/// .doit().await;
7036/// # }
7037/// ```
7038pub struct ProjectLocationOperationCancelCall<'a, C>
7039where
7040 C: 'a,
7041{
7042 hub: &'a CloudRedis<C>,
7043 _name: String,
7044 _delegate: Option<&'a mut dyn common::Delegate>,
7045 _additional_params: HashMap<String, String>,
7046 _scopes: BTreeSet<String>,
7047}
7048
7049impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
7050
7051impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
7052where
7053 C: common::Connector,
7054{
7055 /// Perform the operation you have build so far.
7056 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7057 use std::borrow::Cow;
7058 use std::io::{Read, Seek};
7059
7060 use common::{url::Params, ToParts};
7061 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7062
7063 let mut dd = common::DefaultDelegate;
7064 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7065 dlg.begin(common::MethodInfo {
7066 id: "redis.projects.locations.operations.cancel",
7067 http_method: hyper::Method::POST,
7068 });
7069
7070 for &field in ["alt", "name"].iter() {
7071 if self._additional_params.contains_key(field) {
7072 dlg.finished(false);
7073 return Err(common::Error::FieldClash(field));
7074 }
7075 }
7076
7077 let mut params = Params::with_capacity(3 + self._additional_params.len());
7078 params.push("name", self._name);
7079
7080 params.extend(self._additional_params.iter());
7081
7082 params.push("alt", "json");
7083 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
7084 if self._scopes.is_empty() {
7085 self._scopes
7086 .insert(Scope::CloudPlatform.as_ref().to_string());
7087 }
7088
7089 #[allow(clippy::single_element_loop)]
7090 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7091 url = params.uri_replacement(url, param_name, find_this, true);
7092 }
7093 {
7094 let to_remove = ["name"];
7095 params.remove_params(&to_remove);
7096 }
7097
7098 let url = params.parse_with_url(&url);
7099
7100 loop {
7101 let token = match self
7102 .hub
7103 .auth
7104 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7105 .await
7106 {
7107 Ok(token) => token,
7108 Err(e) => match dlg.token(e) {
7109 Ok(token) => token,
7110 Err(e) => {
7111 dlg.finished(false);
7112 return Err(common::Error::MissingToken(e));
7113 }
7114 },
7115 };
7116 let mut req_result = {
7117 let client = &self.hub.client;
7118 dlg.pre_request();
7119 let mut req_builder = hyper::Request::builder()
7120 .method(hyper::Method::POST)
7121 .uri(url.as_str())
7122 .header(USER_AGENT, self.hub._user_agent.clone());
7123
7124 if let Some(token) = token.as_ref() {
7125 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7126 }
7127
7128 let request = req_builder
7129 .header(CONTENT_LENGTH, 0_u64)
7130 .body(common::to_body::<String>(None));
7131
7132 client.request(request.unwrap()).await
7133 };
7134
7135 match req_result {
7136 Err(err) => {
7137 if let common::Retry::After(d) = dlg.http_error(&err) {
7138 sleep(d).await;
7139 continue;
7140 }
7141 dlg.finished(false);
7142 return Err(common::Error::HttpError(err));
7143 }
7144 Ok(res) => {
7145 let (mut parts, body) = res.into_parts();
7146 let mut body = common::Body::new(body);
7147 if !parts.status.is_success() {
7148 let bytes = common::to_bytes(body).await.unwrap_or_default();
7149 let error = serde_json::from_str(&common::to_string(&bytes));
7150 let response = common::to_response(parts, bytes.into());
7151
7152 if let common::Retry::After(d) =
7153 dlg.http_failure(&response, error.as_ref().ok())
7154 {
7155 sleep(d).await;
7156 continue;
7157 }
7158
7159 dlg.finished(false);
7160
7161 return Err(match error {
7162 Ok(value) => common::Error::BadRequest(value),
7163 _ => common::Error::Failure(response),
7164 });
7165 }
7166 let response = {
7167 let bytes = common::to_bytes(body).await.unwrap_or_default();
7168 let encoded = common::to_string(&bytes);
7169 match serde_json::from_str(&encoded) {
7170 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7171 Err(error) => {
7172 dlg.response_json_decode_error(&encoded, &error);
7173 return Err(common::Error::JsonDecodeError(
7174 encoded.to_string(),
7175 error,
7176 ));
7177 }
7178 }
7179 };
7180
7181 dlg.finished(true);
7182 return Ok(response);
7183 }
7184 }
7185 }
7186 }
7187
7188 /// The name of the operation resource to be cancelled.
7189 ///
7190 /// Sets the *name* path property to the given value.
7191 ///
7192 /// Even though the property as already been set when instantiating this call,
7193 /// we provide this method for API completeness.
7194 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
7195 self._name = new_value.to_string();
7196 self
7197 }
7198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7199 /// while executing the actual API request.
7200 ///
7201 /// ````text
7202 /// It should be used to handle progress information, and to implement a certain level of resilience.
7203 /// ````
7204 ///
7205 /// Sets the *delegate* property to the given value.
7206 pub fn delegate(
7207 mut self,
7208 new_value: &'a mut dyn common::Delegate,
7209 ) -> ProjectLocationOperationCancelCall<'a, C> {
7210 self._delegate = Some(new_value);
7211 self
7212 }
7213
7214 /// Set any additional parameter of the query string used in the request.
7215 /// It should be used to set parameters which are not yet available through their own
7216 /// setters.
7217 ///
7218 /// Please note that this method must not be used to set any of the known parameters
7219 /// which have their own setter method. If done anyway, the request will fail.
7220 ///
7221 /// # Additional Parameters
7222 ///
7223 /// * *$.xgafv* (query-string) - V1 error format.
7224 /// * *access_token* (query-string) - OAuth access token.
7225 /// * *alt* (query-string) - Data format for response.
7226 /// * *callback* (query-string) - JSONP
7227 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7228 /// * *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.
7229 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7230 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7231 /// * *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.
7232 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7233 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7234 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
7235 where
7236 T: AsRef<str>,
7237 {
7238 self._additional_params
7239 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7240 self
7241 }
7242
7243 /// Identifies the authorization scope for the method you are building.
7244 ///
7245 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7246 /// [`Scope::CloudPlatform`].
7247 ///
7248 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7249 /// tokens for more than one scope.
7250 ///
7251 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7252 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7253 /// sufficient, a read-write scope will do as well.
7254 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
7255 where
7256 St: AsRef<str>,
7257 {
7258 self._scopes.insert(String::from(scope.as_ref()));
7259 self
7260 }
7261 /// Identifies the authorization scope(s) for the method you are building.
7262 ///
7263 /// See [`Self::add_scope()`] for details.
7264 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
7265 where
7266 I: IntoIterator<Item = St>,
7267 St: AsRef<str>,
7268 {
7269 self._scopes
7270 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7271 self
7272 }
7273
7274 /// Removes all scopes, and no default scope will be used either.
7275 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7276 /// for details).
7277 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
7278 self._scopes.clear();
7279 self
7280 }
7281}
7282
7283/// 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`.
7284///
7285/// A builder for the *locations.operations.delete* method supported by a *project* resource.
7286/// It is not used directly, but through a [`ProjectMethods`] instance.
7287///
7288/// # Example
7289///
7290/// Instantiate a resource method builder
7291///
7292/// ```test_harness,no_run
7293/// # extern crate hyper;
7294/// # extern crate hyper_rustls;
7295/// # extern crate google_redis1 as redis1;
7296/// # async fn dox() {
7297/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7298///
7299/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7300/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7301/// # secret,
7302/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7303/// # ).build().await.unwrap();
7304///
7305/// # let client = hyper_util::client::legacy::Client::builder(
7306/// # hyper_util::rt::TokioExecutor::new()
7307/// # )
7308/// # .build(
7309/// # hyper_rustls::HttpsConnectorBuilder::new()
7310/// # .with_native_roots()
7311/// # .unwrap()
7312/// # .https_or_http()
7313/// # .enable_http1()
7314/// # .build()
7315/// # );
7316/// # let mut hub = CloudRedis::new(client, auth);
7317/// // You can configure optional parameters by calling the respective setters at will, and
7318/// // execute the final call using `doit()`.
7319/// // Values shown here are possibly random and not representative !
7320/// let result = hub.projects().locations_operations_delete("name")
7321/// .doit().await;
7322/// # }
7323/// ```
7324pub struct ProjectLocationOperationDeleteCall<'a, C>
7325where
7326 C: 'a,
7327{
7328 hub: &'a CloudRedis<C>,
7329 _name: String,
7330 _delegate: Option<&'a mut dyn common::Delegate>,
7331 _additional_params: HashMap<String, String>,
7332 _scopes: BTreeSet<String>,
7333}
7334
7335impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
7336
7337impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
7338where
7339 C: common::Connector,
7340{
7341 /// Perform the operation you have build so far.
7342 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7343 use std::borrow::Cow;
7344 use std::io::{Read, Seek};
7345
7346 use common::{url::Params, ToParts};
7347 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7348
7349 let mut dd = common::DefaultDelegate;
7350 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7351 dlg.begin(common::MethodInfo {
7352 id: "redis.projects.locations.operations.delete",
7353 http_method: hyper::Method::DELETE,
7354 });
7355
7356 for &field in ["alt", "name"].iter() {
7357 if self._additional_params.contains_key(field) {
7358 dlg.finished(false);
7359 return Err(common::Error::FieldClash(field));
7360 }
7361 }
7362
7363 let mut params = Params::with_capacity(3 + self._additional_params.len());
7364 params.push("name", self._name);
7365
7366 params.extend(self._additional_params.iter());
7367
7368 params.push("alt", "json");
7369 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7370 if self._scopes.is_empty() {
7371 self._scopes
7372 .insert(Scope::CloudPlatform.as_ref().to_string());
7373 }
7374
7375 #[allow(clippy::single_element_loop)]
7376 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7377 url = params.uri_replacement(url, param_name, find_this, true);
7378 }
7379 {
7380 let to_remove = ["name"];
7381 params.remove_params(&to_remove);
7382 }
7383
7384 let url = params.parse_with_url(&url);
7385
7386 loop {
7387 let token = match self
7388 .hub
7389 .auth
7390 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7391 .await
7392 {
7393 Ok(token) => token,
7394 Err(e) => match dlg.token(e) {
7395 Ok(token) => token,
7396 Err(e) => {
7397 dlg.finished(false);
7398 return Err(common::Error::MissingToken(e));
7399 }
7400 },
7401 };
7402 let mut req_result = {
7403 let client = &self.hub.client;
7404 dlg.pre_request();
7405 let mut req_builder = hyper::Request::builder()
7406 .method(hyper::Method::DELETE)
7407 .uri(url.as_str())
7408 .header(USER_AGENT, self.hub._user_agent.clone());
7409
7410 if let Some(token) = token.as_ref() {
7411 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7412 }
7413
7414 let request = req_builder
7415 .header(CONTENT_LENGTH, 0_u64)
7416 .body(common::to_body::<String>(None));
7417
7418 client.request(request.unwrap()).await
7419 };
7420
7421 match req_result {
7422 Err(err) => {
7423 if let common::Retry::After(d) = dlg.http_error(&err) {
7424 sleep(d).await;
7425 continue;
7426 }
7427 dlg.finished(false);
7428 return Err(common::Error::HttpError(err));
7429 }
7430 Ok(res) => {
7431 let (mut parts, body) = res.into_parts();
7432 let mut body = common::Body::new(body);
7433 if !parts.status.is_success() {
7434 let bytes = common::to_bytes(body).await.unwrap_or_default();
7435 let error = serde_json::from_str(&common::to_string(&bytes));
7436 let response = common::to_response(parts, bytes.into());
7437
7438 if let common::Retry::After(d) =
7439 dlg.http_failure(&response, error.as_ref().ok())
7440 {
7441 sleep(d).await;
7442 continue;
7443 }
7444
7445 dlg.finished(false);
7446
7447 return Err(match error {
7448 Ok(value) => common::Error::BadRequest(value),
7449 _ => common::Error::Failure(response),
7450 });
7451 }
7452 let response = {
7453 let bytes = common::to_bytes(body).await.unwrap_or_default();
7454 let encoded = common::to_string(&bytes);
7455 match serde_json::from_str(&encoded) {
7456 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7457 Err(error) => {
7458 dlg.response_json_decode_error(&encoded, &error);
7459 return Err(common::Error::JsonDecodeError(
7460 encoded.to_string(),
7461 error,
7462 ));
7463 }
7464 }
7465 };
7466
7467 dlg.finished(true);
7468 return Ok(response);
7469 }
7470 }
7471 }
7472 }
7473
7474 /// The name of the operation resource to be deleted.
7475 ///
7476 /// Sets the *name* path property to the given value.
7477 ///
7478 /// Even though the property as already been set when instantiating this call,
7479 /// we provide this method for API completeness.
7480 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
7481 self._name = new_value.to_string();
7482 self
7483 }
7484 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7485 /// while executing the actual API request.
7486 ///
7487 /// ````text
7488 /// It should be used to handle progress information, and to implement a certain level of resilience.
7489 /// ````
7490 ///
7491 /// Sets the *delegate* property to the given value.
7492 pub fn delegate(
7493 mut self,
7494 new_value: &'a mut dyn common::Delegate,
7495 ) -> ProjectLocationOperationDeleteCall<'a, C> {
7496 self._delegate = Some(new_value);
7497 self
7498 }
7499
7500 /// Set any additional parameter of the query string used in the request.
7501 /// It should be used to set parameters which are not yet available through their own
7502 /// setters.
7503 ///
7504 /// Please note that this method must not be used to set any of the known parameters
7505 /// which have their own setter method. If done anyway, the request will fail.
7506 ///
7507 /// # Additional Parameters
7508 ///
7509 /// * *$.xgafv* (query-string) - V1 error format.
7510 /// * *access_token* (query-string) - OAuth access token.
7511 /// * *alt* (query-string) - Data format for response.
7512 /// * *callback* (query-string) - JSONP
7513 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7514 /// * *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.
7515 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7516 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7517 /// * *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.
7518 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7519 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7520 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
7521 where
7522 T: AsRef<str>,
7523 {
7524 self._additional_params
7525 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7526 self
7527 }
7528
7529 /// Identifies the authorization scope for the method you are building.
7530 ///
7531 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7532 /// [`Scope::CloudPlatform`].
7533 ///
7534 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7535 /// tokens for more than one scope.
7536 ///
7537 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7538 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7539 /// sufficient, a read-write scope will do as well.
7540 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
7541 where
7542 St: AsRef<str>,
7543 {
7544 self._scopes.insert(String::from(scope.as_ref()));
7545 self
7546 }
7547 /// Identifies the authorization scope(s) for the method you are building.
7548 ///
7549 /// See [`Self::add_scope()`] for details.
7550 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
7551 where
7552 I: IntoIterator<Item = St>,
7553 St: AsRef<str>,
7554 {
7555 self._scopes
7556 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7557 self
7558 }
7559
7560 /// Removes all scopes, and no default scope will be used either.
7561 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7562 /// for details).
7563 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
7564 self._scopes.clear();
7565 self
7566 }
7567}
7568
7569/// 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.
7570///
7571/// A builder for the *locations.operations.get* method supported by a *project* resource.
7572/// It is not used directly, but through a [`ProjectMethods`] instance.
7573///
7574/// # Example
7575///
7576/// Instantiate a resource method builder
7577///
7578/// ```test_harness,no_run
7579/// # extern crate hyper;
7580/// # extern crate hyper_rustls;
7581/// # extern crate google_redis1 as redis1;
7582/// # async fn dox() {
7583/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7584///
7585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7586/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7587/// # secret,
7588/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7589/// # ).build().await.unwrap();
7590///
7591/// # let client = hyper_util::client::legacy::Client::builder(
7592/// # hyper_util::rt::TokioExecutor::new()
7593/// # )
7594/// # .build(
7595/// # hyper_rustls::HttpsConnectorBuilder::new()
7596/// # .with_native_roots()
7597/// # .unwrap()
7598/// # .https_or_http()
7599/// # .enable_http1()
7600/// # .build()
7601/// # );
7602/// # let mut hub = CloudRedis::new(client, auth);
7603/// // You can configure optional parameters by calling the respective setters at will, and
7604/// // execute the final call using `doit()`.
7605/// // Values shown here are possibly random and not representative !
7606/// let result = hub.projects().locations_operations_get("name")
7607/// .doit().await;
7608/// # }
7609/// ```
7610pub struct ProjectLocationOperationGetCall<'a, C>
7611where
7612 C: 'a,
7613{
7614 hub: &'a CloudRedis<C>,
7615 _name: String,
7616 _delegate: Option<&'a mut dyn common::Delegate>,
7617 _additional_params: HashMap<String, String>,
7618 _scopes: BTreeSet<String>,
7619}
7620
7621impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
7622
7623impl<'a, C> ProjectLocationOperationGetCall<'a, C>
7624where
7625 C: common::Connector,
7626{
7627 /// Perform the operation you have build so far.
7628 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7629 use std::borrow::Cow;
7630 use std::io::{Read, Seek};
7631
7632 use common::{url::Params, ToParts};
7633 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7634
7635 let mut dd = common::DefaultDelegate;
7636 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7637 dlg.begin(common::MethodInfo {
7638 id: "redis.projects.locations.operations.get",
7639 http_method: hyper::Method::GET,
7640 });
7641
7642 for &field in ["alt", "name"].iter() {
7643 if self._additional_params.contains_key(field) {
7644 dlg.finished(false);
7645 return Err(common::Error::FieldClash(field));
7646 }
7647 }
7648
7649 let mut params = Params::with_capacity(3 + self._additional_params.len());
7650 params.push("name", self._name);
7651
7652 params.extend(self._additional_params.iter());
7653
7654 params.push("alt", "json");
7655 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7656 if self._scopes.is_empty() {
7657 self._scopes
7658 .insert(Scope::CloudPlatform.as_ref().to_string());
7659 }
7660
7661 #[allow(clippy::single_element_loop)]
7662 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7663 url = params.uri_replacement(url, param_name, find_this, true);
7664 }
7665 {
7666 let to_remove = ["name"];
7667 params.remove_params(&to_remove);
7668 }
7669
7670 let url = params.parse_with_url(&url);
7671
7672 loop {
7673 let token = match self
7674 .hub
7675 .auth
7676 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7677 .await
7678 {
7679 Ok(token) => token,
7680 Err(e) => match dlg.token(e) {
7681 Ok(token) => token,
7682 Err(e) => {
7683 dlg.finished(false);
7684 return Err(common::Error::MissingToken(e));
7685 }
7686 },
7687 };
7688 let mut req_result = {
7689 let client = &self.hub.client;
7690 dlg.pre_request();
7691 let mut req_builder = hyper::Request::builder()
7692 .method(hyper::Method::GET)
7693 .uri(url.as_str())
7694 .header(USER_AGENT, self.hub._user_agent.clone());
7695
7696 if let Some(token) = token.as_ref() {
7697 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7698 }
7699
7700 let request = req_builder
7701 .header(CONTENT_LENGTH, 0_u64)
7702 .body(common::to_body::<String>(None));
7703
7704 client.request(request.unwrap()).await
7705 };
7706
7707 match req_result {
7708 Err(err) => {
7709 if let common::Retry::After(d) = dlg.http_error(&err) {
7710 sleep(d).await;
7711 continue;
7712 }
7713 dlg.finished(false);
7714 return Err(common::Error::HttpError(err));
7715 }
7716 Ok(res) => {
7717 let (mut parts, body) = res.into_parts();
7718 let mut body = common::Body::new(body);
7719 if !parts.status.is_success() {
7720 let bytes = common::to_bytes(body).await.unwrap_or_default();
7721 let error = serde_json::from_str(&common::to_string(&bytes));
7722 let response = common::to_response(parts, bytes.into());
7723
7724 if let common::Retry::After(d) =
7725 dlg.http_failure(&response, error.as_ref().ok())
7726 {
7727 sleep(d).await;
7728 continue;
7729 }
7730
7731 dlg.finished(false);
7732
7733 return Err(match error {
7734 Ok(value) => common::Error::BadRequest(value),
7735 _ => common::Error::Failure(response),
7736 });
7737 }
7738 let response = {
7739 let bytes = common::to_bytes(body).await.unwrap_or_default();
7740 let encoded = common::to_string(&bytes);
7741 match serde_json::from_str(&encoded) {
7742 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7743 Err(error) => {
7744 dlg.response_json_decode_error(&encoded, &error);
7745 return Err(common::Error::JsonDecodeError(
7746 encoded.to_string(),
7747 error,
7748 ));
7749 }
7750 }
7751 };
7752
7753 dlg.finished(true);
7754 return Ok(response);
7755 }
7756 }
7757 }
7758 }
7759
7760 /// The name of the operation resource.
7761 ///
7762 /// Sets the *name* path property to the given value.
7763 ///
7764 /// Even though the property as already been set when instantiating this call,
7765 /// we provide this method for API completeness.
7766 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
7767 self._name = new_value.to_string();
7768 self
7769 }
7770 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7771 /// while executing the actual API request.
7772 ///
7773 /// ````text
7774 /// It should be used to handle progress information, and to implement a certain level of resilience.
7775 /// ````
7776 ///
7777 /// Sets the *delegate* property to the given value.
7778 pub fn delegate(
7779 mut self,
7780 new_value: &'a mut dyn common::Delegate,
7781 ) -> ProjectLocationOperationGetCall<'a, C> {
7782 self._delegate = Some(new_value);
7783 self
7784 }
7785
7786 /// Set any additional parameter of the query string used in the request.
7787 /// It should be used to set parameters which are not yet available through their own
7788 /// setters.
7789 ///
7790 /// Please note that this method must not be used to set any of the known parameters
7791 /// which have their own setter method. If done anyway, the request will fail.
7792 ///
7793 /// # Additional Parameters
7794 ///
7795 /// * *$.xgafv* (query-string) - V1 error format.
7796 /// * *access_token* (query-string) - OAuth access token.
7797 /// * *alt* (query-string) - Data format for response.
7798 /// * *callback* (query-string) - JSONP
7799 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7800 /// * *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.
7801 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7802 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7803 /// * *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.
7804 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7805 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7806 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
7807 where
7808 T: AsRef<str>,
7809 {
7810 self._additional_params
7811 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7812 self
7813 }
7814
7815 /// Identifies the authorization scope for the method you are building.
7816 ///
7817 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7818 /// [`Scope::CloudPlatform`].
7819 ///
7820 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7821 /// tokens for more than one scope.
7822 ///
7823 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7824 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7825 /// sufficient, a read-write scope will do as well.
7826 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
7827 where
7828 St: AsRef<str>,
7829 {
7830 self._scopes.insert(String::from(scope.as_ref()));
7831 self
7832 }
7833 /// Identifies the authorization scope(s) for the method you are building.
7834 ///
7835 /// See [`Self::add_scope()`] for details.
7836 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
7837 where
7838 I: IntoIterator<Item = St>,
7839 St: AsRef<str>,
7840 {
7841 self._scopes
7842 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7843 self
7844 }
7845
7846 /// Removes all scopes, and no default scope will be used either.
7847 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7848 /// for details).
7849 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
7850 self._scopes.clear();
7851 self
7852 }
7853}
7854
7855/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
7856///
7857/// A builder for the *locations.operations.list* method supported by a *project* resource.
7858/// It is not used directly, but through a [`ProjectMethods`] instance.
7859///
7860/// # Example
7861///
7862/// Instantiate a resource method builder
7863///
7864/// ```test_harness,no_run
7865/// # extern crate hyper;
7866/// # extern crate hyper_rustls;
7867/// # extern crate google_redis1 as redis1;
7868/// # async fn dox() {
7869/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7870///
7871/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7873/// # secret,
7874/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7875/// # ).build().await.unwrap();
7876///
7877/// # let client = hyper_util::client::legacy::Client::builder(
7878/// # hyper_util::rt::TokioExecutor::new()
7879/// # )
7880/// # .build(
7881/// # hyper_rustls::HttpsConnectorBuilder::new()
7882/// # .with_native_roots()
7883/// # .unwrap()
7884/// # .https_or_http()
7885/// # .enable_http1()
7886/// # .build()
7887/// # );
7888/// # let mut hub = CloudRedis::new(client, auth);
7889/// // You can configure optional parameters by calling the respective setters at will, and
7890/// // execute the final call using `doit()`.
7891/// // Values shown here are possibly random and not representative !
7892/// let result = hub.projects().locations_operations_list("name")
7893/// .page_token("duo")
7894/// .page_size(-80)
7895/// .filter("no")
7896/// .doit().await;
7897/// # }
7898/// ```
7899pub struct ProjectLocationOperationListCall<'a, C>
7900where
7901 C: 'a,
7902{
7903 hub: &'a CloudRedis<C>,
7904 _name: String,
7905 _page_token: Option<String>,
7906 _page_size: Option<i32>,
7907 _filter: Option<String>,
7908 _delegate: Option<&'a mut dyn common::Delegate>,
7909 _additional_params: HashMap<String, String>,
7910 _scopes: BTreeSet<String>,
7911}
7912
7913impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
7914
7915impl<'a, C> ProjectLocationOperationListCall<'a, C>
7916where
7917 C: common::Connector,
7918{
7919 /// Perform the operation you have build so far.
7920 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
7921 use std::borrow::Cow;
7922 use std::io::{Read, Seek};
7923
7924 use common::{url::Params, ToParts};
7925 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7926
7927 let mut dd = common::DefaultDelegate;
7928 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7929 dlg.begin(common::MethodInfo {
7930 id: "redis.projects.locations.operations.list",
7931 http_method: hyper::Method::GET,
7932 });
7933
7934 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
7935 if self._additional_params.contains_key(field) {
7936 dlg.finished(false);
7937 return Err(common::Error::FieldClash(field));
7938 }
7939 }
7940
7941 let mut params = Params::with_capacity(6 + self._additional_params.len());
7942 params.push("name", self._name);
7943 if let Some(value) = self._page_token.as_ref() {
7944 params.push("pageToken", value);
7945 }
7946 if let Some(value) = self._page_size.as_ref() {
7947 params.push("pageSize", value.to_string());
7948 }
7949 if let Some(value) = self._filter.as_ref() {
7950 params.push("filter", value);
7951 }
7952
7953 params.extend(self._additional_params.iter());
7954
7955 params.push("alt", "json");
7956 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
7957 if self._scopes.is_empty() {
7958 self._scopes
7959 .insert(Scope::CloudPlatform.as_ref().to_string());
7960 }
7961
7962 #[allow(clippy::single_element_loop)]
7963 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7964 url = params.uri_replacement(url, param_name, find_this, true);
7965 }
7966 {
7967 let to_remove = ["name"];
7968 params.remove_params(&to_remove);
7969 }
7970
7971 let url = params.parse_with_url(&url);
7972
7973 loop {
7974 let token = match self
7975 .hub
7976 .auth
7977 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7978 .await
7979 {
7980 Ok(token) => token,
7981 Err(e) => match dlg.token(e) {
7982 Ok(token) => token,
7983 Err(e) => {
7984 dlg.finished(false);
7985 return Err(common::Error::MissingToken(e));
7986 }
7987 },
7988 };
7989 let mut req_result = {
7990 let client = &self.hub.client;
7991 dlg.pre_request();
7992 let mut req_builder = hyper::Request::builder()
7993 .method(hyper::Method::GET)
7994 .uri(url.as_str())
7995 .header(USER_AGENT, self.hub._user_agent.clone());
7996
7997 if let Some(token) = token.as_ref() {
7998 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7999 }
8000
8001 let request = req_builder
8002 .header(CONTENT_LENGTH, 0_u64)
8003 .body(common::to_body::<String>(None));
8004
8005 client.request(request.unwrap()).await
8006 };
8007
8008 match req_result {
8009 Err(err) => {
8010 if let common::Retry::After(d) = dlg.http_error(&err) {
8011 sleep(d).await;
8012 continue;
8013 }
8014 dlg.finished(false);
8015 return Err(common::Error::HttpError(err));
8016 }
8017 Ok(res) => {
8018 let (mut parts, body) = res.into_parts();
8019 let mut body = common::Body::new(body);
8020 if !parts.status.is_success() {
8021 let bytes = common::to_bytes(body).await.unwrap_or_default();
8022 let error = serde_json::from_str(&common::to_string(&bytes));
8023 let response = common::to_response(parts, bytes.into());
8024
8025 if let common::Retry::After(d) =
8026 dlg.http_failure(&response, error.as_ref().ok())
8027 {
8028 sleep(d).await;
8029 continue;
8030 }
8031
8032 dlg.finished(false);
8033
8034 return Err(match error {
8035 Ok(value) => common::Error::BadRequest(value),
8036 _ => common::Error::Failure(response),
8037 });
8038 }
8039 let response = {
8040 let bytes = common::to_bytes(body).await.unwrap_or_default();
8041 let encoded = common::to_string(&bytes);
8042 match serde_json::from_str(&encoded) {
8043 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8044 Err(error) => {
8045 dlg.response_json_decode_error(&encoded, &error);
8046 return Err(common::Error::JsonDecodeError(
8047 encoded.to_string(),
8048 error,
8049 ));
8050 }
8051 }
8052 };
8053
8054 dlg.finished(true);
8055 return Ok(response);
8056 }
8057 }
8058 }
8059 }
8060
8061 /// The name of the operation's parent resource.
8062 ///
8063 /// Sets the *name* path property to the given value.
8064 ///
8065 /// Even though the property as already been set when instantiating this call,
8066 /// we provide this method for API completeness.
8067 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
8068 self._name = new_value.to_string();
8069 self
8070 }
8071 /// The standard list page token.
8072 ///
8073 /// Sets the *page token* query property to the given value.
8074 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
8075 self._page_token = Some(new_value.to_string());
8076 self
8077 }
8078 /// The standard list page size.
8079 ///
8080 /// Sets the *page size* query property to the given value.
8081 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
8082 self._page_size = Some(new_value);
8083 self
8084 }
8085 /// The standard list filter.
8086 ///
8087 /// Sets the *filter* query property to the given value.
8088 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
8089 self._filter = Some(new_value.to_string());
8090 self
8091 }
8092 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8093 /// while executing the actual API request.
8094 ///
8095 /// ````text
8096 /// It should be used to handle progress information, and to implement a certain level of resilience.
8097 /// ````
8098 ///
8099 /// Sets the *delegate* property to the given value.
8100 pub fn delegate(
8101 mut self,
8102 new_value: &'a mut dyn common::Delegate,
8103 ) -> ProjectLocationOperationListCall<'a, C> {
8104 self._delegate = Some(new_value);
8105 self
8106 }
8107
8108 /// Set any additional parameter of the query string used in the request.
8109 /// It should be used to set parameters which are not yet available through their own
8110 /// setters.
8111 ///
8112 /// Please note that this method must not be used to set any of the known parameters
8113 /// which have their own setter method. If done anyway, the request will fail.
8114 ///
8115 /// # Additional Parameters
8116 ///
8117 /// * *$.xgafv* (query-string) - V1 error format.
8118 /// * *access_token* (query-string) - OAuth access token.
8119 /// * *alt* (query-string) - Data format for response.
8120 /// * *callback* (query-string) - JSONP
8121 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8122 /// * *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.
8123 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8124 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8125 /// * *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.
8126 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8127 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8128 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
8129 where
8130 T: AsRef<str>,
8131 {
8132 self._additional_params
8133 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8134 self
8135 }
8136
8137 /// Identifies the authorization scope for the method you are building.
8138 ///
8139 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8140 /// [`Scope::CloudPlatform`].
8141 ///
8142 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8143 /// tokens for more than one scope.
8144 ///
8145 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8146 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8147 /// sufficient, a read-write scope will do as well.
8148 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
8149 where
8150 St: AsRef<str>,
8151 {
8152 self._scopes.insert(String::from(scope.as_ref()));
8153 self
8154 }
8155 /// Identifies the authorization scope(s) for the method you are building.
8156 ///
8157 /// See [`Self::add_scope()`] for details.
8158 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
8159 where
8160 I: IntoIterator<Item = St>,
8161 St: AsRef<str>,
8162 {
8163 self._scopes
8164 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8165 self
8166 }
8167
8168 /// Removes all scopes, and no default scope will be used either.
8169 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8170 /// for details).
8171 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
8172 self._scopes.clear();
8173 self
8174 }
8175}
8176
8177/// Gets information about a location.
8178///
8179/// A builder for the *locations.get* method supported by a *project* resource.
8180/// It is not used directly, but through a [`ProjectMethods`] instance.
8181///
8182/// # Example
8183///
8184/// Instantiate a resource method builder
8185///
8186/// ```test_harness,no_run
8187/// # extern crate hyper;
8188/// # extern crate hyper_rustls;
8189/// # extern crate google_redis1 as redis1;
8190/// # async fn dox() {
8191/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8192///
8193/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8194/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8195/// # secret,
8196/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8197/// # ).build().await.unwrap();
8198///
8199/// # let client = hyper_util::client::legacy::Client::builder(
8200/// # hyper_util::rt::TokioExecutor::new()
8201/// # )
8202/// # .build(
8203/// # hyper_rustls::HttpsConnectorBuilder::new()
8204/// # .with_native_roots()
8205/// # .unwrap()
8206/// # .https_or_http()
8207/// # .enable_http1()
8208/// # .build()
8209/// # );
8210/// # let mut hub = CloudRedis::new(client, auth);
8211/// // You can configure optional parameters by calling the respective setters at will, and
8212/// // execute the final call using `doit()`.
8213/// // Values shown here are possibly random and not representative !
8214/// let result = hub.projects().locations_get("name")
8215/// .doit().await;
8216/// # }
8217/// ```
8218pub struct ProjectLocationGetCall<'a, C>
8219where
8220 C: 'a,
8221{
8222 hub: &'a CloudRedis<C>,
8223 _name: String,
8224 _delegate: Option<&'a mut dyn common::Delegate>,
8225 _additional_params: HashMap<String, String>,
8226 _scopes: BTreeSet<String>,
8227}
8228
8229impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
8230
8231impl<'a, C> ProjectLocationGetCall<'a, C>
8232where
8233 C: common::Connector,
8234{
8235 /// Perform the operation you have build so far.
8236 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
8237 use std::borrow::Cow;
8238 use std::io::{Read, Seek};
8239
8240 use common::{url::Params, ToParts};
8241 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8242
8243 let mut dd = common::DefaultDelegate;
8244 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8245 dlg.begin(common::MethodInfo {
8246 id: "redis.projects.locations.get",
8247 http_method: hyper::Method::GET,
8248 });
8249
8250 for &field in ["alt", "name"].iter() {
8251 if self._additional_params.contains_key(field) {
8252 dlg.finished(false);
8253 return Err(common::Error::FieldClash(field));
8254 }
8255 }
8256
8257 let mut params = Params::with_capacity(3 + self._additional_params.len());
8258 params.push("name", self._name);
8259
8260 params.extend(self._additional_params.iter());
8261
8262 params.push("alt", "json");
8263 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8264 if self._scopes.is_empty() {
8265 self._scopes
8266 .insert(Scope::CloudPlatform.as_ref().to_string());
8267 }
8268
8269 #[allow(clippy::single_element_loop)]
8270 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8271 url = params.uri_replacement(url, param_name, find_this, true);
8272 }
8273 {
8274 let to_remove = ["name"];
8275 params.remove_params(&to_remove);
8276 }
8277
8278 let url = params.parse_with_url(&url);
8279
8280 loop {
8281 let token = match self
8282 .hub
8283 .auth
8284 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8285 .await
8286 {
8287 Ok(token) => token,
8288 Err(e) => match dlg.token(e) {
8289 Ok(token) => token,
8290 Err(e) => {
8291 dlg.finished(false);
8292 return Err(common::Error::MissingToken(e));
8293 }
8294 },
8295 };
8296 let mut req_result = {
8297 let client = &self.hub.client;
8298 dlg.pre_request();
8299 let mut req_builder = hyper::Request::builder()
8300 .method(hyper::Method::GET)
8301 .uri(url.as_str())
8302 .header(USER_AGENT, self.hub._user_agent.clone());
8303
8304 if let Some(token) = token.as_ref() {
8305 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8306 }
8307
8308 let request = req_builder
8309 .header(CONTENT_LENGTH, 0_u64)
8310 .body(common::to_body::<String>(None));
8311
8312 client.request(request.unwrap()).await
8313 };
8314
8315 match req_result {
8316 Err(err) => {
8317 if let common::Retry::After(d) = dlg.http_error(&err) {
8318 sleep(d).await;
8319 continue;
8320 }
8321 dlg.finished(false);
8322 return Err(common::Error::HttpError(err));
8323 }
8324 Ok(res) => {
8325 let (mut parts, body) = res.into_parts();
8326 let mut body = common::Body::new(body);
8327 if !parts.status.is_success() {
8328 let bytes = common::to_bytes(body).await.unwrap_or_default();
8329 let error = serde_json::from_str(&common::to_string(&bytes));
8330 let response = common::to_response(parts, bytes.into());
8331
8332 if let common::Retry::After(d) =
8333 dlg.http_failure(&response, error.as_ref().ok())
8334 {
8335 sleep(d).await;
8336 continue;
8337 }
8338
8339 dlg.finished(false);
8340
8341 return Err(match error {
8342 Ok(value) => common::Error::BadRequest(value),
8343 _ => common::Error::Failure(response),
8344 });
8345 }
8346 let response = {
8347 let bytes = common::to_bytes(body).await.unwrap_or_default();
8348 let encoded = common::to_string(&bytes);
8349 match serde_json::from_str(&encoded) {
8350 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8351 Err(error) => {
8352 dlg.response_json_decode_error(&encoded, &error);
8353 return Err(common::Error::JsonDecodeError(
8354 encoded.to_string(),
8355 error,
8356 ));
8357 }
8358 }
8359 };
8360
8361 dlg.finished(true);
8362 return Ok(response);
8363 }
8364 }
8365 }
8366 }
8367
8368 /// Resource name for the location.
8369 ///
8370 /// Sets the *name* path property to the given value.
8371 ///
8372 /// Even though the property as already been set when instantiating this call,
8373 /// we provide this method for API completeness.
8374 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
8375 self._name = new_value.to_string();
8376 self
8377 }
8378 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8379 /// while executing the actual API request.
8380 ///
8381 /// ````text
8382 /// It should be used to handle progress information, and to implement a certain level of resilience.
8383 /// ````
8384 ///
8385 /// Sets the *delegate* property to the given value.
8386 pub fn delegate(
8387 mut self,
8388 new_value: &'a mut dyn common::Delegate,
8389 ) -> ProjectLocationGetCall<'a, C> {
8390 self._delegate = Some(new_value);
8391 self
8392 }
8393
8394 /// Set any additional parameter of the query string used in the request.
8395 /// It should be used to set parameters which are not yet available through their own
8396 /// setters.
8397 ///
8398 /// Please note that this method must not be used to set any of the known parameters
8399 /// which have their own setter method. If done anyway, the request will fail.
8400 ///
8401 /// # Additional Parameters
8402 ///
8403 /// * *$.xgafv* (query-string) - V1 error format.
8404 /// * *access_token* (query-string) - OAuth access token.
8405 /// * *alt* (query-string) - Data format for response.
8406 /// * *callback* (query-string) - JSONP
8407 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8408 /// * *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.
8409 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8410 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8411 /// * *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.
8412 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8413 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8414 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
8415 where
8416 T: AsRef<str>,
8417 {
8418 self._additional_params
8419 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8420 self
8421 }
8422
8423 /// Identifies the authorization scope for the method you are building.
8424 ///
8425 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8426 /// [`Scope::CloudPlatform`].
8427 ///
8428 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8429 /// tokens for more than one scope.
8430 ///
8431 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8432 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8433 /// sufficient, a read-write scope will do as well.
8434 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
8435 where
8436 St: AsRef<str>,
8437 {
8438 self._scopes.insert(String::from(scope.as_ref()));
8439 self
8440 }
8441 /// Identifies the authorization scope(s) for the method you are building.
8442 ///
8443 /// See [`Self::add_scope()`] for details.
8444 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
8445 where
8446 I: IntoIterator<Item = St>,
8447 St: AsRef<str>,
8448 {
8449 self._scopes
8450 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8451 self
8452 }
8453
8454 /// Removes all scopes, and no default scope will be used either.
8455 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8456 /// for details).
8457 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
8458 self._scopes.clear();
8459 self
8460 }
8461}
8462
8463/// Lists information about the supported locations for this service.
8464///
8465/// A builder for the *locations.list* method supported by a *project* resource.
8466/// It is not used directly, but through a [`ProjectMethods`] instance.
8467///
8468/// # Example
8469///
8470/// Instantiate a resource method builder
8471///
8472/// ```test_harness,no_run
8473/// # extern crate hyper;
8474/// # extern crate hyper_rustls;
8475/// # extern crate google_redis1 as redis1;
8476/// # async fn dox() {
8477/// # use redis1::{CloudRedis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8478///
8479/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8480/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8481/// # secret,
8482/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8483/// # ).build().await.unwrap();
8484///
8485/// # let client = hyper_util::client::legacy::Client::builder(
8486/// # hyper_util::rt::TokioExecutor::new()
8487/// # )
8488/// # .build(
8489/// # hyper_rustls::HttpsConnectorBuilder::new()
8490/// # .with_native_roots()
8491/// # .unwrap()
8492/// # .https_or_http()
8493/// # .enable_http1()
8494/// # .build()
8495/// # );
8496/// # let mut hub = CloudRedis::new(client, auth);
8497/// // You can configure optional parameters by calling the respective setters at will, and
8498/// // execute the final call using `doit()`.
8499/// // Values shown here are possibly random and not representative !
8500/// let result = hub.projects().locations_list("name")
8501/// .page_token("et")
8502/// .page_size(-43)
8503/// .filter("et")
8504/// .doit().await;
8505/// # }
8506/// ```
8507pub struct ProjectLocationListCall<'a, C>
8508where
8509 C: 'a,
8510{
8511 hub: &'a CloudRedis<C>,
8512 _name: String,
8513 _page_token: Option<String>,
8514 _page_size: Option<i32>,
8515 _filter: Option<String>,
8516 _delegate: Option<&'a mut dyn common::Delegate>,
8517 _additional_params: HashMap<String, String>,
8518 _scopes: BTreeSet<String>,
8519}
8520
8521impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
8522
8523impl<'a, C> ProjectLocationListCall<'a, C>
8524where
8525 C: common::Connector,
8526{
8527 /// Perform the operation you have build so far.
8528 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
8529 use std::borrow::Cow;
8530 use std::io::{Read, Seek};
8531
8532 use common::{url::Params, ToParts};
8533 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8534
8535 let mut dd = common::DefaultDelegate;
8536 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8537 dlg.begin(common::MethodInfo {
8538 id: "redis.projects.locations.list",
8539 http_method: hyper::Method::GET,
8540 });
8541
8542 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
8543 if self._additional_params.contains_key(field) {
8544 dlg.finished(false);
8545 return Err(common::Error::FieldClash(field));
8546 }
8547 }
8548
8549 let mut params = Params::with_capacity(6 + self._additional_params.len());
8550 params.push("name", self._name);
8551 if let Some(value) = self._page_token.as_ref() {
8552 params.push("pageToken", value);
8553 }
8554 if let Some(value) = self._page_size.as_ref() {
8555 params.push("pageSize", value.to_string());
8556 }
8557 if let Some(value) = self._filter.as_ref() {
8558 params.push("filter", value);
8559 }
8560
8561 params.extend(self._additional_params.iter());
8562
8563 params.push("alt", "json");
8564 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
8565 if self._scopes.is_empty() {
8566 self._scopes
8567 .insert(Scope::CloudPlatform.as_ref().to_string());
8568 }
8569
8570 #[allow(clippy::single_element_loop)]
8571 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8572 url = params.uri_replacement(url, param_name, find_this, true);
8573 }
8574 {
8575 let to_remove = ["name"];
8576 params.remove_params(&to_remove);
8577 }
8578
8579 let url = params.parse_with_url(&url);
8580
8581 loop {
8582 let token = match self
8583 .hub
8584 .auth
8585 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8586 .await
8587 {
8588 Ok(token) => token,
8589 Err(e) => match dlg.token(e) {
8590 Ok(token) => token,
8591 Err(e) => {
8592 dlg.finished(false);
8593 return Err(common::Error::MissingToken(e));
8594 }
8595 },
8596 };
8597 let mut req_result = {
8598 let client = &self.hub.client;
8599 dlg.pre_request();
8600 let mut req_builder = hyper::Request::builder()
8601 .method(hyper::Method::GET)
8602 .uri(url.as_str())
8603 .header(USER_AGENT, self.hub._user_agent.clone());
8604
8605 if let Some(token) = token.as_ref() {
8606 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8607 }
8608
8609 let request = req_builder
8610 .header(CONTENT_LENGTH, 0_u64)
8611 .body(common::to_body::<String>(None));
8612
8613 client.request(request.unwrap()).await
8614 };
8615
8616 match req_result {
8617 Err(err) => {
8618 if let common::Retry::After(d) = dlg.http_error(&err) {
8619 sleep(d).await;
8620 continue;
8621 }
8622 dlg.finished(false);
8623 return Err(common::Error::HttpError(err));
8624 }
8625 Ok(res) => {
8626 let (mut parts, body) = res.into_parts();
8627 let mut body = common::Body::new(body);
8628 if !parts.status.is_success() {
8629 let bytes = common::to_bytes(body).await.unwrap_or_default();
8630 let error = serde_json::from_str(&common::to_string(&bytes));
8631 let response = common::to_response(parts, bytes.into());
8632
8633 if let common::Retry::After(d) =
8634 dlg.http_failure(&response, error.as_ref().ok())
8635 {
8636 sleep(d).await;
8637 continue;
8638 }
8639
8640 dlg.finished(false);
8641
8642 return Err(match error {
8643 Ok(value) => common::Error::BadRequest(value),
8644 _ => common::Error::Failure(response),
8645 });
8646 }
8647 let response = {
8648 let bytes = common::to_bytes(body).await.unwrap_or_default();
8649 let encoded = common::to_string(&bytes);
8650 match serde_json::from_str(&encoded) {
8651 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8652 Err(error) => {
8653 dlg.response_json_decode_error(&encoded, &error);
8654 return Err(common::Error::JsonDecodeError(
8655 encoded.to_string(),
8656 error,
8657 ));
8658 }
8659 }
8660 };
8661
8662 dlg.finished(true);
8663 return Ok(response);
8664 }
8665 }
8666 }
8667 }
8668
8669 /// The resource that owns the locations collection, if applicable.
8670 ///
8671 /// Sets the *name* path property to the given value.
8672 ///
8673 /// Even though the property as already been set when instantiating this call,
8674 /// we provide this method for API completeness.
8675 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
8676 self._name = new_value.to_string();
8677 self
8678 }
8679 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
8680 ///
8681 /// Sets the *page token* query property to the given value.
8682 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
8683 self._page_token = Some(new_value.to_string());
8684 self
8685 }
8686 /// The maximum number of results to return. If not set, the service selects a default.
8687 ///
8688 /// Sets the *page size* query property to the given value.
8689 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
8690 self._page_size = Some(new_value);
8691 self
8692 }
8693 /// 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).
8694 ///
8695 /// Sets the *filter* query property to the given value.
8696 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
8697 self._filter = Some(new_value.to_string());
8698 self
8699 }
8700 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8701 /// while executing the actual API request.
8702 ///
8703 /// ````text
8704 /// It should be used to handle progress information, and to implement a certain level of resilience.
8705 /// ````
8706 ///
8707 /// Sets the *delegate* property to the given value.
8708 pub fn delegate(
8709 mut self,
8710 new_value: &'a mut dyn common::Delegate,
8711 ) -> ProjectLocationListCall<'a, C> {
8712 self._delegate = Some(new_value);
8713 self
8714 }
8715
8716 /// Set any additional parameter of the query string used in the request.
8717 /// It should be used to set parameters which are not yet available through their own
8718 /// setters.
8719 ///
8720 /// Please note that this method must not be used to set any of the known parameters
8721 /// which have their own setter method. If done anyway, the request will fail.
8722 ///
8723 /// # Additional Parameters
8724 ///
8725 /// * *$.xgafv* (query-string) - V1 error format.
8726 /// * *access_token* (query-string) - OAuth access token.
8727 /// * *alt* (query-string) - Data format for response.
8728 /// * *callback* (query-string) - JSONP
8729 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8730 /// * *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.
8731 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8732 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8733 /// * *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.
8734 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8735 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8736 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
8737 where
8738 T: AsRef<str>,
8739 {
8740 self._additional_params
8741 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8742 self
8743 }
8744
8745 /// Identifies the authorization scope for the method you are building.
8746 ///
8747 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8748 /// [`Scope::CloudPlatform`].
8749 ///
8750 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8751 /// tokens for more than one scope.
8752 ///
8753 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8754 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8755 /// sufficient, a read-write scope will do as well.
8756 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
8757 where
8758 St: AsRef<str>,
8759 {
8760 self._scopes.insert(String::from(scope.as_ref()));
8761 self
8762 }
8763 /// Identifies the authorization scope(s) for the method you are building.
8764 ///
8765 /// See [`Self::add_scope()`] for details.
8766 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
8767 where
8768 I: IntoIterator<Item = St>,
8769 St: AsRef<str>,
8770 {
8771 self._scopes
8772 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8773 self
8774 }
8775
8776 /// Removes all scopes, and no default scope will be used either.
8777 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8778 /// for details).
8779 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
8780 self._scopes.clear();
8781 self
8782 }
8783}