Skip to main content

google_cloud_websecurityscanner_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 Web Security Scanner API.
20///
21/// # Example
22/// ```
23/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24/// # use google_cloud_websecurityscanner_v1::client::WebSecurityScanner;
25/// let client = WebSecurityScanner::builder().build().await?;
26/// // use `client` to make requests to the Web Security Scanner API.
27/// # Ok(()) }
28/// ```
29///
30/// # Service Description
31///
32/// Web Security Scanner Service identifies security vulnerabilities in web
33/// applications hosted on Google Cloud. It crawls your application, and
34/// attempts to exercise as many user inputs and event handlers as possible.
35///
36/// # Configuration
37///
38/// To configure `WebSecurityScanner` use the `with_*` methods in the type returned
39/// by [builder()][WebSecurityScanner::builder]. The default configuration should
40/// work for most applications. Common configuration changes include
41///
42/// * [with_endpoint()]: by default this client uses the global default endpoint
43///   (`https://websecurityscanner.googleapis.com`). Applications using regional
44///   endpoints or running in restricted networks (e.g. a network configured
45//    with [Private Google Access with VPC Service Controls]) may want to
46///   override this default.
47/// * [with_credentials()]: by default this client uses
48///   [Application Default Credentials]. Applications using custom
49///   authentication may need to override this default.
50///
51/// [with_endpoint()]: super::builder::web_security_scanner::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::web_security_scanner::ClientBuilder::credentials
53/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
54/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
55///
56/// # Pooling and Cloning
57///
58/// `WebSecurityScanner` holds a connection pool internally, it is advised to
59/// create one and the reuse it.  You do not need to wrap `WebSecurityScanner` in
60/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
61/// already uses an `Arc` internally.
62#[derive(Clone, Debug)]
63pub struct WebSecurityScanner {
64    inner: std::sync::Arc<dyn super::stub::dynamic::WebSecurityScanner>,
65}
66
67impl WebSecurityScanner {
68    /// Returns a builder for [WebSecurityScanner].
69    ///
70    /// ```
71    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
72    /// # use google_cloud_websecurityscanner_v1::client::WebSecurityScanner;
73    /// let client = WebSecurityScanner::builder().build().await?;
74    /// # Ok(()) }
75    /// ```
76    pub fn builder() -> super::builder::web_security_scanner::ClientBuilder {
77        crate::new_client_builder(super::builder::web_security_scanner::client::Factory)
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::WebSecurityScanner + '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    ) -> crate::ClientBuilderResult<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    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::WebSecurityScanner>>
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    ) -> crate::ClientBuilderResult<impl super::stub::WebSecurityScanner> {
113        super::transport::WebSecurityScanner::new(conf).await
114    }
115
116    async fn build_with_tracing(
117        conf: gaxi::options::ClientConfig,
118    ) -> crate::ClientBuilderResult<impl super::stub::WebSecurityScanner> {
119        Self::build_transport(conf)
120            .await
121            .map(super::tracing::WebSecurityScanner::new)
122    }
123
124    /// Creates a new ScanConfig.
125    pub fn create_scan_config(&self) -> super::builder::web_security_scanner::CreateScanConfig {
126        super::builder::web_security_scanner::CreateScanConfig::new(self.inner.clone())
127    }
128
129    /// Deletes an existing ScanConfig and its child resources.
130    pub fn delete_scan_config(&self) -> super::builder::web_security_scanner::DeleteScanConfig {
131        super::builder::web_security_scanner::DeleteScanConfig::new(self.inner.clone())
132    }
133
134    /// Gets a ScanConfig.
135    pub fn get_scan_config(&self) -> super::builder::web_security_scanner::GetScanConfig {
136        super::builder::web_security_scanner::GetScanConfig::new(self.inner.clone())
137    }
138
139    /// Lists ScanConfigs under a given project.
140    pub fn list_scan_configs(&self) -> super::builder::web_security_scanner::ListScanConfigs {
141        super::builder::web_security_scanner::ListScanConfigs::new(self.inner.clone())
142    }
143
144    /// Updates a ScanConfig. This method support partial update of a ScanConfig.
145    pub fn update_scan_config(&self) -> super::builder::web_security_scanner::UpdateScanConfig {
146        super::builder::web_security_scanner::UpdateScanConfig::new(self.inner.clone())
147    }
148
149    /// Start a ScanRun according to the given ScanConfig.
150    pub fn start_scan_run(&self) -> super::builder::web_security_scanner::StartScanRun {
151        super::builder::web_security_scanner::StartScanRun::new(self.inner.clone())
152    }
153
154    /// Gets a ScanRun.
155    pub fn get_scan_run(&self) -> super::builder::web_security_scanner::GetScanRun {
156        super::builder::web_security_scanner::GetScanRun::new(self.inner.clone())
157    }
158
159    /// Lists ScanRuns under a given ScanConfig, in descending order of ScanRun
160    /// stop time.
161    pub fn list_scan_runs(&self) -> super::builder::web_security_scanner::ListScanRuns {
162        super::builder::web_security_scanner::ListScanRuns::new(self.inner.clone())
163    }
164
165    /// Stops a ScanRun. The stopped ScanRun is returned.
166    pub fn stop_scan_run(&self) -> super::builder::web_security_scanner::StopScanRun {
167        super::builder::web_security_scanner::StopScanRun::new(self.inner.clone())
168    }
169
170    /// List CrawledUrls under a given ScanRun.
171    pub fn list_crawled_urls(&self) -> super::builder::web_security_scanner::ListCrawledUrls {
172        super::builder::web_security_scanner::ListCrawledUrls::new(self.inner.clone())
173    }
174
175    /// Gets a Finding.
176    pub fn get_finding(&self) -> super::builder::web_security_scanner::GetFinding {
177        super::builder::web_security_scanner::GetFinding::new(self.inner.clone())
178    }
179
180    /// List Findings under a given ScanRun.
181    pub fn list_findings(&self) -> super::builder::web_security_scanner::ListFindings {
182        super::builder::web_security_scanner::ListFindings::new(self.inner.clone())
183    }
184
185    /// List all FindingTypeStats under a given ScanRun.
186    pub fn list_finding_type_stats(
187        &self,
188    ) -> super::builder::web_security_scanner::ListFindingTypeStats {
189        super::builder::web_security_scanner::ListFindingTypeStats::new(self.inner.clone())
190    }
191}