google_cloud_securityposture_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 Security Posture API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_securityposture_v1::client::SecurityPosture;
25/// let client = SecurityPosture::builder().build().await?;
26/// // use `client` to make requests to the Security Posture 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 `SecurityPosture` use the `with_*` methods in the type returned
37/// by [builder()][SecurityPosture::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://securityposture.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::security_posture::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::security_posture::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/// `SecurityPosture` holds a connection pool internally, it is advised to
57/// create one and the reuse it. You do not need to wrap `SecurityPosture` 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 SecurityPosture {
62 inner: std::sync::Arc<dyn super::stub::dynamic::SecurityPosture>,
63}
64
65impl SecurityPosture {
66 /// Returns a builder for [SecurityPosture].
67 ///
68 /// ```
69 /// # tokio_test::block_on(async {
70 /// # use google_cloud_securityposture_v1::client::SecurityPosture;
71 /// let client = SecurityPosture::builder().build().await?;
72 /// # gax::client_builder::Result::<()>::Ok(()) });
73 /// ```
74 pub fn builder() -> super::builder::security_posture::ClientBuilder {
75 gax::client_builder::internal::new_builder(
76 super::builder::security_posture::client::Factory,
77 )
78 }
79
80 /// Creates a new client from the provided stub.
81 ///
82 /// The most common case for calling this function is in tests mocking the
83 /// client's behavior.
84 pub fn from_stub<T>(stub: T) -> Self
85 where
86 T: super::stub::SecurityPosture + 'static,
87 {
88 Self {
89 inner: std::sync::Arc::new(stub),
90 }
91 }
92
93 pub(crate) async fn new(
94 config: gaxi::options::ClientConfig,
95 ) -> gax::client_builder::Result<Self> {
96 let inner = Self::build_inner(config).await?;
97 Ok(Self { inner })
98 }
99
100 async fn build_inner(
101 conf: gaxi::options::ClientConfig,
102 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SecurityPosture>>
103 {
104 if gaxi::options::tracing_enabled(&conf) {
105 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
106 }
107 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
108 }
109
110 async fn build_transport(
111 conf: gaxi::options::ClientConfig,
112 ) -> gax::client_builder::Result<impl super::stub::SecurityPosture> {
113 super::transport::SecurityPosture::new(conf).await
114 }
115
116 async fn build_with_tracing(
117 conf: gaxi::options::ClientConfig,
118 ) -> gax::client_builder::Result<impl super::stub::SecurityPosture> {
119 Self::build_transport(conf)
120 .await
121 .map(super::tracing::SecurityPosture::new)
122 }
123
124 /// (-- This option restricts the visibility of the API to only projects that
125 /// will
126 /// (-- be labeled as `PREVIEW` or `GOOGLE_INTERNAL` by the service.
127 /// (-- option (google.api.api_visibility).restriction =
128 /// "PREVIEW,GOOGLE_INTERNAL"; Postures Lists Postures in a given organization
129 /// and location. In case a posture has multiple revisions, the latest revision
130 /// as per UpdateTime will be returned.
131 pub fn list_postures(&self) -> super::builder::security_posture::ListPostures {
132 super::builder::security_posture::ListPostures::new(self.inner.clone())
133 }
134
135 /// Lists revisions of a Posture in a given organization and location.
136 pub fn list_posture_revisions(&self) -> super::builder::security_posture::ListPostureRevisions {
137 super::builder::security_posture::ListPostureRevisions::new(self.inner.clone())
138 }
139
140 /// Gets a posture in a given organization and location.
141 /// User must provide revision_id to retrieve a specific revision of the
142 /// resource.
143 /// NOT_FOUND error is returned if the revision_id or the Posture name does not
144 /// exist. In case revision_id is not provided then the latest Posture revision
145 /// by UpdateTime is returned.
146 pub fn get_posture(&self) -> super::builder::security_posture::GetPosture {
147 super::builder::security_posture::GetPosture::new(self.inner.clone())
148 }
149
150 /// Creates a new Posture resource.
151 /// If a Posture with the specified name already exists in the specified
152 /// organization and location, the long running operation returns a
153 /// [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error.
154 ///
155 /// # Long running operations
156 ///
157 /// This method is used to start, and/or poll a [long-running Operation].
158 /// The [Working with long-running operations] chapter in the [user guide]
159 /// covers these operations in detail.
160 ///
161 /// [long-running operation]: https://google.aip.dev/151
162 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
163 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
164 pub fn create_posture(&self) -> super::builder::security_posture::CreatePosture {
165 super::builder::security_posture::CreatePosture::new(self.inner.clone())
166 }
167
168 /// Updates an existing Posture.
169 /// A new revision of the posture will be created if the revision to be
170 /// updated is currently deployed on a workload.
171 /// Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
172 /// Posture does not exist.
173 /// Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
174 /// supplied in the request does not match the persisted etag of the Posture.
175 /// Updatable fields are state, description and policy_sets.
176 /// State update operation cannot be clubbed with update of description and
177 /// policy_sets.
178 /// An ACTIVE posture can be updated to both DRAFT or DEPRECATED states.
179 /// Postures in DRAFT or DEPRECATED states can only be updated to ACTIVE state.
180 ///
181 /// # Long running operations
182 ///
183 /// This method is used to start, and/or poll a [long-running Operation].
184 /// The [Working with long-running operations] chapter in the [user guide]
185 /// covers these operations in detail.
186 ///
187 /// [long-running operation]: https://google.aip.dev/151
188 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
189 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
190 pub fn update_posture(&self) -> super::builder::security_posture::UpdatePosture {
191 super::builder::security_posture::UpdatePosture::new(self.inner.clone())
192 }
193
194 /// Deletes all the revisions of a resource.
195 /// A posture can only be deleted when none of the revisions are deployed to
196 /// any workload.
197 ///
198 /// # Long running operations
199 ///
200 /// This method is used to start, and/or poll a [long-running Operation].
201 /// The [Working with long-running operations] chapter in the [user guide]
202 /// covers these operations in detail.
203 ///
204 /// [long-running operation]: https://google.aip.dev/151
205 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
206 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
207 pub fn delete_posture(&self) -> super::builder::security_posture::DeletePosture {
208 super::builder::security_posture::DeletePosture::new(self.inner.clone())
209 }
210
211 /// Extracts existing policies on a workload as a posture.
212 /// If a Posture on the given workload already exists, the long running
213 /// operation returns a [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error.
214 ///
215 /// # Long running operations
216 ///
217 /// This method is used to start, and/or poll a [long-running Operation].
218 /// The [Working with long-running operations] chapter in the [user guide]
219 /// covers these operations in detail.
220 ///
221 /// [long-running operation]: https://google.aip.dev/151
222 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
223 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
224 pub fn extract_posture(&self) -> super::builder::security_posture::ExtractPosture {
225 super::builder::security_posture::ExtractPosture::new(self.inner.clone())
226 }
227
228 /// PostureDeployments
229 /// Lists PostureDeployments in a given project and location.
230 pub fn list_posture_deployments(
231 &self,
232 ) -> super::builder::security_posture::ListPostureDeployments {
233 super::builder::security_posture::ListPostureDeployments::new(self.inner.clone())
234 }
235
236 /// Gets details of a single PostureDeployment.
237 pub fn get_posture_deployment(&self) -> super::builder::security_posture::GetPostureDeployment {
238 super::builder::security_posture::GetPostureDeployment::new(self.inner.clone())
239 }
240
241 /// Creates a new PostureDeployment in a given project and location.
242 ///
243 /// # Long running operations
244 ///
245 /// This method is used to start, and/or poll a [long-running Operation].
246 /// The [Working with long-running operations] chapter in the [user guide]
247 /// covers these operations in detail.
248 ///
249 /// [long-running operation]: https://google.aip.dev/151
250 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
251 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
252 pub fn create_posture_deployment(
253 &self,
254 ) -> super::builder::security_posture::CreatePostureDeployment {
255 super::builder::security_posture::CreatePostureDeployment::new(self.inner.clone())
256 }
257
258 /// Updates the parameters of a single PostureDeployment.
259 ///
260 /// # Long running operations
261 ///
262 /// This method is used to start, and/or poll a [long-running Operation].
263 /// The [Working with long-running operations] chapter in the [user guide]
264 /// covers these operations in detail.
265 ///
266 /// [long-running operation]: https://google.aip.dev/151
267 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
268 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
269 pub fn update_posture_deployment(
270 &self,
271 ) -> super::builder::security_posture::UpdatePostureDeployment {
272 super::builder::security_posture::UpdatePostureDeployment::new(self.inner.clone())
273 }
274
275 /// Deletes a single PostureDeployment.
276 ///
277 /// # Long running operations
278 ///
279 /// This method is used to start, and/or poll a [long-running Operation].
280 /// The [Working with long-running operations] chapter in the [user guide]
281 /// covers these operations in detail.
282 ///
283 /// [long-running operation]: https://google.aip.dev/151
284 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
285 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
286 pub fn delete_posture_deployment(
287 &self,
288 ) -> super::builder::security_posture::DeletePostureDeployment {
289 super::builder::security_posture::DeletePostureDeployment::new(self.inner.clone())
290 }
291
292 /// PostureTemplates
293 /// Lists all the PostureTemplates available to the user.
294 pub fn list_posture_templates(&self) -> super::builder::security_posture::ListPostureTemplates {
295 super::builder::security_posture::ListPostureTemplates::new(self.inner.clone())
296 }
297
298 /// Gets a PostureTemplate.
299 /// User must provide revision_id to retrieve a specific revision of the
300 /// resource.
301 /// NOT_FOUND error is returned if the revision_id or the PostureTemplate name
302 /// does not exist. In case revision_id is not provided then the
303 /// PostureTemplate with latest revision_id is returned.
304 pub fn get_posture_template(&self) -> super::builder::security_posture::GetPostureTemplate {
305 super::builder::security_posture::GetPostureTemplate::new(self.inner.clone())
306 }
307
308 /// Lists information about the supported locations for this service.
309 pub fn list_locations(&self) -> super::builder::security_posture::ListLocations {
310 super::builder::security_posture::ListLocations::new(self.inner.clone())
311 }
312
313 /// Gets information about a location.
314 pub fn get_location(&self) -> super::builder::security_posture::GetLocation {
315 super::builder::security_posture::GetLocation::new(self.inner.clone())
316 }
317
318 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
319 ///
320 /// [google.longrunning.Operations]: longrunning::client::Operations
321 pub fn list_operations(&self) -> super::builder::security_posture::ListOperations {
322 super::builder::security_posture::ListOperations::new(self.inner.clone())
323 }
324
325 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
326 ///
327 /// [google.longrunning.Operations]: longrunning::client::Operations
328 pub fn get_operation(&self) -> super::builder::security_posture::GetOperation {
329 super::builder::security_posture::GetOperation::new(self.inner.clone())
330 }
331
332 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
333 ///
334 /// [google.longrunning.Operations]: longrunning::client::Operations
335 pub fn delete_operation(&self) -> super::builder::security_posture::DeleteOperation {
336 super::builder::security_posture::DeleteOperation::new(self.inner.clone())
337 }
338
339 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
340 ///
341 /// [google.longrunning.Operations]: longrunning::client::Operations
342 pub fn cancel_operation(&self) -> super::builder::security_posture::CancelOperation {
343 super::builder::security_posture::CancelOperation::new(self.inner.clone())
344 }
345}