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() -> 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() -> 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 gax::client_builder::internal::new_builder(
78 super::builder::web_security_scanner::client::Factory,
79 )
80 }
81
82 /// Creates a new client from the provided stub.
83 ///
84 /// The most common case for calling this function is in tests mocking the
85 /// client's behavior.
86 pub fn from_stub<T>(stub: T) -> Self
87 where
88 T: super::stub::WebSecurityScanner + 'static,
89 {
90 Self {
91 inner: std::sync::Arc::new(stub),
92 }
93 }
94
95 pub(crate) async fn new(
96 config: gaxi::options::ClientConfig,
97 ) -> gax::client_builder::Result<Self> {
98 let inner = Self::build_inner(config).await?;
99 Ok(Self { inner })
100 }
101
102 async fn build_inner(
103 conf: gaxi::options::ClientConfig,
104 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::WebSecurityScanner>>
105 {
106 if gaxi::options::tracing_enabled(&conf) {
107 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
108 }
109 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
110 }
111
112 async fn build_transport(
113 conf: gaxi::options::ClientConfig,
114 ) -> gax::client_builder::Result<impl super::stub::WebSecurityScanner> {
115 super::transport::WebSecurityScanner::new(conf).await
116 }
117
118 async fn build_with_tracing(
119 conf: gaxi::options::ClientConfig,
120 ) -> gax::client_builder::Result<impl super::stub::WebSecurityScanner> {
121 Self::build_transport(conf)
122 .await
123 .map(super::tracing::WebSecurityScanner::new)
124 }
125
126 /// Creates a new ScanConfig.
127 pub fn create_scan_config(&self) -> super::builder::web_security_scanner::CreateScanConfig {
128 super::builder::web_security_scanner::CreateScanConfig::new(self.inner.clone())
129 }
130
131 /// Deletes an existing ScanConfig and its child resources.
132 pub fn delete_scan_config(&self) -> super::builder::web_security_scanner::DeleteScanConfig {
133 super::builder::web_security_scanner::DeleteScanConfig::new(self.inner.clone())
134 }
135
136 /// Gets a ScanConfig.
137 pub fn get_scan_config(&self) -> super::builder::web_security_scanner::GetScanConfig {
138 super::builder::web_security_scanner::GetScanConfig::new(self.inner.clone())
139 }
140
141 /// Lists ScanConfigs under a given project.
142 pub fn list_scan_configs(&self) -> super::builder::web_security_scanner::ListScanConfigs {
143 super::builder::web_security_scanner::ListScanConfigs::new(self.inner.clone())
144 }
145
146 /// Updates a ScanConfig. This method support partial update of a ScanConfig.
147 pub fn update_scan_config(&self) -> super::builder::web_security_scanner::UpdateScanConfig {
148 super::builder::web_security_scanner::UpdateScanConfig::new(self.inner.clone())
149 }
150
151 /// Start a ScanRun according to the given ScanConfig.
152 pub fn start_scan_run(&self) -> super::builder::web_security_scanner::StartScanRun {
153 super::builder::web_security_scanner::StartScanRun::new(self.inner.clone())
154 }
155
156 /// Gets a ScanRun.
157 pub fn get_scan_run(&self) -> super::builder::web_security_scanner::GetScanRun {
158 super::builder::web_security_scanner::GetScanRun::new(self.inner.clone())
159 }
160
161 /// Lists ScanRuns under a given ScanConfig, in descending order of ScanRun
162 /// stop time.
163 pub fn list_scan_runs(&self) -> super::builder::web_security_scanner::ListScanRuns {
164 super::builder::web_security_scanner::ListScanRuns::new(self.inner.clone())
165 }
166
167 /// Stops a ScanRun. The stopped ScanRun is returned.
168 pub fn stop_scan_run(&self) -> super::builder::web_security_scanner::StopScanRun {
169 super::builder::web_security_scanner::StopScanRun::new(self.inner.clone())
170 }
171
172 /// List CrawledUrls under a given ScanRun.
173 pub fn list_crawled_urls(&self) -> super::builder::web_security_scanner::ListCrawledUrls {
174 super::builder::web_security_scanner::ListCrawledUrls::new(self.inner.clone())
175 }
176
177 /// Gets a Finding.
178 pub fn get_finding(&self) -> super::builder::web_security_scanner::GetFinding {
179 super::builder::web_security_scanner::GetFinding::new(self.inner.clone())
180 }
181
182 /// List Findings under a given ScanRun.
183 pub fn list_findings(&self) -> super::builder::web_security_scanner::ListFindings {
184 super::builder::web_security_scanner::ListFindings::new(self.inner.clone())
185 }
186
187 /// List all FindingTypeStats under a given ScanRun.
188 pub fn list_finding_type_stats(
189 &self,
190 ) -> super::builder::web_security_scanner::ListFindingTypeStats {
191 super::builder::web_security_scanner::ListFindingTypeStats::new(self.inner.clone())
192 }
193}