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/// # use google_cloud_securitycenter_v2::client::SecurityCenter;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// async fn sample(
26/// organization_id: &str,
27/// simulation_id: &str,
28/// valued_resource_id: &str,
29/// ) -> anyhow::Result<()> {
30/// let client = SecurityCenter::builder().build().await?;
31/// let mut list = client.list_attack_paths()
32/// .set_parent(format!("organizations/{organization_id}/simulations/{simulation_id}/valuedResources/{valued_resource_id}"))
33/// .by_item();
34/// while let Some(item) = list.next().await.transpose()? {
35/// println!("{:?}", item);
36/// }
37/// Ok(())
38/// }
39/// ```
40///
41/// # Service Description
42///
43/// V2 APIs for Security Center service.
44///
45/// # Configuration
46///
47/// To configure `SecurityCenter` use the `with_*` methods in the type returned
48/// by [builder()][SecurityCenter::builder]. The default configuration should
49/// work for most applications. Common configuration changes include
50///
51/// * [with_endpoint()]: by default this client uses the global default endpoint
52/// (`https://securitycenter.googleapis.com`). Applications using regional
53/// endpoints or running in restricted networks (e.g. a network configured
54// with [Private Google Access with VPC Service Controls]) may want to
55/// override this default.
56/// * [with_credentials()]: by default this client uses
57/// [Application Default Credentials]. Applications using custom
58/// authentication may need to override this default.
59///
60/// [with_endpoint()]: super::builder::security_center::ClientBuilder::with_endpoint
61/// [with_credentials()]: super::builder::security_center::ClientBuilder::with_credentials
62/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
63/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
64///
65/// # Pooling and Cloning
66///
67/// `SecurityCenter` holds a connection pool internally, it is advised to
68/// create one and reuse it. You do not need to wrap `SecurityCenter` in
69/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
70/// already uses an `Arc` internally.
71#[derive(Clone, Debug)]
72pub struct SecurityCenter {
73 inner: std::sync::Arc<dyn super::stub::dynamic::SecurityCenter>,
74}
75
76impl SecurityCenter {
77 /// Returns a builder for [SecurityCenter].
78 ///
79 /// ```
80 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
81 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
82 /// let client = SecurityCenter::builder().build().await?;
83 /// # Ok(()) }
84 /// ```
85 pub fn builder() -> super::builder::security_center::ClientBuilder {
86 crate::new_client_builder(super::builder::security_center::client::Factory)
87 }
88
89 /// Creates a new client from the provided stub.
90 ///
91 /// The most common case for calling this function is in tests mocking the
92 /// client's behavior.
93 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
94 where
95 T: super::stub::SecurityCenter + 'static,
96 {
97 Self { inner: stub.into() }
98 }
99
100 pub(crate) async fn new(
101 config: gaxi::options::ClientConfig,
102 ) -> crate::ClientBuilderResult<Self> {
103 let inner = Self::build_inner(config).await?;
104 Ok(Self { inner })
105 }
106
107 async fn build_inner(
108 conf: gaxi::options::ClientConfig,
109 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::SecurityCenter>> {
110 if gaxi::options::tracing_enabled(&conf) {
111 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
112 }
113 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
114 }
115
116 async fn build_transport(
117 conf: gaxi::options::ClientConfig,
118 ) -> crate::ClientBuilderResult<impl super::stub::SecurityCenter> {
119 super::transport::SecurityCenter::new(conf).await
120 }
121
122 async fn build_with_tracing(
123 conf: gaxi::options::ClientConfig,
124 ) -> crate::ClientBuilderResult<impl super::stub::SecurityCenter> {
125 Self::build_transport(conf)
126 .await
127 .map(super::tracing::SecurityCenter::new)
128 }
129
130 /// Creates a ResourceValueConfig for an organization. Maps user's tags to
131 /// difference resource values for use by the attack path simulation.
132 ///
133 /// # Example
134 /// ```
135 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
136 /// use google_cloud_securitycenter_v2::Result;
137 /// async fn sample(
138 /// client: &SecurityCenter
139 /// ) -> Result<()> {
140 /// let response = client.batch_create_resource_value_configs()
141 /// /* set fields */
142 /// .send().await?;
143 /// println!("response {:?}", response);
144 /// Ok(())
145 /// }
146 /// ```
147 pub fn batch_create_resource_value_configs(
148 &self,
149 ) -> super::builder::security_center::BatchCreateResourceValueConfigs {
150 super::builder::security_center::BatchCreateResourceValueConfigs::new(self.inner.clone())
151 }
152
153 /// Kicks off an LRO to bulk mute findings for a parent based on a filter. If
154 /// no location is specified, findings are muted in global. The parent
155 /// can be either an organization, folder, or project. The findings matched by
156 /// the filter will be muted after the LRO is done.
157 ///
158 /// # Long running operations
159 ///
160 /// This method is used to start, and/or poll a [long-running Operation].
161 /// The [Working with long-running operations] chapter in the [user guide]
162 /// covers these operations in detail.
163 ///
164 /// [long-running operation]: https://google.aip.dev/151
165 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
166 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
167 ///
168 /// # Example
169 /// ```
170 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
171 /// use google_cloud_lro::Poller;
172 /// use google_cloud_securitycenter_v2::Result;
173 /// async fn sample(
174 /// client: &SecurityCenter
175 /// ) -> Result<()> {
176 /// let response = client.bulk_mute_findings()
177 /// /* set fields */
178 /// .poller().until_done().await?;
179 /// println!("response {:?}", response);
180 /// Ok(())
181 /// }
182 /// ```
183 pub fn bulk_mute_findings(&self) -> super::builder::security_center::BulkMuteFindings {
184 super::builder::security_center::BulkMuteFindings::new(self.inner.clone())
185 }
186
187 /// Creates a BigQuery export.
188 ///
189 /// # Example
190 /// ```
191 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
192 /// use google_cloud_securitycenter_v2::model::BigQueryExport;
193 /// use google_cloud_securitycenter_v2::Result;
194 /// async fn sample(
195 /// client: &SecurityCenter, organization_id: &str, location_id: &str
196 /// ) -> Result<()> {
197 /// let response = client.create_big_query_export()
198 /// .set_parent(format!("organizations/{organization_id}/locations/{location_id}"))
199 /// .set_big_query_export(
200 /// BigQueryExport::new()/* set fields */
201 /// )
202 /// .send().await?;
203 /// println!("response {:?}", response);
204 /// Ok(())
205 /// }
206 /// ```
207 pub fn create_big_query_export(&self) -> super::builder::security_center::CreateBigQueryExport {
208 super::builder::security_center::CreateBigQueryExport::new(self.inner.clone())
209 }
210
211 /// Creates a finding in a location. The corresponding source must exist for
212 /// finding creation to succeed.
213 ///
214 /// # Example
215 /// ```
216 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
217 /// use google_cloud_securitycenter_v2::model::Finding;
218 /// use google_cloud_securitycenter_v2::Result;
219 /// async fn sample(
220 /// client: &SecurityCenter, organization_id: &str, source_id: &str
221 /// ) -> Result<()> {
222 /// let response = client.create_finding()
223 /// .set_parent(format!("organizations/{organization_id}/sources/{source_id}"))
224 /// .set_finding_id("finding_id_value")
225 /// .set_finding(
226 /// Finding::new()/* set fields */
227 /// )
228 /// .send().await?;
229 /// println!("response {:?}", response);
230 /// Ok(())
231 /// }
232 /// ```
233 pub fn create_finding(&self) -> super::builder::security_center::CreateFinding {
234 super::builder::security_center::CreateFinding::new(self.inner.clone())
235 }
236
237 /// Creates a mute config.
238 ///
239 /// # Example
240 /// ```
241 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
242 /// use google_cloud_securitycenter_v2::model::MuteConfig;
243 /// use google_cloud_securitycenter_v2::Result;
244 /// async fn sample(
245 /// client: &SecurityCenter, organization_id: &str
246 /// ) -> Result<()> {
247 /// let response = client.create_mute_config()
248 /// .set_parent(format!("organizations/{organization_id}"))
249 /// .set_mute_config(
250 /// MuteConfig::new()/* set fields */
251 /// )
252 /// .send().await?;
253 /// println!("response {:?}", response);
254 /// Ok(())
255 /// }
256 /// ```
257 pub fn create_mute_config(&self) -> super::builder::security_center::CreateMuteConfig {
258 super::builder::security_center::CreateMuteConfig::new(self.inner.clone())
259 }
260
261 /// Creates a notification config.
262 ///
263 /// # Example
264 /// ```
265 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
266 /// use google_cloud_securitycenter_v2::model::NotificationConfig;
267 /// use google_cloud_securitycenter_v2::Result;
268 /// async fn sample(
269 /// client: &SecurityCenter, organization_id: &str, location_id: &str
270 /// ) -> Result<()> {
271 /// let response = client.create_notification_config()
272 /// .set_parent(format!("organizations/{organization_id}/locations/{location_id}"))
273 /// .set_notification_config(
274 /// NotificationConfig::new()/* set fields */
275 /// )
276 /// .send().await?;
277 /// println!("response {:?}", response);
278 /// Ok(())
279 /// }
280 /// ```
281 pub fn create_notification_config(
282 &self,
283 ) -> super::builder::security_center::CreateNotificationConfig {
284 super::builder::security_center::CreateNotificationConfig::new(self.inner.clone())
285 }
286
287 /// Creates a source.
288 ///
289 /// # Example
290 /// ```
291 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
292 /// use google_cloud_securitycenter_v2::model::Source;
293 /// use google_cloud_securitycenter_v2::Result;
294 /// async fn sample(
295 /// client: &SecurityCenter, parent: &str
296 /// ) -> Result<()> {
297 /// let response = client.create_source()
298 /// .set_parent(parent)
299 /// .set_source(
300 /// Source::new()/* set fields */
301 /// )
302 /// .send().await?;
303 /// println!("response {:?}", response);
304 /// Ok(())
305 /// }
306 /// ```
307 pub fn create_source(&self) -> super::builder::security_center::CreateSource {
308 super::builder::security_center::CreateSource::new(self.inner.clone())
309 }
310
311 /// Deletes an existing BigQuery export.
312 ///
313 /// # Example
314 /// ```
315 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
316 /// use google_cloud_securitycenter_v2::Result;
317 /// async fn sample(
318 /// client: &SecurityCenter, organization_id: &str, location_id: &str, export_id: &str
319 /// ) -> Result<()> {
320 /// client.delete_big_query_export()
321 /// .set_name(format!("organizations/{organization_id}/locations/{location_id}/bigQueryExports/{export_id}"))
322 /// .send().await?;
323 /// Ok(())
324 /// }
325 /// ```
326 pub fn delete_big_query_export(&self) -> super::builder::security_center::DeleteBigQueryExport {
327 super::builder::security_center::DeleteBigQueryExport::new(self.inner.clone())
328 }
329
330 /// Deletes an existing mute config. If no location is specified, default is
331 /// global.
332 ///
333 /// # Example
334 /// ```
335 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
336 /// use google_cloud_securitycenter_v2::Result;
337 /// async fn sample(
338 /// client: &SecurityCenter, organization_id: &str, mute_config_id: &str
339 /// ) -> Result<()> {
340 /// client.delete_mute_config()
341 /// .set_name(format!("organizations/{organization_id}/muteConfigs/{mute_config_id}"))
342 /// .send().await?;
343 /// Ok(())
344 /// }
345 /// ```
346 pub fn delete_mute_config(&self) -> super::builder::security_center::DeleteMuteConfig {
347 super::builder::security_center::DeleteMuteConfig::new(self.inner.clone())
348 }
349
350 /// Deletes a notification config.
351 ///
352 /// # Example
353 /// ```
354 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
355 /// use google_cloud_securitycenter_v2::Result;
356 /// async fn sample(
357 /// client: &SecurityCenter, organization_id: &str, location_id: &str, notification_config_id: &str
358 /// ) -> Result<()> {
359 /// client.delete_notification_config()
360 /// .set_name(format!("organizations/{organization_id}/locations/{location_id}/notificationConfigs/{notification_config_id}"))
361 /// .send().await?;
362 /// Ok(())
363 /// }
364 /// ```
365 pub fn delete_notification_config(
366 &self,
367 ) -> super::builder::security_center::DeleteNotificationConfig {
368 super::builder::security_center::DeleteNotificationConfig::new(self.inner.clone())
369 }
370
371 /// Deletes a ResourceValueConfig.
372 ///
373 /// # Example
374 /// ```
375 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
376 /// use google_cloud_securitycenter_v2::Result;
377 /// async fn sample(
378 /// client: &SecurityCenter, organization_id: &str, resource_value_config_id: &str
379 /// ) -> Result<()> {
380 /// client.delete_resource_value_config()
381 /// .set_name(format!("organizations/{organization_id}/resourceValueConfigs/{resource_value_config_id}"))
382 /// .send().await?;
383 /// Ok(())
384 /// }
385 /// ```
386 pub fn delete_resource_value_config(
387 &self,
388 ) -> super::builder::security_center::DeleteResourceValueConfig {
389 super::builder::security_center::DeleteResourceValueConfig::new(self.inner.clone())
390 }
391
392 /// Gets a BigQuery export.
393 ///
394 /// # Example
395 /// ```
396 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
397 /// use google_cloud_securitycenter_v2::Result;
398 /// async fn sample(
399 /// client: &SecurityCenter, organization_id: &str, location_id: &str, export_id: &str
400 /// ) -> Result<()> {
401 /// let response = client.get_big_query_export()
402 /// .set_name(format!("organizations/{organization_id}/locations/{location_id}/bigQueryExports/{export_id}"))
403 /// .send().await?;
404 /// println!("response {:?}", response);
405 /// Ok(())
406 /// }
407 /// ```
408 pub fn get_big_query_export(&self) -> super::builder::security_center::GetBigQueryExport {
409 super::builder::security_center::GetBigQueryExport::new(self.inner.clone())
410 }
411
412 /// Get the simulation by name or the latest simulation for the given
413 /// organization.
414 ///
415 /// # Example
416 /// ```
417 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
418 /// use google_cloud_securitycenter_v2::Result;
419 /// async fn sample(
420 /// client: &SecurityCenter, organization_id: &str, simulation_id: &str
421 /// ) -> Result<()> {
422 /// let response = client.get_simulation()
423 /// .set_name(format!("organizations/{organization_id}/simulations/{simulation_id}"))
424 /// .send().await?;
425 /// println!("response {:?}", response);
426 /// Ok(())
427 /// }
428 /// ```
429 pub fn get_simulation(&self) -> super::builder::security_center::GetSimulation {
430 super::builder::security_center::GetSimulation::new(self.inner.clone())
431 }
432
433 /// Get the valued resource by name
434 ///
435 /// # Example
436 /// ```
437 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
438 /// use google_cloud_securitycenter_v2::Result;
439 /// async fn sample(
440 /// client: &SecurityCenter, organization_id: &str, simulation_id: &str, valued_resource_id: &str
441 /// ) -> Result<()> {
442 /// let response = client.get_valued_resource()
443 /// .set_name(format!("organizations/{organization_id}/simulations/{simulation_id}/valuedResources/{valued_resource_id}"))
444 /// .send().await?;
445 /// println!("response {:?}", response);
446 /// Ok(())
447 /// }
448 /// ```
449 pub fn get_valued_resource(&self) -> super::builder::security_center::GetValuedResource {
450 super::builder::security_center::GetValuedResource::new(self.inner.clone())
451 }
452
453 /// Gets the access control policy on the specified Source.
454 ///
455 /// # Example
456 /// ```
457 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
458 /// use google_cloud_securitycenter_v2::Result;
459 /// async fn sample(
460 /// client: &SecurityCenter
461 /// ) -> Result<()> {
462 /// let response = client.get_iam_policy()
463 /// /* set fields */
464 /// .send().await?;
465 /// println!("response {:?}", response);
466 /// Ok(())
467 /// }
468 /// ```
469 pub fn get_iam_policy(&self) -> super::builder::security_center::GetIamPolicy {
470 super::builder::security_center::GetIamPolicy::new(self.inner.clone())
471 }
472
473 /// Gets a mute config. If no location is specified, default is
474 /// global.
475 ///
476 /// # Example
477 /// ```
478 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
479 /// use google_cloud_securitycenter_v2::Result;
480 /// async fn sample(
481 /// client: &SecurityCenter, organization_id: &str, mute_config_id: &str
482 /// ) -> Result<()> {
483 /// let response = client.get_mute_config()
484 /// .set_name(format!("organizations/{organization_id}/muteConfigs/{mute_config_id}"))
485 /// .send().await?;
486 /// println!("response {:?}", response);
487 /// Ok(())
488 /// }
489 /// ```
490 pub fn get_mute_config(&self) -> super::builder::security_center::GetMuteConfig {
491 super::builder::security_center::GetMuteConfig::new(self.inner.clone())
492 }
493
494 /// Gets a notification config.
495 ///
496 /// # Example
497 /// ```
498 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
499 /// use google_cloud_securitycenter_v2::Result;
500 /// async fn sample(
501 /// client: &SecurityCenter, organization_id: &str, location_id: &str, notification_config_id: &str
502 /// ) -> Result<()> {
503 /// let response = client.get_notification_config()
504 /// .set_name(format!("organizations/{organization_id}/locations/{location_id}/notificationConfigs/{notification_config_id}"))
505 /// .send().await?;
506 /// println!("response {:?}", response);
507 /// Ok(())
508 /// }
509 /// ```
510 pub fn get_notification_config(
511 &self,
512 ) -> super::builder::security_center::GetNotificationConfig {
513 super::builder::security_center::GetNotificationConfig::new(self.inner.clone())
514 }
515
516 /// Gets a ResourceValueConfig.
517 ///
518 /// # Example
519 /// ```
520 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
521 /// use google_cloud_securitycenter_v2::Result;
522 /// async fn sample(
523 /// client: &SecurityCenter, organization_id: &str, resource_value_config_id: &str
524 /// ) -> Result<()> {
525 /// let response = client.get_resource_value_config()
526 /// .set_name(format!("organizations/{organization_id}/resourceValueConfigs/{resource_value_config_id}"))
527 /// .send().await?;
528 /// println!("response {:?}", response);
529 /// Ok(())
530 /// }
531 /// ```
532 pub fn get_resource_value_config(
533 &self,
534 ) -> super::builder::security_center::GetResourceValueConfig {
535 super::builder::security_center::GetResourceValueConfig::new(self.inner.clone())
536 }
537
538 /// Gets a source.
539 ///
540 /// # Example
541 /// ```
542 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
543 /// use google_cloud_securitycenter_v2::Result;
544 /// async fn sample(
545 /// client: &SecurityCenter, organization_id: &str, source_id: &str
546 /// ) -> Result<()> {
547 /// let response = client.get_source()
548 /// .set_name(format!("organizations/{organization_id}/sources/{source_id}"))
549 /// .send().await?;
550 /// println!("response {:?}", response);
551 /// Ok(())
552 /// }
553 /// ```
554 pub fn get_source(&self) -> super::builder::security_center::GetSource {
555 super::builder::security_center::GetSource::new(self.inner.clone())
556 }
557
558 /// Filters an organization or source's findings and groups them by their
559 /// specified properties in a location. If no location is specified, findings
560 /// are assumed to be in global
561 ///
562 /// To group across all sources provide a `-` as the source id.
563 /// The following list shows some examples:
564 ///
565 /// + `/v2/organizations/{organization_id}/sources/-/findings`
566 ///
567 /// `/v2/organizations/{organization_id}/sources/-/locations/{location_id}/findings`
568 ///
569 /// + `/v2/folders/{folder_id}/sources/-/findings`
570 /// + `/v2/folders/{folder_id}/sources/-/locations/{location_id}/findings`
571 /// + `/v2/projects/{project_id}/sources/-/findings`
572 /// + `/v2/projects/{project_id}/sources/-/locations/{location_id}/findings`
573 ///
574 /// # Example
575 /// ```
576 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
577 /// use google_cloud_gax::paginator::ItemPaginator as _;
578 /// use google_cloud_securitycenter_v2::Result;
579 /// async fn sample(
580 /// client: &SecurityCenter
581 /// ) -> Result<()> {
582 /// let mut list = client.group_findings()
583 /// /* set fields */
584 /// .by_item();
585 /// while let Some(item) = list.next().await.transpose()? {
586 /// println!("{:?}", item);
587 /// }
588 /// Ok(())
589 /// }
590 /// ```
591 pub fn group_findings(&self) -> super::builder::security_center::GroupFindings {
592 super::builder::security_center::GroupFindings::new(self.inner.clone())
593 }
594
595 /// Lists the attack paths for a set of simulation results or valued resources
596 /// and filter.
597 ///
598 /// # Example
599 /// ```
600 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
601 /// use google_cloud_gax::paginator::ItemPaginator as _;
602 /// use google_cloud_securitycenter_v2::Result;
603 /// async fn sample(
604 /// client: &SecurityCenter, organization_id: &str, simulation_id: &str, valued_resource_id: &str
605 /// ) -> Result<()> {
606 /// let mut list = client.list_attack_paths()
607 /// .set_parent(format!("organizations/{organization_id}/simulations/{simulation_id}/valuedResources/{valued_resource_id}"))
608 /// .by_item();
609 /// while let Some(item) = list.next().await.transpose()? {
610 /// println!("{:?}", item);
611 /// }
612 /// Ok(())
613 /// }
614 /// ```
615 pub fn list_attack_paths(&self) -> super::builder::security_center::ListAttackPaths {
616 super::builder::security_center::ListAttackPaths::new(self.inner.clone())
617 }
618
619 /// Lists BigQuery exports. Note that when requesting BigQuery exports at a
620 /// given level all exports under that level are also returned e.g. if
621 /// requesting BigQuery exports under a folder, then all BigQuery exports
622 /// immediately under the folder plus the ones created under the projects
623 /// within the folder are returned.
624 ///
625 /// # Example
626 /// ```
627 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
628 /// use google_cloud_gax::paginator::ItemPaginator as _;
629 /// use google_cloud_securitycenter_v2::Result;
630 /// async fn sample(
631 /// client: &SecurityCenter, organization_id: &str, location_id: &str
632 /// ) -> Result<()> {
633 /// let mut list = client.list_big_query_exports()
634 /// .set_parent(format!("organizations/{organization_id}/locations/{location_id}"))
635 /// .by_item();
636 /// while let Some(item) = list.next().await.transpose()? {
637 /// println!("{:?}", item);
638 /// }
639 /// Ok(())
640 /// }
641 /// ```
642 pub fn list_big_query_exports(&self) -> super::builder::security_center::ListBigQueryExports {
643 super::builder::security_center::ListBigQueryExports::new(self.inner.clone())
644 }
645
646 /// Lists an organization or source's findings.
647 ///
648 /// To list across all sources for a given location provide a `-` as the source
649 /// id. If no location is specified, finding are assumed to be in global.
650 /// The following list shows some examples:
651 ///
652 /// + `/v2/organizations/{organization_id}/sources/-/findings`
653 ///
654 /// `/v2/organizations/{organization_id}/sources/-/locations/{location_id}/findings`
655 ///
656 /// # Example
657 /// ```
658 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
659 /// use google_cloud_gax::paginator::ItemPaginator as _;
660 /// use google_cloud_securitycenter_v2::Result;
661 /// async fn sample(
662 /// client: &SecurityCenter
663 /// ) -> Result<()> {
664 /// let mut list = client.list_findings()
665 /// /* set fields */
666 /// .by_item();
667 /// while let Some(item) = list.next().await.transpose()? {
668 /// println!("{:?}", item);
669 /// }
670 /// Ok(())
671 /// }
672 /// ```
673 pub fn list_findings(&self) -> super::builder::security_center::ListFindings {
674 super::builder::security_center::ListFindings::new(self.inner.clone())
675 }
676
677 /// Lists mute configs. If no location is specified, default is
678 /// global.
679 ///
680 /// # Example
681 /// ```
682 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
683 /// use google_cloud_gax::paginator::ItemPaginator as _;
684 /// use google_cloud_securitycenter_v2::Result;
685 /// async fn sample(
686 /// client: &SecurityCenter, organization_id: &str
687 /// ) -> Result<()> {
688 /// let mut list = client.list_mute_configs()
689 /// .set_parent(format!("organizations/{organization_id}"))
690 /// .by_item();
691 /// while let Some(item) = list.next().await.transpose()? {
692 /// println!("{:?}", item);
693 /// }
694 /// Ok(())
695 /// }
696 /// ```
697 pub fn list_mute_configs(&self) -> super::builder::security_center::ListMuteConfigs {
698 super::builder::security_center::ListMuteConfigs::new(self.inner.clone())
699 }
700
701 /// Lists notification configs.
702 ///
703 /// # Example
704 /// ```
705 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
706 /// use google_cloud_gax::paginator::ItemPaginator as _;
707 /// use google_cloud_securitycenter_v2::Result;
708 /// async fn sample(
709 /// client: &SecurityCenter, organization_id: &str, location_id: &str
710 /// ) -> Result<()> {
711 /// let mut list = client.list_notification_configs()
712 /// .set_parent(format!("organizations/{organization_id}/locations/{location_id}"))
713 /// .by_item();
714 /// while let Some(item) = list.next().await.transpose()? {
715 /// println!("{:?}", item);
716 /// }
717 /// Ok(())
718 /// }
719 /// ```
720 pub fn list_notification_configs(
721 &self,
722 ) -> super::builder::security_center::ListNotificationConfigs {
723 super::builder::security_center::ListNotificationConfigs::new(self.inner.clone())
724 }
725
726 /// Lists all ResourceValueConfigs.
727 ///
728 /// # Example
729 /// ```
730 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
731 /// use google_cloud_gax::paginator::ItemPaginator as _;
732 /// use google_cloud_securitycenter_v2::Result;
733 /// async fn sample(
734 /// client: &SecurityCenter, organization_id: &str
735 /// ) -> Result<()> {
736 /// let mut list = client.list_resource_value_configs()
737 /// .set_parent(format!("organizations/{organization_id}"))
738 /// .by_item();
739 /// while let Some(item) = list.next().await.transpose()? {
740 /// println!("{:?}", item);
741 /// }
742 /// Ok(())
743 /// }
744 /// ```
745 pub fn list_resource_value_configs(
746 &self,
747 ) -> super::builder::security_center::ListResourceValueConfigs {
748 super::builder::security_center::ListResourceValueConfigs::new(self.inner.clone())
749 }
750
751 /// Lists all sources belonging to an organization.
752 ///
753 /// # Example
754 /// ```
755 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
756 /// use google_cloud_gax::paginator::ItemPaginator as _;
757 /// use google_cloud_securitycenter_v2::Result;
758 /// async fn sample(
759 /// client: &SecurityCenter, organization_id: &str
760 /// ) -> Result<()> {
761 /// let mut list = client.list_sources()
762 /// .set_parent(format!("organizations/{organization_id}"))
763 /// .by_item();
764 /// while let Some(item) = list.next().await.transpose()? {
765 /// println!("{:?}", item);
766 /// }
767 /// Ok(())
768 /// }
769 /// ```
770 pub fn list_sources(&self) -> super::builder::security_center::ListSources {
771 super::builder::security_center::ListSources::new(self.inner.clone())
772 }
773
774 /// Lists the valued resources for a set of simulation results and filter.
775 ///
776 /// # Example
777 /// ```
778 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
779 /// use google_cloud_gax::paginator::ItemPaginator as _;
780 /// use google_cloud_securitycenter_v2::Result;
781 /// async fn sample(
782 /// client: &SecurityCenter, organization_id: &str, simulation_id: &str
783 /// ) -> Result<()> {
784 /// let mut list = client.list_valued_resources()
785 /// .set_parent(format!("organizations/{organization_id}/simulations/{simulation_id}"))
786 /// .by_item();
787 /// while let Some(item) = list.next().await.transpose()? {
788 /// println!("{:?}", item);
789 /// }
790 /// Ok(())
791 /// }
792 /// ```
793 pub fn list_valued_resources(&self) -> super::builder::security_center::ListValuedResources {
794 super::builder::security_center::ListValuedResources::new(self.inner.clone())
795 }
796
797 /// Updates the state of a finding. If no location is specified, finding is
798 /// assumed to be in global
799 ///
800 /// # Example
801 /// ```
802 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
803 /// use google_cloud_securitycenter_v2::Result;
804 /// async fn sample(
805 /// client: &SecurityCenter
806 /// ) -> Result<()> {
807 /// let response = client.set_finding_state()
808 /// /* set fields */
809 /// .send().await?;
810 /// println!("response {:?}", response);
811 /// Ok(())
812 /// }
813 /// ```
814 pub fn set_finding_state(&self) -> super::builder::security_center::SetFindingState {
815 super::builder::security_center::SetFindingState::new(self.inner.clone())
816 }
817
818 /// Sets the access control policy on the specified Source.
819 ///
820 /// # Example
821 /// ```
822 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
823 /// use google_cloud_securitycenter_v2::Result;
824 /// async fn sample(
825 /// client: &SecurityCenter
826 /// ) -> Result<()> {
827 /// let response = client.set_iam_policy()
828 /// /* set fields */
829 /// .send().await?;
830 /// println!("response {:?}", response);
831 /// Ok(())
832 /// }
833 /// ```
834 pub fn set_iam_policy(&self) -> super::builder::security_center::SetIamPolicy {
835 super::builder::security_center::SetIamPolicy::new(self.inner.clone())
836 }
837
838 /// Updates the mute state of a finding. If no location is specified, finding
839 /// is assumed to be in global
840 ///
841 /// # Example
842 /// ```
843 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
844 /// use google_cloud_securitycenter_v2::Result;
845 /// async fn sample(
846 /// client: &SecurityCenter
847 /// ) -> Result<()> {
848 /// let response = client.set_mute()
849 /// /* set fields */
850 /// .send().await?;
851 /// println!("response {:?}", response);
852 /// Ok(())
853 /// }
854 /// ```
855 pub fn set_mute(&self) -> super::builder::security_center::SetMute {
856 super::builder::security_center::SetMute::new(self.inner.clone())
857 }
858
859 /// Returns the permissions that a caller has on the specified source.
860 ///
861 /// # Example
862 /// ```
863 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
864 /// use google_cloud_securitycenter_v2::Result;
865 /// async fn sample(
866 /// client: &SecurityCenter
867 /// ) -> Result<()> {
868 /// let response = client.test_iam_permissions()
869 /// /* set fields */
870 /// .send().await?;
871 /// println!("response {:?}", response);
872 /// Ok(())
873 /// }
874 /// ```
875 pub fn test_iam_permissions(&self) -> super::builder::security_center::TestIamPermissions {
876 super::builder::security_center::TestIamPermissions::new(self.inner.clone())
877 }
878
879 /// Updates a BigQuery export.
880 ///
881 /// # Example
882 /// ```
883 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
884 /// # extern crate wkt as google_cloud_wkt;
885 /// use google_cloud_wkt::FieldMask;
886 /// use google_cloud_securitycenter_v2::model::BigQueryExport;
887 /// use google_cloud_securitycenter_v2::Result;
888 /// async fn sample(
889 /// client: &SecurityCenter, organization_id: &str, location_id: &str, export_id: &str
890 /// ) -> Result<()> {
891 /// let response = client.update_big_query_export()
892 /// .set_big_query_export(
893 /// BigQueryExport::new().set_name(format!("organizations/{organization_id}/locations/{location_id}/bigQueryExports/{export_id}"))/* set fields */
894 /// )
895 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
896 /// .send().await?;
897 /// println!("response {:?}", response);
898 /// Ok(())
899 /// }
900 /// ```
901 pub fn update_big_query_export(&self) -> super::builder::security_center::UpdateBigQueryExport {
902 super::builder::security_center::UpdateBigQueryExport::new(self.inner.clone())
903 }
904
905 /// Updates external system. This is for a given finding. If no location is
906 /// specified, finding is assumed to be in global
907 ///
908 /// # Example
909 /// ```
910 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
911 /// # extern crate wkt as google_cloud_wkt;
912 /// use google_cloud_wkt::FieldMask;
913 /// use google_cloud_securitycenter_v2::model::ExternalSystem;
914 /// use google_cloud_securitycenter_v2::Result;
915 /// async fn sample(
916 /// client: &SecurityCenter, organization_id: &str, source_id: &str, finding_id: &str, externalsystem_id: &str
917 /// ) -> Result<()> {
918 /// let response = client.update_external_system()
919 /// .set_external_system(
920 /// ExternalSystem::new().set_name(format!("organizations/{organization_id}/sources/{source_id}/findings/{finding_id}/externalSystems/{externalsystem_id}"))/* set fields */
921 /// )
922 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
923 /// .send().await?;
924 /// println!("response {:?}", response);
925 /// Ok(())
926 /// }
927 /// ```
928 pub fn update_external_system(&self) -> super::builder::security_center::UpdateExternalSystem {
929 super::builder::security_center::UpdateExternalSystem::new(self.inner.clone())
930 }
931
932 /// Creates or updates a finding. If no location is specified, finding is
933 /// assumed to be in global. The corresponding source must exist for a finding
934 /// creation to succeed.
935 ///
936 /// # Example
937 /// ```
938 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
939 /// # extern crate wkt as google_cloud_wkt;
940 /// use google_cloud_wkt::FieldMask;
941 /// use google_cloud_securitycenter_v2::model::Finding;
942 /// use google_cloud_securitycenter_v2::Result;
943 /// async fn sample(
944 /// client: &SecurityCenter, organization_id: &str, source_id: &str, finding_id: &str
945 /// ) -> Result<()> {
946 /// let response = client.update_finding()
947 /// .set_finding(
948 /// Finding::new().set_name(format!("organizations/{organization_id}/sources/{source_id}/findings/{finding_id}"))/* set fields */
949 /// )
950 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
951 /// .send().await?;
952 /// println!("response {:?}", response);
953 /// Ok(())
954 /// }
955 /// ```
956 pub fn update_finding(&self) -> super::builder::security_center::UpdateFinding {
957 super::builder::security_center::UpdateFinding::new(self.inner.clone())
958 }
959
960 /// Updates a mute config. If no location is specified, default is
961 /// global.
962 ///
963 /// # Example
964 /// ```
965 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
966 /// # extern crate wkt as google_cloud_wkt;
967 /// use google_cloud_wkt::FieldMask;
968 /// use google_cloud_securitycenter_v2::model::MuteConfig;
969 /// use google_cloud_securitycenter_v2::Result;
970 /// async fn sample(
971 /// client: &SecurityCenter, organization_id: &str, mute_config_id: &str
972 /// ) -> Result<()> {
973 /// let response = client.update_mute_config()
974 /// .set_mute_config(
975 /// MuteConfig::new().set_name(format!("organizations/{organization_id}/muteConfigs/{mute_config_id}"))/* set fields */
976 /// )
977 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
978 /// .send().await?;
979 /// println!("response {:?}", response);
980 /// Ok(())
981 /// }
982 /// ```
983 pub fn update_mute_config(&self) -> super::builder::security_center::UpdateMuteConfig {
984 super::builder::security_center::UpdateMuteConfig::new(self.inner.clone())
985 }
986
987 /// Updates a notification config. The following update
988 /// fields are allowed: description, pubsub_topic, streaming_config.filter
989 ///
990 /// # Example
991 /// ```
992 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
993 /// # extern crate wkt as google_cloud_wkt;
994 /// use google_cloud_wkt::FieldMask;
995 /// use google_cloud_securitycenter_v2::model::NotificationConfig;
996 /// use google_cloud_securitycenter_v2::Result;
997 /// async fn sample(
998 /// client: &SecurityCenter, organization_id: &str, location_id: &str, notification_config_id: &str
999 /// ) -> Result<()> {
1000 /// let response = client.update_notification_config()
1001 /// .set_notification_config(
1002 /// NotificationConfig::new().set_name(format!("organizations/{organization_id}/locations/{location_id}/notificationConfigs/{notification_config_id}"))/* set fields */
1003 /// )
1004 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1005 /// .send().await?;
1006 /// println!("response {:?}", response);
1007 /// Ok(())
1008 /// }
1009 /// ```
1010 pub fn update_notification_config(
1011 &self,
1012 ) -> super::builder::security_center::UpdateNotificationConfig {
1013 super::builder::security_center::UpdateNotificationConfig::new(self.inner.clone())
1014 }
1015
1016 /// Updates an existing ResourceValueConfigs with new rules.
1017 ///
1018 /// # Example
1019 /// ```
1020 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1021 /// # extern crate wkt as google_cloud_wkt;
1022 /// use google_cloud_wkt::FieldMask;
1023 /// use google_cloud_securitycenter_v2::model::ResourceValueConfig;
1024 /// use google_cloud_securitycenter_v2::Result;
1025 /// async fn sample(
1026 /// client: &SecurityCenter, organization_id: &str, resource_value_config_id: &str
1027 /// ) -> Result<()> {
1028 /// let response = client.update_resource_value_config()
1029 /// .set_resource_value_config(
1030 /// ResourceValueConfig::new().set_name(format!("organizations/{organization_id}/resourceValueConfigs/{resource_value_config_id}"))/* set fields */
1031 /// )
1032 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1033 /// .send().await?;
1034 /// println!("response {:?}", response);
1035 /// Ok(())
1036 /// }
1037 /// ```
1038 pub fn update_resource_value_config(
1039 &self,
1040 ) -> super::builder::security_center::UpdateResourceValueConfig {
1041 super::builder::security_center::UpdateResourceValueConfig::new(self.inner.clone())
1042 }
1043
1044 /// Updates security marks. For Finding Security marks, if no location is
1045 /// specified, finding is assumed to be in global. Assets Security Marks can
1046 /// only be accessed through global endpoint.
1047 ///
1048 /// # Example
1049 /// ```
1050 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1051 /// # extern crate wkt as google_cloud_wkt;
1052 /// use google_cloud_wkt::FieldMask;
1053 /// use google_cloud_securitycenter_v2::model::SecurityMarks;
1054 /// use google_cloud_securitycenter_v2::Result;
1055 /// async fn sample(
1056 /// client: &SecurityCenter, organization_id: &str, asset_id: &str
1057 /// ) -> Result<()> {
1058 /// let response = client.update_security_marks()
1059 /// .set_security_marks(
1060 /// SecurityMarks::new().set_name(format!("organizations/{organization_id}/assets/{asset_id}/securityMarks"))/* set fields */
1061 /// )
1062 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1063 /// .send().await?;
1064 /// println!("response {:?}", response);
1065 /// Ok(())
1066 /// }
1067 /// ```
1068 pub fn update_security_marks(&self) -> super::builder::security_center::UpdateSecurityMarks {
1069 super::builder::security_center::UpdateSecurityMarks::new(self.inner.clone())
1070 }
1071
1072 /// Updates a source.
1073 ///
1074 /// # Example
1075 /// ```
1076 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1077 /// # extern crate wkt as google_cloud_wkt;
1078 /// use google_cloud_wkt::FieldMask;
1079 /// use google_cloud_securitycenter_v2::model::Source;
1080 /// use google_cloud_securitycenter_v2::Result;
1081 /// async fn sample(
1082 /// client: &SecurityCenter, organization_id: &str, source_id: &str
1083 /// ) -> Result<()> {
1084 /// let response = client.update_source()
1085 /// .set_source(
1086 /// Source::new().set_name(format!("organizations/{organization_id}/sources/{source_id}"))/* set fields */
1087 /// )
1088 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1089 /// .send().await?;
1090 /// println!("response {:?}", response);
1091 /// Ok(())
1092 /// }
1093 /// ```
1094 pub fn update_source(&self) -> super::builder::security_center::UpdateSource {
1095 super::builder::security_center::UpdateSource::new(self.inner.clone())
1096 }
1097
1098 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1099 ///
1100 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1101 ///
1102 /// # Example
1103 /// ```
1104 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1105 /// use google_cloud_gax::paginator::ItemPaginator as _;
1106 /// use google_cloud_securitycenter_v2::Result;
1107 /// async fn sample(
1108 /// client: &SecurityCenter
1109 /// ) -> Result<()> {
1110 /// let mut list = client.list_operations()
1111 /// /* set fields */
1112 /// .by_item();
1113 /// while let Some(item) = list.next().await.transpose()? {
1114 /// println!("{:?}", item);
1115 /// }
1116 /// Ok(())
1117 /// }
1118 /// ```
1119 pub fn list_operations(&self) -> super::builder::security_center::ListOperations {
1120 super::builder::security_center::ListOperations::new(self.inner.clone())
1121 }
1122
1123 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1124 ///
1125 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1126 ///
1127 /// # Example
1128 /// ```
1129 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1130 /// use google_cloud_securitycenter_v2::Result;
1131 /// async fn sample(
1132 /// client: &SecurityCenter
1133 /// ) -> Result<()> {
1134 /// let response = client.get_operation()
1135 /// /* set fields */
1136 /// .send().await?;
1137 /// println!("response {:?}", response);
1138 /// Ok(())
1139 /// }
1140 /// ```
1141 pub fn get_operation(&self) -> super::builder::security_center::GetOperation {
1142 super::builder::security_center::GetOperation::new(self.inner.clone())
1143 }
1144
1145 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1146 ///
1147 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1148 ///
1149 /// # Example
1150 /// ```
1151 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1152 /// use google_cloud_securitycenter_v2::Result;
1153 /// async fn sample(
1154 /// client: &SecurityCenter
1155 /// ) -> Result<()> {
1156 /// client.delete_operation()
1157 /// /* set fields */
1158 /// .send().await?;
1159 /// Ok(())
1160 /// }
1161 /// ```
1162 pub fn delete_operation(&self) -> super::builder::security_center::DeleteOperation {
1163 super::builder::security_center::DeleteOperation::new(self.inner.clone())
1164 }
1165
1166 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1167 ///
1168 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1169 ///
1170 /// # Example
1171 /// ```
1172 /// # use google_cloud_securitycenter_v2::client::SecurityCenter;
1173 /// use google_cloud_securitycenter_v2::Result;
1174 /// async fn sample(
1175 /// client: &SecurityCenter
1176 /// ) -> Result<()> {
1177 /// client.cancel_operation()
1178 /// /* set fields */
1179 /// .send().await?;
1180 /// Ok(())
1181 /// }
1182 /// ```
1183 pub fn cancel_operation(&self) -> super::builder::security_center::CancelOperation {
1184 super::builder::security_center::CancelOperation::new(self.inner.clone())
1185 }
1186}