google_cloud_parametermanager_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 Parameter Manager API.
20///
21/// # Example
22/// ```
23/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24/// # use google_cloud_parametermanager_v1::client::ParameterManager;
25/// let client = ParameterManager::builder().build().await?;
26/// // use `client` to make requests to the Parameter Manager API.
27/// # Ok(()) }
28/// ```
29///
30/// # Service Description
31///
32/// Service describing handlers for resources
33///
34/// # Configuration
35///
36/// To configure `ParameterManager` use the `with_*` methods in the type returned
37/// by [builder()][ParameterManager::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://parametermanager.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::parameter_manager::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::parameter_manager::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/// `ParameterManager` holds a connection pool internally, it is advised to
57/// create one and the reuse it. You do not need to wrap `ParameterManager` 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 ParameterManager {
62 inner: std::sync::Arc<dyn super::stub::dynamic::ParameterManager>,
63}
64
65impl ParameterManager {
66 /// Returns a builder for [ParameterManager].
67 ///
68 /// ```
69 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
70 /// # use google_cloud_parametermanager_v1::client::ParameterManager;
71 /// let client = ParameterManager::builder().build().await?;
72 /// # Ok(()) }
73 /// ```
74 pub fn builder() -> super::builder::parameter_manager::ClientBuilder {
75 crate::new_client_builder(super::builder::parameter_manager::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::ParameterManager + '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 ) -> crate::ClientBuilderResult<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 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ParameterManager>>
101 {
102 if gaxi::options::tracing_enabled(&conf) {
103 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
104 }
105 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
106 }
107
108 async fn build_transport(
109 conf: gaxi::options::ClientConfig,
110 ) -> crate::ClientBuilderResult<impl super::stub::ParameterManager> {
111 super::transport::ParameterManager::new(conf).await
112 }
113
114 async fn build_with_tracing(
115 conf: gaxi::options::ClientConfig,
116 ) -> crate::ClientBuilderResult<impl super::stub::ParameterManager> {
117 Self::build_transport(conf)
118 .await
119 .map(super::tracing::ParameterManager::new)
120 }
121
122 /// Lists Parameters in a given project and location.
123 pub fn list_parameters(&self) -> super::builder::parameter_manager::ListParameters {
124 super::builder::parameter_manager::ListParameters::new(self.inner.clone())
125 }
126
127 /// Gets details of a single Parameter.
128 pub fn get_parameter(&self) -> super::builder::parameter_manager::GetParameter {
129 super::builder::parameter_manager::GetParameter::new(self.inner.clone())
130 }
131
132 /// Creates a new Parameter in a given project and location.
133 pub fn create_parameter(&self) -> super::builder::parameter_manager::CreateParameter {
134 super::builder::parameter_manager::CreateParameter::new(self.inner.clone())
135 }
136
137 /// Updates a single Parameter.
138 pub fn update_parameter(&self) -> super::builder::parameter_manager::UpdateParameter {
139 super::builder::parameter_manager::UpdateParameter::new(self.inner.clone())
140 }
141
142 /// Deletes a single Parameter.
143 pub fn delete_parameter(&self) -> super::builder::parameter_manager::DeleteParameter {
144 super::builder::parameter_manager::DeleteParameter::new(self.inner.clone())
145 }
146
147 /// Lists ParameterVersions in a given project, location, and parameter.
148 pub fn list_parameter_versions(
149 &self,
150 ) -> super::builder::parameter_manager::ListParameterVersions {
151 super::builder::parameter_manager::ListParameterVersions::new(self.inner.clone())
152 }
153
154 /// Gets details of a single ParameterVersion.
155 pub fn get_parameter_version(&self) -> super::builder::parameter_manager::GetParameterVersion {
156 super::builder::parameter_manager::GetParameterVersion::new(self.inner.clone())
157 }
158
159 /// Gets rendered version of a ParameterVersion.
160 pub fn render_parameter_version(
161 &self,
162 ) -> super::builder::parameter_manager::RenderParameterVersion {
163 super::builder::parameter_manager::RenderParameterVersion::new(self.inner.clone())
164 }
165
166 /// Creates a new ParameterVersion in a given project, location, and parameter.
167 pub fn create_parameter_version(
168 &self,
169 ) -> super::builder::parameter_manager::CreateParameterVersion {
170 super::builder::parameter_manager::CreateParameterVersion::new(self.inner.clone())
171 }
172
173 /// Updates a single ParameterVersion.
174 pub fn update_parameter_version(
175 &self,
176 ) -> super::builder::parameter_manager::UpdateParameterVersion {
177 super::builder::parameter_manager::UpdateParameterVersion::new(self.inner.clone())
178 }
179
180 /// Deletes a single ParameterVersion.
181 pub fn delete_parameter_version(
182 &self,
183 ) -> super::builder::parameter_manager::DeleteParameterVersion {
184 super::builder::parameter_manager::DeleteParameterVersion::new(self.inner.clone())
185 }
186
187 /// Lists information about the supported locations for this service.
188 pub fn list_locations(&self) -> super::builder::parameter_manager::ListLocations {
189 super::builder::parameter_manager::ListLocations::new(self.inner.clone())
190 }
191
192 /// Gets information about a location.
193 pub fn get_location(&self) -> super::builder::parameter_manager::GetLocation {
194 super::builder::parameter_manager::GetLocation::new(self.inner.clone())
195 }
196}