google_cloud_securitycenter_v2/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 Command Center API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_securitycenter_v2::client::SecurityCenter;
25/// let client = SecurityCenter::builder().build().await?;
26/// // use `client` to make requests to the Security Command Center API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// V2 APIs for Security Center service.
33///
34/// # Configuration
35///
36/// To configure `SecurityCenter` use the `with_*` methods in the type returned
37/// by [builder()][SecurityCenter::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://securitycenter.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_center::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::security_center::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/// `SecurityCenter` holds a connection pool internally, it is advised to
57/// create one and the reuse it. You do not need to wrap `SecurityCenter` 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 SecurityCenter {
62 inner: std::sync::Arc<dyn super::stub::dynamic::SecurityCenter>,
63}
64
65impl SecurityCenter {
66 /// Returns a builder for [SecurityCenter].
67 ///
68 /// ```
69 /// # tokio_test::block_on(async {
70 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
71 /// let client = SecurityCenter::builder().build().await?;
72 /// # gax::client_builder::Result::<()>::Ok(()) });
73 /// ```
74 pub fn builder() -> super::builder::security_center::ClientBuilder {
75 gax::client_builder::internal::new_builder(super::builder::security_center::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::SecurityCenter + '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::SecurityCenter>> {
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::SecurityCenter> {
110 super::transport::SecurityCenter::new(conf).await
111 }
112
113 async fn build_with_tracing(
114 conf: gaxi::options::ClientConfig,
115 ) -> gax::client_builder::Result<impl super::stub::SecurityCenter> {
116 Self::build_transport(conf)
117 .await
118 .map(super::tracing::SecurityCenter::new)
119 }
120
121 /// Creates a ResourceValueConfig for an organization. Maps user's tags to
122 /// difference resource values for use by the attack path simulation.
123 pub fn batch_create_resource_value_configs(
124 &self,
125 ) -> super::builder::security_center::BatchCreateResourceValueConfigs {
126 super::builder::security_center::BatchCreateResourceValueConfigs::new(self.inner.clone())
127 }
128
129 /// Kicks off an LRO to bulk mute findings for a parent based on a filter. If
130 /// no location is specified, findings are muted in global. The parent
131 /// can be either an organization, folder, or project. The findings matched by
132 /// the filter will be muted after the LRO is done.
133 ///
134 /// # Long running operations
135 ///
136 /// This method is used to start, and/or poll a [long-running Operation].
137 /// The [Working with long-running operations] chapter in the [user guide]
138 /// covers these operations in detail.
139 ///
140 /// [long-running operation]: https://google.aip.dev/151
141 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
142 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
143 pub fn bulk_mute_findings(&self) -> super::builder::security_center::BulkMuteFindings {
144 super::builder::security_center::BulkMuteFindings::new(self.inner.clone())
145 }
146
147 /// Creates a BigQuery export.
148 pub fn create_big_query_export(&self) -> super::builder::security_center::CreateBigQueryExport {
149 super::builder::security_center::CreateBigQueryExport::new(self.inner.clone())
150 }
151
152 /// Creates a finding in a location. The corresponding source must exist for
153 /// finding creation to succeed.
154 pub fn create_finding(&self) -> super::builder::security_center::CreateFinding {
155 super::builder::security_center::CreateFinding::new(self.inner.clone())
156 }
157
158 /// Creates a mute config.
159 pub fn create_mute_config(&self) -> super::builder::security_center::CreateMuteConfig {
160 super::builder::security_center::CreateMuteConfig::new(self.inner.clone())
161 }
162
163 /// Creates a notification config.
164 pub fn create_notification_config(
165 &self,
166 ) -> super::builder::security_center::CreateNotificationConfig {
167 super::builder::security_center::CreateNotificationConfig::new(self.inner.clone())
168 }
169
170 /// Creates a source.
171 pub fn create_source(&self) -> super::builder::security_center::CreateSource {
172 super::builder::security_center::CreateSource::new(self.inner.clone())
173 }
174
175 /// Deletes an existing BigQuery export.
176 pub fn delete_big_query_export(&self) -> super::builder::security_center::DeleteBigQueryExport {
177 super::builder::security_center::DeleteBigQueryExport::new(self.inner.clone())
178 }
179
180 /// Deletes an existing mute config. If no location is specified, default is
181 /// global.
182 pub fn delete_mute_config(&self) -> super::builder::security_center::DeleteMuteConfig {
183 super::builder::security_center::DeleteMuteConfig::new(self.inner.clone())
184 }
185
186 /// Deletes a notification config.
187 pub fn delete_notification_config(
188 &self,
189 ) -> super::builder::security_center::DeleteNotificationConfig {
190 super::builder::security_center::DeleteNotificationConfig::new(self.inner.clone())
191 }
192
193 /// Deletes a ResourceValueConfig.
194 pub fn delete_resource_value_config(
195 &self,
196 ) -> super::builder::security_center::DeleteResourceValueConfig {
197 super::builder::security_center::DeleteResourceValueConfig::new(self.inner.clone())
198 }
199
200 /// Gets a BigQuery export.
201 pub fn get_big_query_export(&self) -> super::builder::security_center::GetBigQueryExport {
202 super::builder::security_center::GetBigQueryExport::new(self.inner.clone())
203 }
204
205 /// Get the simulation by name or the latest simulation for the given
206 /// organization.
207 pub fn get_simulation(&self) -> super::builder::security_center::GetSimulation {
208 super::builder::security_center::GetSimulation::new(self.inner.clone())
209 }
210
211 /// Get the valued resource by name
212 pub fn get_valued_resource(&self) -> super::builder::security_center::GetValuedResource {
213 super::builder::security_center::GetValuedResource::new(self.inner.clone())
214 }
215
216 /// Gets the access control policy on the specified Source.
217 pub fn get_iam_policy(&self) -> super::builder::security_center::GetIamPolicy {
218 super::builder::security_center::GetIamPolicy::new(self.inner.clone())
219 }
220
221 /// Gets a mute config. If no location is specified, default is
222 /// global.
223 pub fn get_mute_config(&self) -> super::builder::security_center::GetMuteConfig {
224 super::builder::security_center::GetMuteConfig::new(self.inner.clone())
225 }
226
227 /// Gets a notification config.
228 pub fn get_notification_config(
229 &self,
230 ) -> super::builder::security_center::GetNotificationConfig {
231 super::builder::security_center::GetNotificationConfig::new(self.inner.clone())
232 }
233
234 /// Gets a ResourceValueConfig.
235 pub fn get_resource_value_config(
236 &self,
237 ) -> super::builder::security_center::GetResourceValueConfig {
238 super::builder::security_center::GetResourceValueConfig::new(self.inner.clone())
239 }
240
241 /// Gets a source.
242 pub fn get_source(&self) -> super::builder::security_center::GetSource {
243 super::builder::security_center::GetSource::new(self.inner.clone())
244 }
245
246 /// Filters an organization or source's findings and groups them by their
247 /// specified properties in a location. If no location is specified, findings
248 /// are assumed to be in global
249 ///
250 /// To group across all sources provide a `-` as the source id.
251 /// The following list shows some examples:
252 ///
253 /// + `/v2/organizations/{organization_id}/sources/-/findings`
254 ///
255 /// `/v2/organizations/{organization_id}/sources/-/locations/{location_id}/findings`
256 ///
257 /// + `/v2/folders/{folder_id}/sources/-/findings`
258 /// + `/v2/folders/{folder_id}/sources/-/locations/{location_id}/findings`
259 /// + `/v2/projects/{project_id}/sources/-/findings`
260 /// + `/v2/projects/{project_id}/sources/-/locations/{location_id}/findings`
261 pub fn group_findings(&self) -> super::builder::security_center::GroupFindings {
262 super::builder::security_center::GroupFindings::new(self.inner.clone())
263 }
264
265 /// Lists the attack paths for a set of simulation results or valued resources
266 /// and filter.
267 pub fn list_attack_paths(&self) -> super::builder::security_center::ListAttackPaths {
268 super::builder::security_center::ListAttackPaths::new(self.inner.clone())
269 }
270
271 /// Lists BigQuery exports. Note that when requesting BigQuery exports at a
272 /// given level all exports under that level are also returned e.g. if
273 /// requesting BigQuery exports under a folder, then all BigQuery exports
274 /// immediately under the folder plus the ones created under the projects
275 /// within the folder are returned.
276 pub fn list_big_query_exports(&self) -> super::builder::security_center::ListBigQueryExports {
277 super::builder::security_center::ListBigQueryExports::new(self.inner.clone())
278 }
279
280 /// Lists an organization or source's findings.
281 ///
282 /// To list across all sources for a given location provide a `-` as the source
283 /// id. If no location is specified, finding are assumed to be in global.
284 /// The following list shows some examples:
285 ///
286 /// + `/v2/organizations/{organization_id}/sources/-/findings`
287 ///
288 /// `/v2/organizations/{organization_id}/sources/-/locations/{location_id}/findings`
289 pub fn list_findings(&self) -> super::builder::security_center::ListFindings {
290 super::builder::security_center::ListFindings::new(self.inner.clone())
291 }
292
293 /// Lists mute configs. If no location is specified, default is
294 /// global.
295 pub fn list_mute_configs(&self) -> super::builder::security_center::ListMuteConfigs {
296 super::builder::security_center::ListMuteConfigs::new(self.inner.clone())
297 }
298
299 /// Lists notification configs.
300 pub fn list_notification_configs(
301 &self,
302 ) -> super::builder::security_center::ListNotificationConfigs {
303 super::builder::security_center::ListNotificationConfigs::new(self.inner.clone())
304 }
305
306 /// Lists all ResourceValueConfigs.
307 pub fn list_resource_value_configs(
308 &self,
309 ) -> super::builder::security_center::ListResourceValueConfigs {
310 super::builder::security_center::ListResourceValueConfigs::new(self.inner.clone())
311 }
312
313 /// Lists all sources belonging to an organization.
314 pub fn list_sources(&self) -> super::builder::security_center::ListSources {
315 super::builder::security_center::ListSources::new(self.inner.clone())
316 }
317
318 /// Lists the valued resources for a set of simulation results and filter.
319 pub fn list_valued_resources(&self) -> super::builder::security_center::ListValuedResources {
320 super::builder::security_center::ListValuedResources::new(self.inner.clone())
321 }
322
323 /// Updates the state of a finding. If no location is specified, finding is
324 /// assumed to be in global
325 pub fn set_finding_state(&self) -> super::builder::security_center::SetFindingState {
326 super::builder::security_center::SetFindingState::new(self.inner.clone())
327 }
328
329 /// Sets the access control policy on the specified Source.
330 pub fn set_iam_policy(&self) -> super::builder::security_center::SetIamPolicy {
331 super::builder::security_center::SetIamPolicy::new(self.inner.clone())
332 }
333
334 /// Updates the mute state of a finding. If no location is specified, finding
335 /// is assumed to be in global
336 pub fn set_mute(&self) -> super::builder::security_center::SetMute {
337 super::builder::security_center::SetMute::new(self.inner.clone())
338 }
339
340 /// Returns the permissions that a caller has on the specified source.
341 pub fn test_iam_permissions(&self) -> super::builder::security_center::TestIamPermissions {
342 super::builder::security_center::TestIamPermissions::new(self.inner.clone())
343 }
344
345 /// Updates a BigQuery export.
346 pub fn update_big_query_export(&self) -> super::builder::security_center::UpdateBigQueryExport {
347 super::builder::security_center::UpdateBigQueryExport::new(self.inner.clone())
348 }
349
350 /// Updates external system. This is for a given finding. If no location is
351 /// specified, finding is assumed to be in global
352 pub fn update_external_system(&self) -> super::builder::security_center::UpdateExternalSystem {
353 super::builder::security_center::UpdateExternalSystem::new(self.inner.clone())
354 }
355
356 /// Creates or updates a finding. If no location is specified, finding is
357 /// assumed to be in global. The corresponding source must exist for a finding
358 /// creation to succeed.
359 pub fn update_finding(&self) -> super::builder::security_center::UpdateFinding {
360 super::builder::security_center::UpdateFinding::new(self.inner.clone())
361 }
362
363 /// Updates a mute config. If no location is specified, default is
364 /// global.
365 pub fn update_mute_config(&self) -> super::builder::security_center::UpdateMuteConfig {
366 super::builder::security_center::UpdateMuteConfig::new(self.inner.clone())
367 }
368
369 /// Updates a notification config. The following update
370 /// fields are allowed: description, pubsub_topic, streaming_config.filter
371 pub fn update_notification_config(
372 &self,
373 ) -> super::builder::security_center::UpdateNotificationConfig {
374 super::builder::security_center::UpdateNotificationConfig::new(self.inner.clone())
375 }
376
377 /// Updates an existing ResourceValueConfigs with new rules.
378 pub fn update_resource_value_config(
379 &self,
380 ) -> super::builder::security_center::UpdateResourceValueConfig {
381 super::builder::security_center::UpdateResourceValueConfig::new(self.inner.clone())
382 }
383
384 /// Updates security marks. For Finding Security marks, if no location is
385 /// specified, finding is assumed to be in global. Assets Security Marks can
386 /// only be accessed through global endpoint.
387 pub fn update_security_marks(&self) -> super::builder::security_center::UpdateSecurityMarks {
388 super::builder::security_center::UpdateSecurityMarks::new(self.inner.clone())
389 }
390
391 /// Updates a source.
392 pub fn update_source(&self) -> super::builder::security_center::UpdateSource {
393 super::builder::security_center::UpdateSource::new(self.inner.clone())
394 }
395
396 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
397 ///
398 /// [google.longrunning.Operations]: longrunning::client::Operations
399 pub fn list_operations(&self) -> super::builder::security_center::ListOperations {
400 super::builder::security_center::ListOperations::new(self.inner.clone())
401 }
402
403 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
404 ///
405 /// [google.longrunning.Operations]: longrunning::client::Operations
406 pub fn get_operation(&self) -> super::builder::security_center::GetOperation {
407 super::builder::security_center::GetOperation::new(self.inner.clone())
408 }
409
410 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
411 ///
412 /// [google.longrunning.Operations]: longrunning::client::Operations
413 pub fn delete_operation(&self) -> super::builder::security_center::DeleteOperation {
414 super::builder::security_center::DeleteOperation::new(self.inner.clone())
415 }
416
417 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
418 ///
419 /// [google.longrunning.Operations]: longrunning::client::Operations
420 pub fn cancel_operation(&self) -> super::builder::security_center::CancelOperation {
421 super::builder::security_center::CancelOperation::new(self.inner.clone())
422 }
423}