google_cloud_memorystore_v1/client.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Memorystore API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_memorystore_v1::client::Memorystore;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
26/// let client = Memorystore::builder().build().await?;
27/// let parent = "parent_value";
28/// let mut list = client.list_instances()
29/// .set_parent(parent)
30/// .by_item();
31/// while let Some(item) = list.next().await.transpose()? {
32/// println!("{:?}", item);
33/// }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// Service describing handlers for resources
40///
41/// # Configuration
42///
43/// To configure `Memorystore` use the `with_*` methods in the type returned
44/// by [builder()][Memorystore::builder]. The default configuration should
45/// work for most applications. Common configuration changes include
46///
47/// * [with_endpoint()]: by default this client uses the global default endpoint
48/// (`https://memorystore.googleapis.com`). Applications using regional
49/// endpoints or running in restricted networks (e.g. a network configured
50// with [Private Google Access with VPC Service Controls]) may want to
51/// override this default.
52/// * [with_credentials()]: by default this client uses
53/// [Application Default Credentials]. Applications using custom
54/// authentication may need to override this default.
55///
56/// [with_endpoint()]: super::builder::memorystore::ClientBuilder::with_endpoint
57/// [with_credentials()]: super::builder::memorystore::ClientBuilder::with_credentials
58/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
59/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
60///
61/// # Pooling and Cloning
62///
63/// `Memorystore` holds a connection pool internally, it is advised to
64/// create one and reuse it. You do not need to wrap `Memorystore` in
65/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
66/// already uses an `Arc` internally.
67#[derive(Clone, Debug)]
68pub struct Memorystore {
69 inner: std::sync::Arc<dyn super::stub::dynamic::Memorystore>,
70}
71
72impl Memorystore {
73 /// Returns a builder for [Memorystore].
74 ///
75 /// ```
76 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
77 /// # use google_cloud_memorystore_v1::client::Memorystore;
78 /// let client = Memorystore::builder().build().await?;
79 /// # Ok(()) }
80 /// ```
81 pub fn builder() -> super::builder::memorystore::ClientBuilder {
82 crate::new_client_builder(super::builder::memorystore::client::Factory)
83 }
84
85 /// Creates a new client from the provided stub.
86 ///
87 /// The most common case for calling this function is in tests mocking the
88 /// client's behavior.
89 pub fn from_stub<T>(stub: T) -> Self
90 where
91 T: super::stub::Memorystore + 'static,
92 {
93 Self {
94 inner: std::sync::Arc::new(stub),
95 }
96 }
97
98 pub(crate) async fn new(
99 config: gaxi::options::ClientConfig,
100 ) -> crate::ClientBuilderResult<Self> {
101 let inner = Self::build_inner(config).await?;
102 Ok(Self { inner })
103 }
104
105 async fn build_inner(
106 conf: gaxi::options::ClientConfig,
107 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Memorystore>> {
108 if gaxi::options::tracing_enabled(&conf) {
109 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
110 }
111 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
112 }
113
114 async fn build_transport(
115 conf: gaxi::options::ClientConfig,
116 ) -> crate::ClientBuilderResult<impl super::stub::Memorystore> {
117 super::transport::Memorystore::new(conf).await
118 }
119
120 async fn build_with_tracing(
121 conf: gaxi::options::ClientConfig,
122 ) -> crate::ClientBuilderResult<impl super::stub::Memorystore> {
123 Self::build_transport(conf)
124 .await
125 .map(super::tracing::Memorystore::new)
126 }
127
128 /// Lists Instances in a given project and location.
129 ///
130 /// # Example
131 /// ```
132 /// # use google_cloud_memorystore_v1::client::Memorystore;
133 /// use google_cloud_gax::paginator::ItemPaginator as _;
134 /// use google_cloud_memorystore_v1::Result;
135 /// async fn sample(
136 /// client: &Memorystore, parent: &str
137 /// ) -> Result<()> {
138 /// let mut list = client.list_instances()
139 /// .set_parent(parent)
140 /// .by_item();
141 /// while let Some(item) = list.next().await.transpose()? {
142 /// println!("{:?}", item);
143 /// }
144 /// Ok(())
145 /// }
146 /// ```
147 pub fn list_instances(&self) -> super::builder::memorystore::ListInstances {
148 super::builder::memorystore::ListInstances::new(self.inner.clone())
149 }
150
151 /// Gets details of a single Instance.
152 ///
153 /// # Example
154 /// ```
155 /// # use google_cloud_memorystore_v1::client::Memorystore;
156 /// use google_cloud_memorystore_v1::Result;
157 /// async fn sample(
158 /// client: &Memorystore, name: &str
159 /// ) -> Result<()> {
160 /// let response = client.get_instance()
161 /// .set_name(name)
162 /// .send().await?;
163 /// println!("response {:?}", response);
164 /// Ok(())
165 /// }
166 /// ```
167 pub fn get_instance(&self) -> super::builder::memorystore::GetInstance {
168 super::builder::memorystore::GetInstance::new(self.inner.clone())
169 }
170
171 /// Creates a new Instance in a given project and location.
172 ///
173 /// # Long running operations
174 ///
175 /// This method is used to start, and/or poll a [long-running Operation].
176 /// The [Working with long-running operations] chapter in the [user guide]
177 /// covers these operations in detail.
178 ///
179 /// [long-running operation]: https://google.aip.dev/151
180 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
181 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
182 ///
183 /// # Example
184 /// ```
185 /// # use google_cloud_memorystore_v1::client::Memorystore;
186 /// use google_cloud_lro::Poller;
187 /// use google_cloud_memorystore_v1::model::Instance;
188 /// use google_cloud_memorystore_v1::Result;
189 /// async fn sample(
190 /// client: &Memorystore, parent: &str
191 /// ) -> Result<()> {
192 /// let response = client.create_instance()
193 /// .set_parent(parent)
194 /// .set_instance_id("instance_id_value")
195 /// .set_instance(
196 /// Instance::new()/* set fields */
197 /// )
198 /// .poller().until_done().await?;
199 /// println!("response {:?}", response);
200 /// Ok(())
201 /// }
202 /// ```
203 pub fn create_instance(&self) -> super::builder::memorystore::CreateInstance {
204 super::builder::memorystore::CreateInstance::new(self.inner.clone())
205 }
206
207 /// Updates the parameters of a single Instance.
208 ///
209 /// # Long running operations
210 ///
211 /// This method is used to start, and/or poll a [long-running Operation].
212 /// The [Working with long-running operations] chapter in the [user guide]
213 /// covers these operations in detail.
214 ///
215 /// [long-running operation]: https://google.aip.dev/151
216 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
217 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
218 ///
219 /// # Example
220 /// ```
221 /// # use google_cloud_memorystore_v1::client::Memorystore;
222 /// use google_cloud_lro::Poller;
223 /// # extern crate wkt as google_cloud_wkt;
224 /// use google_cloud_wkt::FieldMask;
225 /// use google_cloud_memorystore_v1::model::Instance;
226 /// use google_cloud_memorystore_v1::Result;
227 /// async fn sample(
228 /// client: &Memorystore, name: &str
229 /// ) -> Result<()> {
230 /// let response = client.update_instance()
231 /// .set_instance(
232 /// Instance::new().set_name(name)/* set fields */
233 /// )
234 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
235 /// .poller().until_done().await?;
236 /// println!("response {:?}", response);
237 /// Ok(())
238 /// }
239 /// ```
240 pub fn update_instance(&self) -> super::builder::memorystore::UpdateInstance {
241 super::builder::memorystore::UpdateInstance::new(self.inner.clone())
242 }
243
244 /// Deletes a single Instance.
245 ///
246 /// # Long running operations
247 ///
248 /// This method is used to start, and/or poll a [long-running Operation].
249 /// The [Working with long-running operations] chapter in the [user guide]
250 /// covers these operations in detail.
251 ///
252 /// [long-running operation]: https://google.aip.dev/151
253 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
254 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
255 ///
256 /// # Example
257 /// ```
258 /// # use google_cloud_memorystore_v1::client::Memorystore;
259 /// use google_cloud_lro::Poller;
260 /// use google_cloud_memorystore_v1::Result;
261 /// async fn sample(
262 /// client: &Memorystore, name: &str
263 /// ) -> Result<()> {
264 /// client.delete_instance()
265 /// .set_name(name)
266 /// .poller().until_done().await?;
267 /// Ok(())
268 /// }
269 /// ```
270 pub fn delete_instance(&self) -> super::builder::memorystore::DeleteInstance {
271 super::builder::memorystore::DeleteInstance::new(self.inner.clone())
272 }
273
274 /// Gets details about the certificate authority for an Instance.
275 ///
276 /// # Example
277 /// ```
278 /// # use google_cloud_memorystore_v1::client::Memorystore;
279 /// use google_cloud_memorystore_v1::Result;
280 /// async fn sample(
281 /// client: &Memorystore
282 /// ) -> Result<()> {
283 /// let response = client.get_certificate_authority()
284 /// /* set fields */
285 /// .send().await?;
286 /// println!("response {:?}", response);
287 /// Ok(())
288 /// }
289 /// ```
290 pub fn get_certificate_authority(
291 &self,
292 ) -> super::builder::memorystore::GetCertificateAuthority {
293 super::builder::memorystore::GetCertificateAuthority::new(self.inner.clone())
294 }
295
296 /// Reschedules upcoming maintenance event.
297 ///
298 /// # Long running operations
299 ///
300 /// This method is used to start, and/or poll a [long-running Operation].
301 /// The [Working with long-running operations] chapter in the [user guide]
302 /// covers these operations in detail.
303 ///
304 /// [long-running operation]: https://google.aip.dev/151
305 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
306 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
307 ///
308 /// # Example
309 /// ```
310 /// # use google_cloud_memorystore_v1::client::Memorystore;
311 /// use google_cloud_lro::Poller;
312 /// use google_cloud_memorystore_v1::Result;
313 /// async fn sample(
314 /// client: &Memorystore
315 /// ) -> Result<()> {
316 /// let response = client.reschedule_maintenance()
317 /// /* set fields */
318 /// .poller().until_done().await?;
319 /// println!("response {:?}", response);
320 /// Ok(())
321 /// }
322 /// ```
323 pub fn reschedule_maintenance(&self) -> super::builder::memorystore::RescheduleMaintenance {
324 super::builder::memorystore::RescheduleMaintenance::new(self.inner.clone())
325 }
326
327 /// Lists all backup collections owned by a consumer project in either the
328 /// specified location (region) or all locations.
329 ///
330 /// If `location_id` is specified as `-` (wildcard), then all regions
331 /// available to the project are queried, and the results are aggregated.
332 ///
333 /// # Example
334 /// ```
335 /// # use google_cloud_memorystore_v1::client::Memorystore;
336 /// use google_cloud_gax::paginator::ItemPaginator as _;
337 /// use google_cloud_memorystore_v1::Result;
338 /// async fn sample(
339 /// client: &Memorystore, parent: &str
340 /// ) -> Result<()> {
341 /// let mut list = client.list_backup_collections()
342 /// .set_parent(parent)
343 /// .by_item();
344 /// while let Some(item) = list.next().await.transpose()? {
345 /// println!("{:?}", item);
346 /// }
347 /// Ok(())
348 /// }
349 /// ```
350 pub fn list_backup_collections(&self) -> super::builder::memorystore::ListBackupCollections {
351 super::builder::memorystore::ListBackupCollections::new(self.inner.clone())
352 }
353
354 /// Get a backup collection.
355 ///
356 /// # Example
357 /// ```
358 /// # use google_cloud_memorystore_v1::client::Memorystore;
359 /// use google_cloud_memorystore_v1::Result;
360 /// async fn sample(
361 /// client: &Memorystore, name: &str
362 /// ) -> Result<()> {
363 /// let response = client.get_backup_collection()
364 /// .set_name(name)
365 /// .send().await?;
366 /// println!("response {:?}", response);
367 /// Ok(())
368 /// }
369 /// ```
370 pub fn get_backup_collection(&self) -> super::builder::memorystore::GetBackupCollection {
371 super::builder::memorystore::GetBackupCollection::new(self.inner.clone())
372 }
373
374 /// Lists all backups owned by a backup collection.
375 ///
376 /// # Example
377 /// ```
378 /// # use google_cloud_memorystore_v1::client::Memorystore;
379 /// use google_cloud_gax::paginator::ItemPaginator as _;
380 /// use google_cloud_memorystore_v1::Result;
381 /// async fn sample(
382 /// client: &Memorystore, parent: &str
383 /// ) -> Result<()> {
384 /// let mut list = client.list_backups()
385 /// .set_parent(parent)
386 /// .by_item();
387 /// while let Some(item) = list.next().await.transpose()? {
388 /// println!("{:?}", item);
389 /// }
390 /// Ok(())
391 /// }
392 /// ```
393 pub fn list_backups(&self) -> super::builder::memorystore::ListBackups {
394 super::builder::memorystore::ListBackups::new(self.inner.clone())
395 }
396
397 /// Gets the details of a specific backup.
398 ///
399 /// # Example
400 /// ```
401 /// # use google_cloud_memorystore_v1::client::Memorystore;
402 /// use google_cloud_memorystore_v1::Result;
403 /// async fn sample(
404 /// client: &Memorystore, name: &str
405 /// ) -> Result<()> {
406 /// let response = client.get_backup()
407 /// .set_name(name)
408 /// .send().await?;
409 /// println!("response {:?}", response);
410 /// Ok(())
411 /// }
412 /// ```
413 pub fn get_backup(&self) -> super::builder::memorystore::GetBackup {
414 super::builder::memorystore::GetBackup::new(self.inner.clone())
415 }
416
417 /// Deletes a specific backup.
418 ///
419 /// # Long running operations
420 ///
421 /// This method is used to start, and/or poll a [long-running Operation].
422 /// The [Working with long-running operations] chapter in the [user guide]
423 /// covers these operations in detail.
424 ///
425 /// [long-running operation]: https://google.aip.dev/151
426 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
427 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
428 ///
429 /// # Example
430 /// ```
431 /// # use google_cloud_memorystore_v1::client::Memorystore;
432 /// use google_cloud_lro::Poller;
433 /// use google_cloud_memorystore_v1::Result;
434 /// async fn sample(
435 /// client: &Memorystore, name: &str
436 /// ) -> Result<()> {
437 /// client.delete_backup()
438 /// .set_name(name)
439 /// .poller().until_done().await?;
440 /// Ok(())
441 /// }
442 /// ```
443 pub fn delete_backup(&self) -> super::builder::memorystore::DeleteBackup {
444 super::builder::memorystore::DeleteBackup::new(self.inner.clone())
445 }
446
447 /// Exports a specific backup to a customer target Cloud Storage URI.
448 ///
449 /// # Long running operations
450 ///
451 /// This method is used to start, and/or poll a [long-running Operation].
452 /// The [Working with long-running operations] chapter in the [user guide]
453 /// covers these operations in detail.
454 ///
455 /// [long-running operation]: https://google.aip.dev/151
456 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
457 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
458 ///
459 /// # Example
460 /// ```
461 /// # use google_cloud_memorystore_v1::client::Memorystore;
462 /// use google_cloud_lro::Poller;
463 /// use google_cloud_memorystore_v1::Result;
464 /// async fn sample(
465 /// client: &Memorystore
466 /// ) -> Result<()> {
467 /// let response = client.export_backup()
468 /// /* set fields */
469 /// .poller().until_done().await?;
470 /// println!("response {:?}", response);
471 /// Ok(())
472 /// }
473 /// ```
474 pub fn export_backup(&self) -> super::builder::memorystore::ExportBackup {
475 super::builder::memorystore::ExportBackup::new(self.inner.clone())
476 }
477
478 /// Backup Instance.
479 /// If this is the first time a backup is being created, a backup collection
480 /// will be created at the backend, and this backup belongs to this collection.
481 /// Both collection and backup will have a resource name. Backup will be
482 /// executed for each shard. A replica (primary if nonHA) will be selected to
483 /// perform the execution. Backup call will be rejected if there is an ongoing
484 /// backup or update operation. Be aware that during preview, if the instance's
485 /// internal software version is too old, critical update will be performed
486 /// before actual backup. Once the internal software version is updated to the
487 /// minimum version required by the backup feature, subsequent backups will not
488 /// require critical update. After preview, there will be no critical update
489 /// needed for backup.
490 ///
491 /// # Long running operations
492 ///
493 /// This method is used to start, and/or poll a [long-running Operation].
494 /// The [Working with long-running operations] chapter in the [user guide]
495 /// covers these operations in detail.
496 ///
497 /// [long-running operation]: https://google.aip.dev/151
498 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
499 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
500 ///
501 /// # Example
502 /// ```
503 /// # use google_cloud_memorystore_v1::client::Memorystore;
504 /// use google_cloud_lro::Poller;
505 /// use google_cloud_memorystore_v1::Result;
506 /// async fn sample(
507 /// client: &Memorystore
508 /// ) -> Result<()> {
509 /// let response = client.backup_instance()
510 /// /* set fields */
511 /// .poller().until_done().await?;
512 /// println!("response {:?}", response);
513 /// Ok(())
514 /// }
515 /// ```
516 pub fn backup_instance(&self) -> super::builder::memorystore::BackupInstance {
517 super::builder::memorystore::BackupInstance::new(self.inner.clone())
518 }
519
520 /// Lists information about the supported locations for this service.
521 ///
522 /// # Example
523 /// ```
524 /// # use google_cloud_memorystore_v1::client::Memorystore;
525 /// use google_cloud_gax::paginator::ItemPaginator as _;
526 /// use google_cloud_memorystore_v1::Result;
527 /// async fn sample(
528 /// client: &Memorystore
529 /// ) -> Result<()> {
530 /// let mut list = client.list_locations()
531 /// /* set fields */
532 /// .by_item();
533 /// while let Some(item) = list.next().await.transpose()? {
534 /// println!("{:?}", item);
535 /// }
536 /// Ok(())
537 /// }
538 /// ```
539 pub fn list_locations(&self) -> super::builder::memorystore::ListLocations {
540 super::builder::memorystore::ListLocations::new(self.inner.clone())
541 }
542
543 /// Gets information about a location.
544 ///
545 /// # Example
546 /// ```
547 /// # use google_cloud_memorystore_v1::client::Memorystore;
548 /// use google_cloud_memorystore_v1::Result;
549 /// async fn sample(
550 /// client: &Memorystore
551 /// ) -> Result<()> {
552 /// let response = client.get_location()
553 /// /* set fields */
554 /// .send().await?;
555 /// println!("response {:?}", response);
556 /// Ok(())
557 /// }
558 /// ```
559 pub fn get_location(&self) -> super::builder::memorystore::GetLocation {
560 super::builder::memorystore::GetLocation::new(self.inner.clone())
561 }
562
563 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
564 ///
565 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
566 ///
567 /// # Example
568 /// ```
569 /// # use google_cloud_memorystore_v1::client::Memorystore;
570 /// use google_cloud_gax::paginator::ItemPaginator as _;
571 /// use google_cloud_memorystore_v1::Result;
572 /// async fn sample(
573 /// client: &Memorystore
574 /// ) -> Result<()> {
575 /// let mut list = client.list_operations()
576 /// /* set fields */
577 /// .by_item();
578 /// while let Some(item) = list.next().await.transpose()? {
579 /// println!("{:?}", item);
580 /// }
581 /// Ok(())
582 /// }
583 /// ```
584 pub fn list_operations(&self) -> super::builder::memorystore::ListOperations {
585 super::builder::memorystore::ListOperations::new(self.inner.clone())
586 }
587
588 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
589 ///
590 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
591 ///
592 /// # Example
593 /// ```
594 /// # use google_cloud_memorystore_v1::client::Memorystore;
595 /// use google_cloud_memorystore_v1::Result;
596 /// async fn sample(
597 /// client: &Memorystore
598 /// ) -> Result<()> {
599 /// let response = client.get_operation()
600 /// /* set fields */
601 /// .send().await?;
602 /// println!("response {:?}", response);
603 /// Ok(())
604 /// }
605 /// ```
606 pub fn get_operation(&self) -> super::builder::memorystore::GetOperation {
607 super::builder::memorystore::GetOperation::new(self.inner.clone())
608 }
609
610 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
611 ///
612 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
613 ///
614 /// # Example
615 /// ```
616 /// # use google_cloud_memorystore_v1::client::Memorystore;
617 /// use google_cloud_memorystore_v1::Result;
618 /// async fn sample(
619 /// client: &Memorystore
620 /// ) -> Result<()> {
621 /// client.delete_operation()
622 /// /* set fields */
623 /// .send().await?;
624 /// Ok(())
625 /// }
626 /// ```
627 pub fn delete_operation(&self) -> super::builder::memorystore::DeleteOperation {
628 super::builder::memorystore::DeleteOperation::new(self.inner.clone())
629 }
630
631 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
632 ///
633 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
634 ///
635 /// # Example
636 /// ```
637 /// # use google_cloud_memorystore_v1::client::Memorystore;
638 /// use google_cloud_memorystore_v1::Result;
639 /// async fn sample(
640 /// client: &Memorystore
641 /// ) -> Result<()> {
642 /// client.cancel_operation()
643 /// /* set fields */
644 /// .send().await?;
645 /// Ok(())
646 /// }
647 /// ```
648 pub fn cancel_operation(&self) -> super::builder::memorystore::CancelOperation {
649 super::builder::memorystore::CancelOperation::new(self.inner.clone())
650 }
651}