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/// # tokio_test::block_on(async {
24/// # use google_cloud_memorystore_v1::client::Memorystore;
25/// let client = Memorystore::builder().build().await?;
26/// // use `client` to make requests to the Memorystore API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Service describing handlers for resources
33///
34/// # Configuration
35///
36/// To configure `Memorystore` use the `with_*` methods in the type returned
37/// by [builder()][Memorystore::builder]. The default configuration should
38/// work for most applications. Common configuration changes include
39///
40/// * [with_endpoint()]: by default this client uses the global default endpoint
41/// (`https://memorystore.googleapis.com`). Applications using regional
42/// endpoints or running in restricted networks (e.g. a network configured
43// with [Private Google Access with VPC Service Controls]) may want to
44/// override this default.
45/// * [with_credentials()]: by default this client uses
46/// [Application Default Credentials]. Applications using custom
47/// authentication may need to override this default.
48///
49/// [with_endpoint()]: super::builder::memorystore::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::memorystore::ClientBuilder::credentials
51/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
52/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
53///
54/// # Pooling and Cloning
55///
56/// `Memorystore` holds a connection pool internally, it is advised to
57/// create one and the reuse it. You do not need to wrap `Memorystore` in
58/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
59/// already uses an `Arc` internally.
60#[derive(Clone, Debug)]
61pub struct Memorystore {
62 inner: std::sync::Arc<dyn super::stub::dynamic::Memorystore>,
63}
64
65impl Memorystore {
66 /// Returns a builder for [Memorystore].
67 ///
68 /// ```
69 /// # tokio_test::block_on(async {
70 /// # use google_cloud_memorystore_v1::client::Memorystore;
71 /// let client = Memorystore::builder().build().await?;
72 /// # gax::client_builder::Result::<()>::Ok(()) });
73 /// ```
74 pub fn builder() -> super::builder::memorystore::ClientBuilder {
75 gax::client_builder::internal::new_builder(super::builder::memorystore::client::Factory)
76 }
77
78 /// Creates a new client from the provided stub.
79 ///
80 /// The most common case for calling this function is in tests mocking the
81 /// client's behavior.
82 pub fn from_stub<T>(stub: T) -> Self
83 where
84 T: super::stub::Memorystore + 'static,
85 {
86 Self {
87 inner: std::sync::Arc::new(stub),
88 }
89 }
90
91 pub(crate) async fn new(
92 config: gaxi::options::ClientConfig,
93 ) -> gax::client_builder::Result<Self> {
94 let inner = Self::build_inner(config).await?;
95 Ok(Self { inner })
96 }
97
98 async fn build_inner(
99 conf: gaxi::options::ClientConfig,
100 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Memorystore>> {
101 if gaxi::options::tracing_enabled(&conf) {
102 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
103 }
104 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
105 }
106
107 async fn build_transport(
108 conf: gaxi::options::ClientConfig,
109 ) -> gax::client_builder::Result<impl super::stub::Memorystore> {
110 super::transport::Memorystore::new(conf).await
111 }
112
113 async fn build_with_tracing(
114 conf: gaxi::options::ClientConfig,
115 ) -> gax::client_builder::Result<impl super::stub::Memorystore> {
116 Self::build_transport(conf)
117 .await
118 .map(super::tracing::Memorystore::new)
119 }
120
121 /// Lists Instances in a given project and location.
122 pub fn list_instances(&self) -> super::builder::memorystore::ListInstances {
123 super::builder::memorystore::ListInstances::new(self.inner.clone())
124 }
125
126 /// Gets details of a single Instance.
127 pub fn get_instance(&self) -> super::builder::memorystore::GetInstance {
128 super::builder::memorystore::GetInstance::new(self.inner.clone())
129 }
130
131 /// Creates a new Instance in a given project and location.
132 ///
133 /// # Long running operations
134 ///
135 /// This method is used to start, and/or poll a [long-running Operation].
136 /// The [Working with long-running operations] chapter in the [user guide]
137 /// covers these operations in detail.
138 ///
139 /// [long-running operation]: https://google.aip.dev/151
140 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
141 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
142 pub fn create_instance(&self) -> super::builder::memorystore::CreateInstance {
143 super::builder::memorystore::CreateInstance::new(self.inner.clone())
144 }
145
146 /// Updates the parameters of a single Instance.
147 ///
148 /// # Long running operations
149 ///
150 /// This method is used to start, and/or poll a [long-running Operation].
151 /// The [Working with long-running operations] chapter in the [user guide]
152 /// covers these operations in detail.
153 ///
154 /// [long-running operation]: https://google.aip.dev/151
155 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
156 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
157 pub fn update_instance(&self) -> super::builder::memorystore::UpdateInstance {
158 super::builder::memorystore::UpdateInstance::new(self.inner.clone())
159 }
160
161 /// Deletes a single Instance.
162 ///
163 /// # Long running operations
164 ///
165 /// This method is used to start, and/or poll a [long-running Operation].
166 /// The [Working with long-running operations] chapter in the [user guide]
167 /// covers these operations in detail.
168 ///
169 /// [long-running operation]: https://google.aip.dev/151
170 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
171 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
172 pub fn delete_instance(&self) -> super::builder::memorystore::DeleteInstance {
173 super::builder::memorystore::DeleteInstance::new(self.inner.clone())
174 }
175
176 /// Gets details about the certificate authority for an Instance.
177 pub fn get_certificate_authority(
178 &self,
179 ) -> super::builder::memorystore::GetCertificateAuthority {
180 super::builder::memorystore::GetCertificateAuthority::new(self.inner.clone())
181 }
182
183 /// Reschedules upcoming maintenance event.
184 ///
185 /// # Long running operations
186 ///
187 /// This method is used to start, and/or poll a [long-running Operation].
188 /// The [Working with long-running operations] chapter in the [user guide]
189 /// covers these operations in detail.
190 ///
191 /// [long-running operation]: https://google.aip.dev/151
192 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
193 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
194 pub fn reschedule_maintenance(&self) -> super::builder::memorystore::RescheduleMaintenance {
195 super::builder::memorystore::RescheduleMaintenance::new(self.inner.clone())
196 }
197
198 /// Lists all backup collections owned by a consumer project in either the
199 /// specified location (region) or all locations.
200 ///
201 /// If `location_id` is specified as `-` (wildcard), then all regions
202 /// available to the project are queried, and the results are aggregated.
203 pub fn list_backup_collections(&self) -> super::builder::memorystore::ListBackupCollections {
204 super::builder::memorystore::ListBackupCollections::new(self.inner.clone())
205 }
206
207 /// Get a backup collection.
208 pub fn get_backup_collection(&self) -> super::builder::memorystore::GetBackupCollection {
209 super::builder::memorystore::GetBackupCollection::new(self.inner.clone())
210 }
211
212 /// Lists all backups owned by a backup collection.
213 pub fn list_backups(&self) -> super::builder::memorystore::ListBackups {
214 super::builder::memorystore::ListBackups::new(self.inner.clone())
215 }
216
217 /// Gets the details of a specific backup.
218 pub fn get_backup(&self) -> super::builder::memorystore::GetBackup {
219 super::builder::memorystore::GetBackup::new(self.inner.clone())
220 }
221
222 /// Deletes a specific backup.
223 ///
224 /// # Long running operations
225 ///
226 /// This method is used to start, and/or poll a [long-running Operation].
227 /// The [Working with long-running operations] chapter in the [user guide]
228 /// covers these operations in detail.
229 ///
230 /// [long-running operation]: https://google.aip.dev/151
231 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
232 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
233 pub fn delete_backup(&self) -> super::builder::memorystore::DeleteBackup {
234 super::builder::memorystore::DeleteBackup::new(self.inner.clone())
235 }
236
237 /// Exports a specific backup to a customer target Cloud Storage URI.
238 ///
239 /// # Long running operations
240 ///
241 /// This method is used to start, and/or poll a [long-running Operation].
242 /// The [Working with long-running operations] chapter in the [user guide]
243 /// covers these operations in detail.
244 ///
245 /// [long-running operation]: https://google.aip.dev/151
246 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
247 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
248 pub fn export_backup(&self) -> super::builder::memorystore::ExportBackup {
249 super::builder::memorystore::ExportBackup::new(self.inner.clone())
250 }
251
252 /// Backup Instance.
253 /// If this is the first time a backup is being created, a backup collection
254 /// will be created at the backend, and this backup belongs to this collection.
255 /// Both collection and backup will have a resource name. Backup will be
256 /// executed for each shard. A replica (primary if nonHA) will be selected to
257 /// perform the execution. Backup call will be rejected if there is an ongoing
258 /// backup or update operation. Be aware that during preview, if the instance's
259 /// internal software version is too old, critical update will be performed
260 /// before actual backup. Once the internal software version is updated to the
261 /// minimum version required by the backup feature, subsequent backups will not
262 /// require critical update. After preview, there will be no critical update
263 /// needed for backup.
264 ///
265 /// # Long running operations
266 ///
267 /// This method is used to start, and/or poll a [long-running Operation].
268 /// The [Working with long-running operations] chapter in the [user guide]
269 /// covers these operations in detail.
270 ///
271 /// [long-running operation]: https://google.aip.dev/151
272 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
273 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
274 pub fn backup_instance(&self) -> super::builder::memorystore::BackupInstance {
275 super::builder::memorystore::BackupInstance::new(self.inner.clone())
276 }
277
278 /// Lists information about the supported locations for this service.
279 pub fn list_locations(&self) -> super::builder::memorystore::ListLocations {
280 super::builder::memorystore::ListLocations::new(self.inner.clone())
281 }
282
283 /// Gets information about a location.
284 pub fn get_location(&self) -> super::builder::memorystore::GetLocation {
285 super::builder::memorystore::GetLocation::new(self.inner.clone())
286 }
287
288 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
289 ///
290 /// [google.longrunning.Operations]: longrunning::client::Operations
291 pub fn list_operations(&self) -> super::builder::memorystore::ListOperations {
292 super::builder::memorystore::ListOperations::new(self.inner.clone())
293 }
294
295 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
296 ///
297 /// [google.longrunning.Operations]: longrunning::client::Operations
298 pub fn get_operation(&self) -> super::builder::memorystore::GetOperation {
299 super::builder::memorystore::GetOperation::new(self.inner.clone())
300 }
301
302 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
303 ///
304 /// [google.longrunning.Operations]: longrunning::client::Operations
305 pub fn delete_operation(&self) -> super::builder::memorystore::DeleteOperation {
306 super::builder::memorystore::DeleteOperation::new(self.inner.clone())
307 }
308
309 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
310 ///
311 /// [google.longrunning.Operations]: longrunning::client::Operations
312 pub fn cancel_operation(&self) -> super::builder::memorystore::CancelOperation {
313 super::builder::memorystore::CancelOperation::new(self.inner.clone())
314 }
315}