Skip to main content

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