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 grafeas;
24extern crate iam_v1;
25extern crate lazy_static;
26extern crate reqwest;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34/// Request to get a vulnerability summary for some set of occurrences.
35#[serde_with::serde_as]
36#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
37#[serde(default, rename_all = "camelCase")]
38#[non_exhaustive]
39pub struct GetVulnerabilityOccurrencesSummaryRequest {
40    /// Required. The name of the project to get a vulnerability summary for in the form of
41    /// `projects/[PROJECT_ID]`.
42    #[serde(skip_serializing_if = "std::string::String::is_empty")]
43    pub parent: std::string::String,
44
45    /// The filter expression.
46    #[serde(skip_serializing_if = "std::string::String::is_empty")]
47    pub filter: std::string::String,
48}
49
50impl GetVulnerabilityOccurrencesSummaryRequest {
51    pub fn new() -> Self {
52        std::default::Default::default()
53    }
54
55    /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
56    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
57        self.parent = v.into();
58        self
59    }
60
61    /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
62    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
63        self.filter = v.into();
64        self
65    }
66}
67
68impl wkt::message::Message for GetVulnerabilityOccurrencesSummaryRequest {
69    fn typename() -> &'static str {
70        "type.googleapis.com/google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest"
71    }
72}
73
74/// A summary of how many vulnerability occurrences there are per resource and
75/// severity type.
76#[serde_with::serde_as]
77#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
78#[serde(default, rename_all = "camelCase")]
79#[non_exhaustive]
80pub struct VulnerabilityOccurrencesSummary {
81    /// A listing by resource of the number of fixable and total vulnerabilities.
82    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
83    pub counts:
84        std::vec::Vec<crate::model::vulnerability_occurrences_summary::FixableTotalByDigest>,
85}
86
87impl VulnerabilityOccurrencesSummary {
88    pub fn new() -> Self {
89        std::default::Default::default()
90    }
91
92    /// Sets the value of [counts][crate::model::VulnerabilityOccurrencesSummary::counts].
93    pub fn set_counts<T, V>(mut self, v: T) -> Self
94    where
95        T: std::iter::IntoIterator<Item = V>,
96        V: std::convert::Into<
97            crate::model::vulnerability_occurrences_summary::FixableTotalByDigest,
98        >,
99    {
100        use std::iter::Iterator;
101        self.counts = v.into_iter().map(|i| i.into()).collect();
102        self
103    }
104}
105
106impl wkt::message::Message for VulnerabilityOccurrencesSummary {
107    fn typename() -> &'static str {
108        "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary"
109    }
110}
111
112/// Defines additional types related to VulnerabilityOccurrencesSummary
113pub mod vulnerability_occurrences_summary {
114    #[allow(unused_imports)]
115    use super::*;
116
117    /// Per resource and severity counts of fixable and total vulnerabilities.
118    #[serde_with::serde_as]
119    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
120    #[serde(default, rename_all = "camelCase")]
121    #[non_exhaustive]
122    pub struct FixableTotalByDigest {
123        /// The affected resource.
124        #[serde(skip_serializing_if = "std::string::String::is_empty")]
125        pub resource_uri: std::string::String,
126
127        /// The severity for this count. SEVERITY_UNSPECIFIED indicates total across
128        /// all severities.
129        pub severity: grafeas::model::Severity,
130
131        /// The number of fixable vulnerabilities associated with this resource.
132        #[serde_as(as = "serde_with::DisplayFromStr")]
133        pub fixable_count: i64,
134
135        /// The total number of vulnerabilities associated with this resource.
136        #[serde_as(as = "serde_with::DisplayFromStr")]
137        pub total_count: i64,
138    }
139
140    impl FixableTotalByDigest {
141        pub fn new() -> Self {
142            std::default::Default::default()
143        }
144
145        /// Sets the value of [resource_uri][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::resource_uri].
146        pub fn set_resource_uri<T: std::convert::Into<std::string::String>>(
147            mut self,
148            v: T,
149        ) -> Self {
150            self.resource_uri = v.into();
151            self
152        }
153
154        /// Sets the value of [severity][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::severity].
155        pub fn set_severity<T: std::convert::Into<grafeas::model::Severity>>(
156            mut self,
157            v: T,
158        ) -> Self {
159            self.severity = v.into();
160            self
161        }
162
163        /// Sets the value of [fixable_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::fixable_count].
164        pub fn set_fixable_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
165            self.fixable_count = v.into();
166            self
167        }
168
169        /// Sets the value of [total_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::total_count].
170        pub fn set_total_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
171            self.total_count = v.into();
172            self
173        }
174    }
175
176    impl wkt::message::Message for FixableTotalByDigest {
177        fn typename() -> &'static str {
178            "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary.FixableTotalByDigest"
179        }
180    }
181}