google_cloud_spanner_admin_instance_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 Cloud Spanner API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_spanner_admin_instance_v1::client::InstanceAdmin;
25/// let client = InstanceAdmin::builder().build().await?;
26/// // use `client` to make requests to the Cloud Spanner API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Cloud Spanner Instance Admin API
33///
34/// The Cloud Spanner Instance Admin API can be used to create, delete,
35/// modify and list instances. Instances are dedicated Cloud Spanner serving
36/// and storage resources to be used by Cloud Spanner databases.
37///
38/// Each instance has a "configuration", which dictates where the
39/// serving resources for the Cloud Spanner instance are located (e.g.,
40/// US-central, Europe). Configurations are created by Google based on
41/// resource availability.
42///
43/// Cloud Spanner billing is based on the instances that exist and their
44/// sizes. After an instance exists, there are no additional
45/// per-database or per-operation charges for use of the instance
46/// (though there may be additional network bandwidth charges).
47/// Instances offer isolation: problems with databases in one instance
48/// will not affect other instances. However, within an instance
49/// databases can affect each other. For example, if one database in an
50/// instance receives a lot of requests and consumes most of the
51/// instance resources, fewer resources are available for other
52/// databases in that instance, and their performance may suffer.
53///
54/// # Configuration
55///
56/// To configure `InstanceAdmin` use the `with_*` methods in the type returned
57/// by [builder()][InstanceAdmin::builder]. The default configuration should
58/// work for most applications. Common configuration changes include
59///
60/// * [with_endpoint()]: by default this client uses the global default endpoint
61///   (`https://spanner.googleapis.com`). Applications using regional
62///   endpoints or running in restricted networks (e.g. a network configured
63//    with [Private Google Access with VPC Service Controls]) may want to
64///   override this default.
65/// * [with_credentials()]: by default this client uses
66///   [Application Default Credentials]. Applications using custom
67///   authentication may need to override this default.
68///
69/// [with_endpoint()]: super::builder::instance_admin::ClientBuilder::with_endpoint
70/// [with_credentials()]: super::builder::instance_admin::ClientBuilder::credentials
71/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
72/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
73///
74/// # Pooling and Cloning
75///
76/// `InstanceAdmin` holds a connection pool internally, it is advised to
77/// create one and the reuse it.  You do not need to wrap `InstanceAdmin` in
78/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
79/// already uses an `Arc` internally.
80#[derive(Clone, Debug)]
81pub struct InstanceAdmin {
82    inner: std::sync::Arc<dyn super::stub::dynamic::InstanceAdmin>,
83}
84
85impl InstanceAdmin {
86    /// Returns a builder for [InstanceAdmin].
87    ///
88    /// ```
89    /// # tokio_test::block_on(async {
90    /// # use google_cloud_spanner_admin_instance_v1::client::InstanceAdmin;
91    /// let client = InstanceAdmin::builder().build().await?;
92    /// # gax::client_builder::Result::<()>::Ok(()) });
93    /// ```
94    pub fn builder() -> super::builder::instance_admin::ClientBuilder {
95        gax::client_builder::internal::new_builder(super::builder::instance_admin::client::Factory)
96    }
97
98    /// Creates a new client from the provided stub.
99    ///
100    /// The most common case for calling this function is in tests mocking the
101    /// client's behavior.
102    pub fn from_stub<T>(stub: T) -> Self
103    where
104        T: super::stub::InstanceAdmin + 'static,
105    {
106        Self {
107            inner: std::sync::Arc::new(stub),
108        }
109    }
110
111    pub(crate) async fn new(
112        config: gaxi::options::ClientConfig,
113    ) -> gax::client_builder::Result<Self> {
114        let inner = Self::build_inner(config).await?;
115        Ok(Self { inner })
116    }
117
118    async fn build_inner(
119        conf: gaxi::options::ClientConfig,
120    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::InstanceAdmin>> {
121        if gaxi::options::tracing_enabled(&conf) {
122            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
123        }
124        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
125    }
126
127    async fn build_transport(
128        conf: gaxi::options::ClientConfig,
129    ) -> gax::client_builder::Result<impl super::stub::InstanceAdmin> {
130        super::transport::InstanceAdmin::new(conf).await
131    }
132
133    async fn build_with_tracing(
134        conf: gaxi::options::ClientConfig,
135    ) -> gax::client_builder::Result<impl super::stub::InstanceAdmin> {
136        Self::build_transport(conf)
137            .await
138            .map(super::tracing::InstanceAdmin::new)
139    }
140
141    /// Lists the supported instance configurations for a given project.
142    ///
143    /// Returns both Google-managed configurations and user-managed
144    /// configurations.
145    pub fn list_instance_configs(&self) -> super::builder::instance_admin::ListInstanceConfigs {
146        super::builder::instance_admin::ListInstanceConfigs::new(self.inner.clone())
147    }
148
149    /// Gets information about a particular instance configuration.
150    pub fn get_instance_config(&self) -> super::builder::instance_admin::GetInstanceConfig {
151        super::builder::instance_admin::GetInstanceConfig::new(self.inner.clone())
152    }
153
154    /// Creates an instance configuration and begins preparing it to be used. The
155    /// returned long-running operation
156    /// can be used to track the progress of preparing the new
157    /// instance configuration. The instance configuration name is assigned by the
158    /// caller. If the named instance configuration already exists,
159    /// `CreateInstanceConfig` returns `ALREADY_EXISTS`.
160    ///
161    /// Immediately after the request returns:
162    ///
163    /// * The instance configuration is readable via the API, with all requested
164    ///   attributes. The instance configuration's
165    ///   [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
166    ///   field is set to true. Its state is `CREATING`.
167    ///
168    /// While the operation is pending:
169    ///
170    /// * Cancelling the operation renders the instance configuration immediately
171    ///   unreadable via the API.
172    /// * Except for deleting the creating resource, all other attempts to modify
173    ///   the instance configuration are rejected.
174    ///
175    /// Upon completion of the returned operation:
176    ///
177    /// * Instances can be created using the instance configuration.
178    /// * The instance configuration's
179    ///   [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
180    ///   field becomes false. Its state becomes `READY`.
181    ///
182    /// The returned long-running operation will
183    /// have a name of the format
184    /// `<instance_config_name>/operations/<operation_id>` and can be used to track
185    /// creation of the instance configuration. The
186    /// metadata field type is
187    /// [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata].
188    /// The response field type is
189    /// [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if
190    /// successful.
191    ///
192    /// Authorization requires `spanner.instanceConfigs.create` permission on
193    /// the resource
194    /// [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent].
195    ///
196    /// [google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]: crate::model::CreateInstanceConfigMetadata
197    /// [google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]: crate::model::CreateInstanceConfigRequest::parent
198    /// [google.spanner.admin.instance.v1.InstanceConfig]: crate::model::InstanceConfig
199    /// [google.spanner.admin.instance.v1.InstanceConfig.reconciling]: crate::model::InstanceConfig::reconciling
200    ///
201    /// # Long running operations
202    ///
203    /// This method is used to start, and/or poll a [long-running Operation].
204    /// The [Working with long-running operations] chapter in the [user guide]
205    /// covers these operations in detail.
206    ///
207    /// [long-running operation]: https://google.aip.dev/151
208    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
209    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
210    pub fn create_instance_config(&self) -> super::builder::instance_admin::CreateInstanceConfig {
211        super::builder::instance_admin::CreateInstanceConfig::new(self.inner.clone())
212    }
213
214    /// Updates an instance configuration. The returned
215    /// long-running operation can be used to track
216    /// the progress of updating the instance. If the named instance configuration
217    /// does not exist, returns `NOT_FOUND`.
218    ///
219    /// Only user-managed configurations can be updated.
220    ///
221    /// Immediately after the request returns:
222    ///
223    /// * The instance configuration's
224    ///   [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
225    ///   field is set to true.
226    ///
227    /// While the operation is pending:
228    ///
229    /// * Cancelling the operation sets its metadata's
230    ///   [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time].
231    ///   The operation is guaranteed to succeed at undoing all changes, after
232    ///   which point it terminates with a `CANCELLED` status.
233    /// * All other attempts to modify the instance configuration are rejected.
234    /// * Reading the instance configuration via the API continues to give the
235    ///   pre-request values.
236    ///
237    /// Upon completion of the returned operation:
238    ///
239    /// * Creating instances using the instance configuration uses the new
240    ///   values.
241    /// * The new values of the instance configuration are readable via the API.
242    /// * The instance configuration's
243    ///   [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling]
244    ///   field becomes false.
245    ///
246    /// The returned long-running operation will
247    /// have a name of the format
248    /// `<instance_config_name>/operations/<operation_id>` and can be used to track
249    /// the instance configuration modification.  The
250    /// metadata field type is
251    /// [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata].
252    /// The response field type is
253    /// [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if
254    /// successful.
255    ///
256    /// Authorization requires `spanner.instanceConfigs.update` permission on
257    /// the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name].
258    ///
259    /// [google.spanner.admin.instance.v1.InstanceConfig]: crate::model::InstanceConfig
260    /// [google.spanner.admin.instance.v1.InstanceConfig.name]: crate::model::InstanceConfig::name
261    /// [google.spanner.admin.instance.v1.InstanceConfig.reconciling]: crate::model::InstanceConfig::reconciling
262    /// [google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]: crate::model::UpdateInstanceConfigMetadata
263    /// [google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]: crate::model::UpdateInstanceConfigMetadata::cancel_time
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 update_instance_config(&self) -> super::builder::instance_admin::UpdateInstanceConfig {
275        super::builder::instance_admin::UpdateInstanceConfig::new(self.inner.clone())
276    }
277
278    /// Deletes the instance configuration. Deletion is only allowed when no
279    /// instances are using the configuration. If any instances are using
280    /// the configuration, returns `FAILED_PRECONDITION`.
281    ///
282    /// Only user-managed configurations can be deleted.
283    ///
284    /// Authorization requires `spanner.instanceConfigs.delete` permission on
285    /// the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name].
286    ///
287    /// [google.spanner.admin.instance.v1.InstanceConfig.name]: crate::model::InstanceConfig::name
288    pub fn delete_instance_config(&self) -> super::builder::instance_admin::DeleteInstanceConfig {
289        super::builder::instance_admin::DeleteInstanceConfig::new(self.inner.clone())
290    }
291
292    /// Lists the user-managed instance configuration long-running
293    /// operations in the given project. An instance
294    /// configuration operation has a name of the form
295    /// `projects/<project>/instanceConfigs/<instance_config>/operations/<operation>`.
296    /// The long-running operation
297    /// metadata field type
298    /// `metadata.type_url` describes the type of the metadata. Operations returned
299    /// include those that have completed/failed/canceled within the last 7 days,
300    /// and pending operations. Operations returned are ordered by
301    /// `operation.metadata.value.start_time` in descending order starting
302    /// from the most recently started operation.
303    pub fn list_instance_config_operations(
304        &self,
305    ) -> super::builder::instance_admin::ListInstanceConfigOperations {
306        super::builder::instance_admin::ListInstanceConfigOperations::new(self.inner.clone())
307    }
308
309    /// Lists all instances in the given project.
310    pub fn list_instances(&self) -> super::builder::instance_admin::ListInstances {
311        super::builder::instance_admin::ListInstances::new(self.inner.clone())
312    }
313
314    /// Lists all instance partitions for the given instance.
315    pub fn list_instance_partitions(
316        &self,
317    ) -> super::builder::instance_admin::ListInstancePartitions {
318        super::builder::instance_admin::ListInstancePartitions::new(self.inner.clone())
319    }
320
321    /// Gets information about a particular instance.
322    pub fn get_instance(&self) -> super::builder::instance_admin::GetInstance {
323        super::builder::instance_admin::GetInstance::new(self.inner.clone())
324    }
325
326    /// Creates an instance and begins preparing it to begin serving. The
327    /// returned long-running operation
328    /// can be used to track the progress of preparing the new
329    /// instance. The instance name is assigned by the caller. If the
330    /// named instance already exists, `CreateInstance` returns
331    /// `ALREADY_EXISTS`.
332    ///
333    /// Immediately upon completion of this request:
334    ///
335    /// * The instance is readable via the API, with all requested attributes
336    ///   but no allocated resources. Its state is `CREATING`.
337    ///
338    /// Until completion of the returned operation:
339    ///
340    /// * Cancelling the operation renders the instance immediately unreadable
341    ///   via the API.
342    /// * The instance can be deleted.
343    /// * All other attempts to modify the instance are rejected.
344    ///
345    /// Upon completion of the returned operation:
346    ///
347    /// * Billing for all successfully-allocated resources begins (some types
348    ///   may have lower than the requested levels).
349    /// * Databases can be created in the instance.
350    /// * The instance's allocated resource levels are readable via the API.
351    /// * The instance's state becomes `READY`.
352    ///
353    /// The returned long-running operation will
354    /// have a name of the format `<instance_name>/operations/<operation_id>` and
355    /// can be used to track creation of the instance.  The
356    /// metadata field type is
357    /// [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata].
358    /// The response field type is
359    /// [Instance][google.spanner.admin.instance.v1.Instance], if successful.
360    ///
361    /// [google.spanner.admin.instance.v1.CreateInstanceMetadata]: crate::model::CreateInstanceMetadata
362    /// [google.spanner.admin.instance.v1.Instance]: crate::model::Instance
363    ///
364    /// # Long running operations
365    ///
366    /// This method is used to start, and/or poll a [long-running Operation].
367    /// The [Working with long-running operations] chapter in the [user guide]
368    /// covers these operations in detail.
369    ///
370    /// [long-running operation]: https://google.aip.dev/151
371    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
372    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
373    pub fn create_instance(&self) -> super::builder::instance_admin::CreateInstance {
374        super::builder::instance_admin::CreateInstance::new(self.inner.clone())
375    }
376
377    /// Updates an instance, and begins allocating or releasing resources
378    /// as requested. The returned long-running operation can be used to track the
379    /// progress of updating the instance. If the named instance does not
380    /// exist, returns `NOT_FOUND`.
381    ///
382    /// Immediately upon completion of this request:
383    ///
384    /// * For resource types for which a decrease in the instance's allocation
385    ///   has been requested, billing is based on the newly-requested level.
386    ///
387    /// Until completion of the returned operation:
388    ///
389    /// * Cancelling the operation sets its metadata's
390    ///   [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time],
391    ///   and begins restoring resources to their pre-request values. The
392    ///   operation is guaranteed to succeed at undoing all resource changes,
393    ///   after which point it terminates with a `CANCELLED` status.
394    /// * All other attempts to modify the instance are rejected.
395    /// * Reading the instance via the API continues to give the pre-request
396    ///   resource levels.
397    ///
398    /// Upon completion of the returned operation:
399    ///
400    /// * Billing begins for all successfully-allocated resources (some types
401    ///   may have lower than the requested levels).
402    /// * All newly-reserved resources are available for serving the instance's
403    ///   tables.
404    /// * The instance's new resource levels are readable via the API.
405    ///
406    /// The returned long-running operation will
407    /// have a name of the format `<instance_name>/operations/<operation_id>` and
408    /// can be used to track the instance modification.  The
409    /// metadata field type is
410    /// [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata].
411    /// The response field type is
412    /// [Instance][google.spanner.admin.instance.v1.Instance], if successful.
413    ///
414    /// Authorization requires `spanner.instances.update` permission on
415    /// the resource [name][google.spanner.admin.instance.v1.Instance.name].
416    ///
417    /// [google.spanner.admin.instance.v1.Instance]: crate::model::Instance
418    /// [google.spanner.admin.instance.v1.Instance.name]: crate::model::Instance::name
419    /// [google.spanner.admin.instance.v1.UpdateInstanceMetadata]: crate::model::UpdateInstanceMetadata
420    /// [google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time]: crate::model::UpdateInstanceMetadata::cancel_time
421    ///
422    /// # Long running operations
423    ///
424    /// This method is used to start, and/or poll a [long-running Operation].
425    /// The [Working with long-running operations] chapter in the [user guide]
426    /// covers these operations in detail.
427    ///
428    /// [long-running operation]: https://google.aip.dev/151
429    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
430    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
431    pub fn update_instance(&self) -> super::builder::instance_admin::UpdateInstance {
432        super::builder::instance_admin::UpdateInstance::new(self.inner.clone())
433    }
434
435    /// Deletes an instance.
436    ///
437    /// Immediately upon completion of the request:
438    ///
439    /// * Billing ceases for all of the instance's reserved resources.
440    ///
441    /// Soon afterward:
442    ///
443    /// * The instance and *all of its databases* immediately and
444    ///   irrevocably disappear from the API. All data in the databases
445    ///   is permanently deleted.
446    pub fn delete_instance(&self) -> super::builder::instance_admin::DeleteInstance {
447        super::builder::instance_admin::DeleteInstance::new(self.inner.clone())
448    }
449
450    /// Sets the access control policy on an instance resource. Replaces any
451    /// existing policy.
452    ///
453    /// Authorization requires `spanner.instances.setIamPolicy` on
454    /// [resource][google.iam.v1.SetIamPolicyRequest.resource].
455    ///
456    /// [google.iam.v1.SetIamPolicyRequest.resource]: iam_v1::model::SetIamPolicyRequest::resource
457    pub fn set_iam_policy(&self) -> super::builder::instance_admin::SetIamPolicy {
458        super::builder::instance_admin::SetIamPolicy::new(self.inner.clone())
459    }
460
461    /// Gets the access control policy for an instance resource. Returns an empty
462    /// policy if an instance exists but does not have a policy set.
463    ///
464    /// Authorization requires `spanner.instances.getIamPolicy` on
465    /// [resource][google.iam.v1.GetIamPolicyRequest.resource].
466    ///
467    /// [google.iam.v1.GetIamPolicyRequest.resource]: iam_v1::model::GetIamPolicyRequest::resource
468    pub fn get_iam_policy(&self) -> super::builder::instance_admin::GetIamPolicy {
469        super::builder::instance_admin::GetIamPolicy::new(self.inner.clone())
470    }
471
472    /// Returns permissions that the caller has on the specified instance resource.
473    ///
474    /// Attempting this RPC on a non-existent Cloud Spanner instance resource will
475    /// result in a NOT_FOUND error if the user has `spanner.instances.list`
476    /// permission on the containing Google Cloud Project. Otherwise returns an
477    /// empty set of permissions.
478    pub fn test_iam_permissions(&self) -> super::builder::instance_admin::TestIamPermissions {
479        super::builder::instance_admin::TestIamPermissions::new(self.inner.clone())
480    }
481
482    /// Gets information about a particular instance partition.
483    pub fn get_instance_partition(&self) -> super::builder::instance_admin::GetInstancePartition {
484        super::builder::instance_admin::GetInstancePartition::new(self.inner.clone())
485    }
486
487    /// Creates an instance partition and begins preparing it to be used. The
488    /// returned long-running operation
489    /// can be used to track the progress of preparing the new instance partition.
490    /// The instance partition name is assigned by the caller. If the named
491    /// instance partition already exists, `CreateInstancePartition` returns
492    /// `ALREADY_EXISTS`.
493    ///
494    /// Immediately upon completion of this request:
495    ///
496    /// * The instance partition is readable via the API, with all requested
497    ///   attributes but no allocated resources. Its state is `CREATING`.
498    ///
499    /// Until completion of the returned operation:
500    ///
501    /// * Cancelling the operation renders the instance partition immediately
502    ///   unreadable via the API.
503    /// * The instance partition can be deleted.
504    /// * All other attempts to modify the instance partition are rejected.
505    ///
506    /// Upon completion of the returned operation:
507    ///
508    /// * Billing for all successfully-allocated resources begins (some types
509    ///   may have lower than the requested levels).
510    /// * Databases can start using this instance partition.
511    /// * The instance partition's allocated resource levels are readable via the
512    ///   API.
513    /// * The instance partition's state becomes `READY`.
514    ///
515    /// The returned long-running operation will
516    /// have a name of the format
517    /// `<instance_partition_name>/operations/<operation_id>` and can be used to
518    /// track creation of the instance partition.  The
519    /// metadata field type is
520    /// [CreateInstancePartitionMetadata][google.spanner.admin.instance.v1.CreateInstancePartitionMetadata].
521    /// The response field type is
522    /// [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if
523    /// successful.
524    ///
525    /// [google.spanner.admin.instance.v1.CreateInstancePartitionMetadata]: crate::model::CreateInstancePartitionMetadata
526    /// [google.spanner.admin.instance.v1.InstancePartition]: crate::model::InstancePartition
527    ///
528    /// # Long running operations
529    ///
530    /// This method is used to start, and/or poll a [long-running Operation].
531    /// The [Working with long-running operations] chapter in the [user guide]
532    /// covers these operations in detail.
533    ///
534    /// [long-running operation]: https://google.aip.dev/151
535    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
536    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
537    pub fn create_instance_partition(
538        &self,
539    ) -> super::builder::instance_admin::CreateInstancePartition {
540        super::builder::instance_admin::CreateInstancePartition::new(self.inner.clone())
541    }
542
543    /// Deletes an existing instance partition. Requires that the
544    /// instance partition is not used by any database or backup and is not the
545    /// default instance partition of an instance.
546    ///
547    /// Authorization requires `spanner.instancePartitions.delete` permission on
548    /// the resource
549    /// [name][google.spanner.admin.instance.v1.InstancePartition.name].
550    ///
551    /// [google.spanner.admin.instance.v1.InstancePartition.name]: crate::model::InstancePartition::name
552    pub fn delete_instance_partition(
553        &self,
554    ) -> super::builder::instance_admin::DeleteInstancePartition {
555        super::builder::instance_admin::DeleteInstancePartition::new(self.inner.clone())
556    }
557
558    /// Updates an instance partition, and begins allocating or releasing resources
559    /// as requested. The returned long-running operation can be used to track the
560    /// progress of updating the instance partition. If the named instance
561    /// partition does not exist, returns `NOT_FOUND`.
562    ///
563    /// Immediately upon completion of this request:
564    ///
565    /// * For resource types for which a decrease in the instance partition's
566    ///   allocation has been requested, billing is based on the newly-requested
567    ///   level.
568    ///
569    /// Until completion of the returned operation:
570    ///
571    /// * Cancelling the operation sets its metadata's
572    ///   [cancel_time][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata.cancel_time],
573    ///   and begins restoring resources to their pre-request values. The
574    ///   operation is guaranteed to succeed at undoing all resource changes,
575    ///   after which point it terminates with a `CANCELLED` status.
576    /// * All other attempts to modify the instance partition are rejected.
577    /// * Reading the instance partition via the API continues to give the
578    ///   pre-request resource levels.
579    ///
580    /// Upon completion of the returned operation:
581    ///
582    /// * Billing begins for all successfully-allocated resources (some types
583    ///   may have lower than the requested levels).
584    /// * All newly-reserved resources are available for serving the instance
585    ///   partition's tables.
586    /// * The instance partition's new resource levels are readable via the API.
587    ///
588    /// The returned long-running operation will
589    /// have a name of the format
590    /// `<instance_partition_name>/operations/<operation_id>` and can be used to
591    /// track the instance partition modification. The
592    /// metadata field type is
593    /// [UpdateInstancePartitionMetadata][google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata].
594    /// The response field type is
595    /// [InstancePartition][google.spanner.admin.instance.v1.InstancePartition], if
596    /// successful.
597    ///
598    /// Authorization requires `spanner.instancePartitions.update` permission on
599    /// the resource
600    /// [name][google.spanner.admin.instance.v1.InstancePartition.name].
601    ///
602    /// [google.spanner.admin.instance.v1.InstancePartition]: crate::model::InstancePartition
603    /// [google.spanner.admin.instance.v1.InstancePartition.name]: crate::model::InstancePartition::name
604    /// [google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata]: crate::model::UpdateInstancePartitionMetadata
605    /// [google.spanner.admin.instance.v1.UpdateInstancePartitionMetadata.cancel_time]: crate::model::UpdateInstancePartitionMetadata::cancel_time
606    ///
607    /// # Long running operations
608    ///
609    /// This method is used to start, and/or poll a [long-running Operation].
610    /// The [Working with long-running operations] chapter in the [user guide]
611    /// covers these operations in detail.
612    ///
613    /// [long-running operation]: https://google.aip.dev/151
614    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
615    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
616    pub fn update_instance_partition(
617        &self,
618    ) -> super::builder::instance_admin::UpdateInstancePartition {
619        super::builder::instance_admin::UpdateInstancePartition::new(self.inner.clone())
620    }
621
622    /// Lists instance partition long-running operations in the given instance.
623    /// An instance partition operation has a name of the form
624    /// `projects/<project>/instances/<instance>/instancePartitions/<instance_partition>/operations/<operation>`.
625    /// The long-running operation
626    /// metadata field type
627    /// `metadata.type_url` describes the type of the metadata. Operations returned
628    /// include those that have completed/failed/canceled within the last 7 days,
629    /// and pending operations. Operations returned are ordered by
630    /// `operation.metadata.value.start_time` in descending order starting from the
631    /// most recently started operation.
632    ///
633    /// Authorization requires `spanner.instancePartitionOperations.list`
634    /// permission on the resource
635    /// [parent][google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent].
636    ///
637    /// [google.spanner.admin.instance.v1.ListInstancePartitionOperationsRequest.parent]: crate::model::ListInstancePartitionOperationsRequest::parent
638    pub fn list_instance_partition_operations(
639        &self,
640    ) -> super::builder::instance_admin::ListInstancePartitionOperations {
641        super::builder::instance_admin::ListInstancePartitionOperations::new(self.inner.clone())
642    }
643
644    /// Moves an instance to the target instance configuration. You can use the
645    /// returned long-running operation to track
646    /// the progress of moving the instance.
647    ///
648    /// `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of
649    /// the following criteria:
650    ///
651    /// * Is undergoing a move to a different instance configuration
652    /// * Has backups
653    /// * Has an ongoing update
654    /// * Contains any CMEK-enabled databases
655    /// * Is a free trial instance
656    ///
657    /// While the operation is pending:
658    ///
659    /// * All other attempts to modify the instance, including changes to its
660    ///   compute capacity, are rejected.
661    ///
662    /// * The following database and backup admin operations are rejected:
663    ///
664    ///   * `DatabaseAdmin.CreateDatabase`
665    ///   * `DatabaseAdmin.UpdateDatabaseDdl` (disabled if default_leader is
666    ///     specified in the request.)
667    ///   * `DatabaseAdmin.RestoreDatabase`
668    ///   * `DatabaseAdmin.CreateBackup`
669    ///   * `DatabaseAdmin.CopyBackup`
670    /// * Both the source and target instance configurations are subject to
671    ///   hourly compute and storage charges.
672    ///
673    /// * The instance might experience higher read-write latencies and a higher
674    ///   transaction abort rate. However, moving an instance doesn't cause any
675    ///   downtime.
676    ///
677    ///
678    /// The returned long-running operation has
679    /// a name of the format
680    /// `<instance_name>/operations/<operation_id>` and can be used to track
681    /// the move instance operation. The
682    /// metadata field type is
683    /// [MoveInstanceMetadata][google.spanner.admin.instance.v1.MoveInstanceMetadata].
684    /// The response field type is
685    /// [Instance][google.spanner.admin.instance.v1.Instance],
686    /// if successful.
687    /// Cancelling the operation sets its metadata's
688    /// [cancel_time][google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time].
689    /// Cancellation is not immediate because it involves moving any data
690    /// previously moved to the target instance configuration back to the original
691    /// instance configuration. You can use this operation to track the progress of
692    /// the cancellation. Upon successful completion of the cancellation, the
693    /// operation terminates with `CANCELLED` status.
694    ///
695    /// If not cancelled, upon completion of the returned operation:
696    ///
697    /// * The instance successfully moves to the target instance
698    ///   configuration.
699    /// * You are billed for compute and storage in target instance
700    ///   configuration.
701    ///
702    /// Authorization requires the `spanner.instances.update` permission on
703    /// the resource [instance][google.spanner.admin.instance.v1.Instance].
704    ///
705    /// For more details, see
706    /// [Move an instance](https://cloud.google.com/spanner/docs/move-instance).
707    ///
708    /// [google.spanner.admin.instance.v1.Instance]: crate::model::Instance
709    /// [google.spanner.admin.instance.v1.MoveInstanceMetadata]: crate::model::MoveInstanceMetadata
710    /// [google.spanner.admin.instance.v1.MoveInstanceMetadata.cancel_time]: crate::model::MoveInstanceMetadata::cancel_time
711    ///
712    /// # Long running operations
713    ///
714    /// This method is used to start, and/or poll a [long-running Operation].
715    /// The [Working with long-running operations] chapter in the [user guide]
716    /// covers these operations in detail.
717    ///
718    /// [long-running operation]: https://google.aip.dev/151
719    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
720    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
721    pub fn move_instance(&self) -> super::builder::instance_admin::MoveInstance {
722        super::builder::instance_admin::MoveInstance::new(self.inner.clone())
723    }
724
725    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
726    ///
727    /// [google.longrunning.Operations]: longrunning::client::Operations
728    pub fn list_operations(&self) -> super::builder::instance_admin::ListOperations {
729        super::builder::instance_admin::ListOperations::new(self.inner.clone())
730    }
731
732    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
733    ///
734    /// [google.longrunning.Operations]: longrunning::client::Operations
735    pub fn get_operation(&self) -> super::builder::instance_admin::GetOperation {
736        super::builder::instance_admin::GetOperation::new(self.inner.clone())
737    }
738
739    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
740    ///
741    /// [google.longrunning.Operations]: longrunning::client::Operations
742    pub fn delete_operation(&self) -> super::builder::instance_admin::DeleteOperation {
743        super::builder::instance_admin::DeleteOperation::new(self.inner.clone())
744    }
745
746    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
747    ///
748    /// [google.longrunning.Operations]: longrunning::client::Operations
749    pub fn cancel_operation(&self) -> super::builder::instance_admin::CancelOperation {
750        super::builder::instance_admin::CancelOperation::new(self.inner.clone())
751    }
752}