google_cloud_containeranalysis_v1/
model.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
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate grafeas;
25extern crate iam_v1;
26extern crate lazy_static;
27extern crate reqwest;
28extern crate serde;
29extern crate serde_json;
30extern crate serde_with;
31extern crate std;
32extern crate tracing;
33extern crate wkt;
34
35/// The request to generate and export SBOM. Target must be specified for the
36/// request.
37#[serde_with::serde_as]
38#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
39#[serde(default, rename_all = "camelCase")]
40#[non_exhaustive]
41pub struct ExportSBOMRequest {
42    /// Required. The name of the resource in the form of
43    /// `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
44    #[serde(skip_serializing_if = "std::string::String::is_empty")]
45    pub name: std::string::String,
46
47    /// The location of the SBOM export.
48    #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
49    pub target: std::option::Option<crate::model::export_sbom_request::Target>,
50
51    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
52    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
53}
54
55impl ExportSBOMRequest {
56    pub fn new() -> Self {
57        std::default::Default::default()
58    }
59
60    /// Sets the value of [name][crate::model::ExportSBOMRequest::name].
61    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
62        self.name = v.into();
63        self
64    }
65
66    /// Sets the value of [target][crate::model::ExportSBOMRequest::target].
67    ///
68    /// Note that all the setters affecting `target` are mutually
69    /// exclusive.
70    pub fn set_target<
71        T: std::convert::Into<std::option::Option<crate::model::export_sbom_request::Target>>,
72    >(
73        mut self,
74        v: T,
75    ) -> Self {
76        self.target = v.into();
77        self
78    }
79
80    /// The value of [target][crate::model::ExportSBOMRequest::target]
81    /// if it holds a `CloudStorageLocation`, `None` if the field is not set or
82    /// holds a different branch.
83    pub fn cloud_storage_location(
84        &self,
85    ) -> std::option::Option<
86        &std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
87    > {
88        #[allow(unreachable_patterns)]
89        self.target.as_ref().and_then(|v| match v {
90            crate::model::export_sbom_request::Target::CloudStorageLocation(v) => {
91                std::option::Option::Some(v)
92            }
93            _ => std::option::Option::None,
94        })
95    }
96
97    /// Sets the value of [target][crate::model::ExportSBOMRequest::target]
98    /// to hold a `CloudStorageLocation`.
99    ///
100    /// Note that all the setters affecting `target` are
101    /// mutually exclusive.
102    pub fn set_cloud_storage_location<
103        T: std::convert::Into<
104                std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
105            >,
106    >(
107        mut self,
108        v: T,
109    ) -> Self {
110        self.target = std::option::Option::Some(
111            crate::model::export_sbom_request::Target::CloudStorageLocation(v.into()),
112        );
113        self
114    }
115}
116
117impl wkt::message::Message for ExportSBOMRequest {
118    fn typename() -> &'static str {
119        "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMRequest"
120    }
121}
122
123/// Defines additional types related to [ExportSBOMRequest].
124pub mod export_sbom_request {
125    #[allow(unused_imports)]
126    use super::*;
127
128    /// Empty placeholder to denote that this is a Google Cloud Storage
129    /// export request.
130    #[serde_with::serde_as]
131    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
132    #[serde(default, rename_all = "camelCase")]
133    #[non_exhaustive]
134    pub struct CloudStorageLocation {
135        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
136        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
137    }
138
139    impl CloudStorageLocation {
140        pub fn new() -> Self {
141            std::default::Default::default()
142        }
143    }
144
145    impl wkt::message::Message for CloudStorageLocation {
146        fn typename() -> &'static str {
147            "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMRequest.CloudStorageLocation"
148        }
149    }
150
151    /// The location of the SBOM export.
152    #[serde_with::serde_as]
153    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
154    #[serde(rename_all = "camelCase")]
155    #[non_exhaustive]
156    pub enum Target {
157        /// Optional. Empty placeholder to denote that this is a Google Cloud Storage
158        /// export request.
159        CloudStorageLocation(
160            std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
161        ),
162    }
163}
164
165/// The response from a call to ExportSBOM.
166#[serde_with::serde_as]
167#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
168#[serde(default, rename_all = "camelCase")]
169#[non_exhaustive]
170pub struct ExportSBOMResponse {
171    /// The name of the discovery occurrence in the form
172    /// "projects/{project_id}/occurrences/{OCCURRENCE_ID}
173    /// It can be used to track the progress of the SBOM export.
174    #[serde(skip_serializing_if = "std::string::String::is_empty")]
175    pub discovery_occurrence: std::string::String,
176
177    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
178    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
179}
180
181impl ExportSBOMResponse {
182    pub fn new() -> Self {
183        std::default::Default::default()
184    }
185
186    /// Sets the value of [discovery_occurrence][crate::model::ExportSBOMResponse::discovery_occurrence].
187    pub fn set_discovery_occurrence<T: std::convert::Into<std::string::String>>(
188        mut self,
189        v: T,
190    ) -> Self {
191        self.discovery_occurrence = v.into();
192        self
193    }
194}
195
196impl wkt::message::Message for ExportSBOMResponse {
197    fn typename() -> &'static str {
198        "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMResponse"
199    }
200}
201
202/// Request to get a vulnerability summary for some set of occurrences.
203#[serde_with::serde_as]
204#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
205#[serde(default, rename_all = "camelCase")]
206#[non_exhaustive]
207pub struct GetVulnerabilityOccurrencesSummaryRequest {
208    /// Required. The name of the project to get a vulnerability summary for in the
209    /// form of `projects/[PROJECT_ID]`.
210    #[serde(skip_serializing_if = "std::string::String::is_empty")]
211    pub parent: std::string::String,
212
213    /// The filter expression.
214    #[serde(skip_serializing_if = "std::string::String::is_empty")]
215    pub filter: std::string::String,
216
217    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
218    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
219}
220
221impl GetVulnerabilityOccurrencesSummaryRequest {
222    pub fn new() -> Self {
223        std::default::Default::default()
224    }
225
226    /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
227    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
228        self.parent = v.into();
229        self
230    }
231
232    /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
233    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
234        self.filter = v.into();
235        self
236    }
237}
238
239impl wkt::message::Message for GetVulnerabilityOccurrencesSummaryRequest {
240    fn typename() -> &'static str {
241        "type.googleapis.com/google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest"
242    }
243}
244
245/// A summary of how many vulnerability occurrences there are per resource and
246/// severity type.
247#[serde_with::serde_as]
248#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
249#[serde(default, rename_all = "camelCase")]
250#[non_exhaustive]
251pub struct VulnerabilityOccurrencesSummary {
252    /// A listing by resource of the number of fixable and total vulnerabilities.
253    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
254    pub counts:
255        std::vec::Vec<crate::model::vulnerability_occurrences_summary::FixableTotalByDigest>,
256
257    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
258    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
259}
260
261impl VulnerabilityOccurrencesSummary {
262    pub fn new() -> Self {
263        std::default::Default::default()
264    }
265
266    /// Sets the value of [counts][crate::model::VulnerabilityOccurrencesSummary::counts].
267    pub fn set_counts<T, V>(mut self, v: T) -> Self
268    where
269        T: std::iter::IntoIterator<Item = V>,
270        V: std::convert::Into<
271                crate::model::vulnerability_occurrences_summary::FixableTotalByDigest,
272            >,
273    {
274        use std::iter::Iterator;
275        self.counts = v.into_iter().map(|i| i.into()).collect();
276        self
277    }
278}
279
280impl wkt::message::Message for VulnerabilityOccurrencesSummary {
281    fn typename() -> &'static str {
282        "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary"
283    }
284}
285
286/// Defines additional types related to [VulnerabilityOccurrencesSummary].
287pub mod vulnerability_occurrences_summary {
288    #[allow(unused_imports)]
289    use super::*;
290
291    /// Per resource and severity counts of fixable and total vulnerabilities.
292    #[serde_with::serde_as]
293    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
294    #[serde(default, rename_all = "camelCase")]
295    #[non_exhaustive]
296    pub struct FixableTotalByDigest {
297        /// The affected resource.
298        #[serde(skip_serializing_if = "std::string::String::is_empty")]
299        pub resource_uri: std::string::String,
300
301        /// The severity for this count. SEVERITY_UNSPECIFIED indicates total across
302        /// all severities.
303        pub severity: grafeas::model::Severity,
304
305        /// The number of fixable vulnerabilities associated with this resource.
306        #[serde(skip_serializing_if = "wkt::internal::is_default")]
307        #[serde_as(as = "serde_with::DisplayFromStr")]
308        pub fixable_count: i64,
309
310        /// The total number of vulnerabilities associated with this resource.
311        #[serde(skip_serializing_if = "wkt::internal::is_default")]
312        #[serde_as(as = "serde_with::DisplayFromStr")]
313        pub total_count: i64,
314
315        #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
316        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
317    }
318
319    impl FixableTotalByDigest {
320        pub fn new() -> Self {
321            std::default::Default::default()
322        }
323
324        /// Sets the value of [resource_uri][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::resource_uri].
325        pub fn set_resource_uri<T: std::convert::Into<std::string::String>>(
326            mut self,
327            v: T,
328        ) -> Self {
329            self.resource_uri = v.into();
330            self
331        }
332
333        /// Sets the value of [severity][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::severity].
334        pub fn set_severity<T: std::convert::Into<grafeas::model::Severity>>(
335            mut self,
336            v: T,
337        ) -> Self {
338            self.severity = v.into();
339            self
340        }
341
342        /// Sets the value of [fixable_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::fixable_count].
343        pub fn set_fixable_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
344            self.fixable_count = v.into();
345            self
346        }
347
348        /// Sets the value of [total_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::total_count].
349        pub fn set_total_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
350            self.total_count = v.into();
351            self
352        }
353    }
354
355    impl wkt::message::Message for FixableTotalByDigest {
356        fn typename() -> &'static str {
357            "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary.FixableTotalByDigest"
358        }
359    }
360}