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#[derive(Clone, Default, PartialEq)]
38#[non_exhaustive]
39pub struct ExportSBOMRequest {
40    /// Required. The name of the resource in the form of
41    /// `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
42    pub name: std::string::String,
43
44    /// The location of the SBOM export.
45    pub target: std::option::Option<crate::model::export_sbom_request::Target>,
46
47    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
48}
49
50impl ExportSBOMRequest {
51    pub fn new() -> Self {
52        std::default::Default::default()
53    }
54
55    /// Sets the value of [name][crate::model::ExportSBOMRequest::name].
56    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
57        self.name = v.into();
58        self
59    }
60
61    /// Sets the value of [target][crate::model::ExportSBOMRequest::target].
62    ///
63    /// Note that all the setters affecting `target` are mutually
64    /// exclusive.
65    pub fn set_target<
66        T: std::convert::Into<std::option::Option<crate::model::export_sbom_request::Target>>,
67    >(
68        mut self,
69        v: T,
70    ) -> Self {
71        self.target = v.into();
72        self
73    }
74
75    /// The value of [target][crate::model::ExportSBOMRequest::target]
76    /// if it holds a `CloudStorageLocation`, `None` if the field is not set or
77    /// holds a different branch.
78    pub fn cloud_storage_location(
79        &self,
80    ) -> std::option::Option<
81        &std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
82    > {
83        #[allow(unreachable_patterns)]
84        self.target.as_ref().and_then(|v| match v {
85            crate::model::export_sbom_request::Target::CloudStorageLocation(v) => {
86                std::option::Option::Some(v)
87            }
88            _ => std::option::Option::None,
89        })
90    }
91
92    /// Sets the value of [target][crate::model::ExportSBOMRequest::target]
93    /// to hold a `CloudStorageLocation`.
94    ///
95    /// Note that all the setters affecting `target` are
96    /// mutually exclusive.
97    pub fn set_cloud_storage_location<
98        T: std::convert::Into<
99                std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
100            >,
101    >(
102        mut self,
103        v: T,
104    ) -> Self {
105        self.target = std::option::Option::Some(
106            crate::model::export_sbom_request::Target::CloudStorageLocation(v.into()),
107        );
108        self
109    }
110}
111
112impl wkt::message::Message for ExportSBOMRequest {
113    fn typename() -> &'static str {
114        "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMRequest"
115    }
116}
117
118#[doc(hidden)]
119impl<'de> serde::de::Deserialize<'de> for ExportSBOMRequest {
120    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
121    where
122        D: serde::Deserializer<'de>,
123    {
124        #[allow(non_camel_case_types)]
125        #[doc(hidden)]
126        #[derive(PartialEq, Eq, Hash)]
127        enum __FieldTag {
128            __name,
129            __cloud_storage_location,
130            Unknown(std::string::String),
131        }
132        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
133            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
134            where
135                D: serde::Deserializer<'de>,
136            {
137                struct Visitor;
138                impl<'de> serde::de::Visitor<'de> for Visitor {
139                    type Value = __FieldTag;
140                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
141                        formatter.write_str("a field name for ExportSBOMRequest")
142                    }
143                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
144                    where
145                        E: serde::de::Error,
146                    {
147                        use std::result::Result::Ok;
148                        use std::string::ToString;
149                        match value {
150                            "name" => Ok(__FieldTag::__name),
151                            "cloudStorageLocation" => Ok(__FieldTag::__cloud_storage_location),
152                            "cloud_storage_location" => Ok(__FieldTag::__cloud_storage_location),
153                            _ => Ok(__FieldTag::Unknown(value.to_string())),
154                        }
155                    }
156                }
157                deserializer.deserialize_identifier(Visitor)
158            }
159        }
160        struct Visitor;
161        impl<'de> serde::de::Visitor<'de> for Visitor {
162            type Value = ExportSBOMRequest;
163            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
164                formatter.write_str("struct ExportSBOMRequest")
165            }
166            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
167            where
168                A: serde::de::MapAccess<'de>,
169            {
170                #[allow(unused_imports)]
171                use serde::de::Error;
172                use std::option::Option::Some;
173                let mut fields = std::collections::HashSet::new();
174                let mut result = Self::Value::new();
175                while let Some(tag) = map.next_key::<__FieldTag>()? {
176                    #[allow(clippy::match_single_binding)]
177                    match tag {
178                        __FieldTag::__name => {
179                            if !fields.insert(__FieldTag::__name) {
180                                return std::result::Result::Err(A::Error::duplicate_field(
181                                    "multiple values for name",
182                                ));
183                            }
184                            result.name = map
185                                .next_value::<std::option::Option<std::string::String>>()?
186                                .unwrap_or_default();
187                        }
188                        __FieldTag::__cloud_storage_location => {
189                            if !fields.insert(__FieldTag::__cloud_storage_location) {
190                                return std::result::Result::Err(A::Error::duplicate_field(
191                                    "multiple values for cloud_storage_location",
192                                ));
193                            }
194                            if result.target.is_some() {
195                                return std::result::Result::Err(A::Error::duplicate_field(
196                                    "multiple values for `target`, a oneof with full ID .google.devtools.containeranalysis.v1.ExportSBOMRequest.cloud_storage_location, latest field was cloudStorageLocation",
197                                ));
198                            }
199                            result.target = std::option::Option::Some(
200                                crate::model::export_sbom_request::Target::CloudStorageLocation(
201                                    map.next_value::<std::option::Option<
202                                        std::boxed::Box<
203                                            crate::model::export_sbom_request::CloudStorageLocation,
204                                        >,
205                                    >>()?
206                                    .unwrap_or_default(),
207                                ),
208                            );
209                        }
210                        __FieldTag::Unknown(key) => {
211                            let value = map.next_value::<serde_json::Value>()?;
212                            result._unknown_fields.insert(key, value);
213                        }
214                    }
215                }
216                std::result::Result::Ok(result)
217            }
218        }
219        deserializer.deserialize_any(Visitor)
220    }
221}
222
223#[doc(hidden)]
224impl serde::ser::Serialize for ExportSBOMRequest {
225    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
226    where
227        S: serde::ser::Serializer,
228    {
229        use serde::ser::SerializeMap;
230        #[allow(unused_imports)]
231        use std::option::Option::Some;
232        let mut state = serializer.serialize_map(std::option::Option::None)?;
233        if !self.name.is_empty() {
234            state.serialize_entry("name", &self.name)?;
235        }
236        if let Some(value) = self.cloud_storage_location() {
237            state.serialize_entry("cloudStorageLocation", value)?;
238        }
239        if !self._unknown_fields.is_empty() {
240            for (key, value) in self._unknown_fields.iter() {
241                state.serialize_entry(key, &value)?;
242            }
243        }
244        state.end()
245    }
246}
247
248impl std::fmt::Debug for ExportSBOMRequest {
249    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
250        let mut debug_struct = f.debug_struct("ExportSBOMRequest");
251        debug_struct.field("name", &self.name);
252        debug_struct.field("target", &self.target);
253        if !self._unknown_fields.is_empty() {
254            debug_struct.field("_unknown_fields", &self._unknown_fields);
255        }
256        debug_struct.finish()
257    }
258}
259
260/// Defines additional types related to [ExportSBOMRequest].
261pub mod export_sbom_request {
262    #[allow(unused_imports)]
263    use super::*;
264
265    /// Empty placeholder to denote that this is a Google Cloud Storage
266    /// export request.
267    #[derive(Clone, Default, PartialEq)]
268    #[non_exhaustive]
269    pub struct CloudStorageLocation {
270        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
271    }
272
273    impl CloudStorageLocation {
274        pub fn new() -> Self {
275            std::default::Default::default()
276        }
277    }
278
279    impl wkt::message::Message for CloudStorageLocation {
280        fn typename() -> &'static str {
281            "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMRequest.CloudStorageLocation"
282        }
283    }
284
285    #[doc(hidden)]
286    impl<'de> serde::de::Deserialize<'de> for CloudStorageLocation {
287        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
288        where
289            D: serde::Deserializer<'de>,
290        {
291            #[allow(non_camel_case_types)]
292            #[doc(hidden)]
293            #[derive(PartialEq, Eq, Hash)]
294            enum __FieldTag {
295                Unknown(std::string::String),
296            }
297            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
298                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
299                where
300                    D: serde::Deserializer<'de>,
301                {
302                    struct Visitor;
303                    impl<'de> serde::de::Visitor<'de> for Visitor {
304                        type Value = __FieldTag;
305                        fn expecting(
306                            &self,
307                            formatter: &mut std::fmt::Formatter,
308                        ) -> std::fmt::Result {
309                            formatter.write_str("a field name for CloudStorageLocation")
310                        }
311                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
312                        where
313                            E: serde::de::Error,
314                        {
315                            use std::result::Result::Ok;
316                            use std::string::ToString;
317                            Ok(__FieldTag::Unknown(value.to_string()))
318                        }
319                    }
320                    deserializer.deserialize_identifier(Visitor)
321                }
322            }
323            struct Visitor;
324            impl<'de> serde::de::Visitor<'de> for Visitor {
325                type Value = CloudStorageLocation;
326                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
327                    formatter.write_str("struct CloudStorageLocation")
328                }
329                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
330                where
331                    A: serde::de::MapAccess<'de>,
332                {
333                    #[allow(unused_imports)]
334                    use serde::de::Error;
335                    use std::option::Option::Some;
336                    let mut result = Self::Value::new();
337                    while let Some(tag) = map.next_key::<__FieldTag>()? {
338                        #[allow(clippy::match_single_binding)]
339                        match tag {
340                            __FieldTag::Unknown(key) => {
341                                let value = map.next_value::<serde_json::Value>()?;
342                                result._unknown_fields.insert(key, value);
343                            }
344                        }
345                    }
346                    std::result::Result::Ok(result)
347                }
348            }
349            deserializer.deserialize_any(Visitor)
350        }
351    }
352
353    #[doc(hidden)]
354    impl serde::ser::Serialize for CloudStorageLocation {
355        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
356        where
357            S: serde::ser::Serializer,
358        {
359            use serde::ser::SerializeMap;
360            #[allow(unused_imports)]
361            use std::option::Option::Some;
362            let mut state = serializer.serialize_map(std::option::Option::None)?;
363            if !self._unknown_fields.is_empty() {
364                for (key, value) in self._unknown_fields.iter() {
365                    state.serialize_entry(key, &value)?;
366                }
367            }
368            state.end()
369        }
370    }
371
372    impl std::fmt::Debug for CloudStorageLocation {
373        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
374            let mut debug_struct = f.debug_struct("CloudStorageLocation");
375            if !self._unknown_fields.is_empty() {
376                debug_struct.field("_unknown_fields", &self._unknown_fields);
377            }
378            debug_struct.finish()
379        }
380    }
381
382    /// The location of the SBOM export.
383    #[derive(Clone, Debug, PartialEq)]
384    #[non_exhaustive]
385    pub enum Target {
386        /// Optional. Empty placeholder to denote that this is a Google Cloud Storage
387        /// export request.
388        CloudStorageLocation(
389            std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
390        ),
391    }
392}
393
394/// The response from a call to ExportSBOM.
395#[derive(Clone, Default, PartialEq)]
396#[non_exhaustive]
397pub struct ExportSBOMResponse {
398    /// The name of the discovery occurrence in the form
399    /// "projects/{project_id}/occurrences/{OCCURRENCE_ID}
400    /// It can be used to track the progress of the SBOM export.
401    pub discovery_occurrence: std::string::String,
402
403    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
404}
405
406impl ExportSBOMResponse {
407    pub fn new() -> Self {
408        std::default::Default::default()
409    }
410
411    /// Sets the value of [discovery_occurrence][crate::model::ExportSBOMResponse::discovery_occurrence].
412    pub fn set_discovery_occurrence<T: std::convert::Into<std::string::String>>(
413        mut self,
414        v: T,
415    ) -> Self {
416        self.discovery_occurrence = v.into();
417        self
418    }
419}
420
421impl wkt::message::Message for ExportSBOMResponse {
422    fn typename() -> &'static str {
423        "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMResponse"
424    }
425}
426
427#[doc(hidden)]
428impl<'de> serde::de::Deserialize<'de> for ExportSBOMResponse {
429    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
430    where
431        D: serde::Deserializer<'de>,
432    {
433        #[allow(non_camel_case_types)]
434        #[doc(hidden)]
435        #[derive(PartialEq, Eq, Hash)]
436        enum __FieldTag {
437            __discovery_occurrence,
438            Unknown(std::string::String),
439        }
440        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
441            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
442            where
443                D: serde::Deserializer<'de>,
444            {
445                struct Visitor;
446                impl<'de> serde::de::Visitor<'de> for Visitor {
447                    type Value = __FieldTag;
448                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
449                        formatter.write_str("a field name for ExportSBOMResponse")
450                    }
451                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
452                    where
453                        E: serde::de::Error,
454                    {
455                        use std::result::Result::Ok;
456                        use std::string::ToString;
457                        match value {
458                            "discoveryOccurrence" => Ok(__FieldTag::__discovery_occurrence),
459                            "discovery_occurrence" => Ok(__FieldTag::__discovery_occurrence),
460                            _ => Ok(__FieldTag::Unknown(value.to_string())),
461                        }
462                    }
463                }
464                deserializer.deserialize_identifier(Visitor)
465            }
466        }
467        struct Visitor;
468        impl<'de> serde::de::Visitor<'de> for Visitor {
469            type Value = ExportSBOMResponse;
470            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
471                formatter.write_str("struct ExportSBOMResponse")
472            }
473            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
474            where
475                A: serde::de::MapAccess<'de>,
476            {
477                #[allow(unused_imports)]
478                use serde::de::Error;
479                use std::option::Option::Some;
480                let mut fields = std::collections::HashSet::new();
481                let mut result = Self::Value::new();
482                while let Some(tag) = map.next_key::<__FieldTag>()? {
483                    #[allow(clippy::match_single_binding)]
484                    match tag {
485                        __FieldTag::__discovery_occurrence => {
486                            if !fields.insert(__FieldTag::__discovery_occurrence) {
487                                return std::result::Result::Err(A::Error::duplicate_field(
488                                    "multiple values for discovery_occurrence",
489                                ));
490                            }
491                            result.discovery_occurrence = map
492                                .next_value::<std::option::Option<std::string::String>>()?
493                                .unwrap_or_default();
494                        }
495                        __FieldTag::Unknown(key) => {
496                            let value = map.next_value::<serde_json::Value>()?;
497                            result._unknown_fields.insert(key, value);
498                        }
499                    }
500                }
501                std::result::Result::Ok(result)
502            }
503        }
504        deserializer.deserialize_any(Visitor)
505    }
506}
507
508#[doc(hidden)]
509impl serde::ser::Serialize for ExportSBOMResponse {
510    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
511    where
512        S: serde::ser::Serializer,
513    {
514        use serde::ser::SerializeMap;
515        #[allow(unused_imports)]
516        use std::option::Option::Some;
517        let mut state = serializer.serialize_map(std::option::Option::None)?;
518        if !self.discovery_occurrence.is_empty() {
519            state.serialize_entry("discoveryOccurrence", &self.discovery_occurrence)?;
520        }
521        if !self._unknown_fields.is_empty() {
522            for (key, value) in self._unknown_fields.iter() {
523                state.serialize_entry(key, &value)?;
524            }
525        }
526        state.end()
527    }
528}
529
530impl std::fmt::Debug for ExportSBOMResponse {
531    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
532        let mut debug_struct = f.debug_struct("ExportSBOMResponse");
533        debug_struct.field("discovery_occurrence", &self.discovery_occurrence);
534        if !self._unknown_fields.is_empty() {
535            debug_struct.field("_unknown_fields", &self._unknown_fields);
536        }
537        debug_struct.finish()
538    }
539}
540
541/// Request to get a vulnerability summary for some set of occurrences.
542#[derive(Clone, Default, PartialEq)]
543#[non_exhaustive]
544pub struct GetVulnerabilityOccurrencesSummaryRequest {
545    /// Required. The name of the project to get a vulnerability summary for in the
546    /// form of `projects/[PROJECT_ID]`.
547    pub parent: std::string::String,
548
549    /// The filter expression.
550    pub filter: std::string::String,
551
552    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
553}
554
555impl GetVulnerabilityOccurrencesSummaryRequest {
556    pub fn new() -> Self {
557        std::default::Default::default()
558    }
559
560    /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
561    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
562        self.parent = v.into();
563        self
564    }
565
566    /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
567    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
568        self.filter = v.into();
569        self
570    }
571}
572
573impl wkt::message::Message for GetVulnerabilityOccurrencesSummaryRequest {
574    fn typename() -> &'static str {
575        "type.googleapis.com/google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest"
576    }
577}
578
579#[doc(hidden)]
580impl<'de> serde::de::Deserialize<'de> for GetVulnerabilityOccurrencesSummaryRequest {
581    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
582    where
583        D: serde::Deserializer<'de>,
584    {
585        #[allow(non_camel_case_types)]
586        #[doc(hidden)]
587        #[derive(PartialEq, Eq, Hash)]
588        enum __FieldTag {
589            __parent,
590            __filter,
591            Unknown(std::string::String),
592        }
593        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
594            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
595            where
596                D: serde::Deserializer<'de>,
597            {
598                struct Visitor;
599                impl<'de> serde::de::Visitor<'de> for Visitor {
600                    type Value = __FieldTag;
601                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
602                        formatter
603                            .write_str("a field name for GetVulnerabilityOccurrencesSummaryRequest")
604                    }
605                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
606                    where
607                        E: serde::de::Error,
608                    {
609                        use std::result::Result::Ok;
610                        use std::string::ToString;
611                        match value {
612                            "parent" => Ok(__FieldTag::__parent),
613                            "filter" => Ok(__FieldTag::__filter),
614                            _ => Ok(__FieldTag::Unknown(value.to_string())),
615                        }
616                    }
617                }
618                deserializer.deserialize_identifier(Visitor)
619            }
620        }
621        struct Visitor;
622        impl<'de> serde::de::Visitor<'de> for Visitor {
623            type Value = GetVulnerabilityOccurrencesSummaryRequest;
624            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
625                formatter.write_str("struct GetVulnerabilityOccurrencesSummaryRequest")
626            }
627            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
628            where
629                A: serde::de::MapAccess<'de>,
630            {
631                #[allow(unused_imports)]
632                use serde::de::Error;
633                use std::option::Option::Some;
634                let mut fields = std::collections::HashSet::new();
635                let mut result = Self::Value::new();
636                while let Some(tag) = map.next_key::<__FieldTag>()? {
637                    #[allow(clippy::match_single_binding)]
638                    match tag {
639                        __FieldTag::__parent => {
640                            if !fields.insert(__FieldTag::__parent) {
641                                return std::result::Result::Err(A::Error::duplicate_field(
642                                    "multiple values for parent",
643                                ));
644                            }
645                            result.parent = map
646                                .next_value::<std::option::Option<std::string::String>>()?
647                                .unwrap_or_default();
648                        }
649                        __FieldTag::__filter => {
650                            if !fields.insert(__FieldTag::__filter) {
651                                return std::result::Result::Err(A::Error::duplicate_field(
652                                    "multiple values for filter",
653                                ));
654                            }
655                            result.filter = map
656                                .next_value::<std::option::Option<std::string::String>>()?
657                                .unwrap_or_default();
658                        }
659                        __FieldTag::Unknown(key) => {
660                            let value = map.next_value::<serde_json::Value>()?;
661                            result._unknown_fields.insert(key, value);
662                        }
663                    }
664                }
665                std::result::Result::Ok(result)
666            }
667        }
668        deserializer.deserialize_any(Visitor)
669    }
670}
671
672#[doc(hidden)]
673impl serde::ser::Serialize for GetVulnerabilityOccurrencesSummaryRequest {
674    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
675    where
676        S: serde::ser::Serializer,
677    {
678        use serde::ser::SerializeMap;
679        #[allow(unused_imports)]
680        use std::option::Option::Some;
681        let mut state = serializer.serialize_map(std::option::Option::None)?;
682        if !self.parent.is_empty() {
683            state.serialize_entry("parent", &self.parent)?;
684        }
685        if !self.filter.is_empty() {
686            state.serialize_entry("filter", &self.filter)?;
687        }
688        if !self._unknown_fields.is_empty() {
689            for (key, value) in self._unknown_fields.iter() {
690                state.serialize_entry(key, &value)?;
691            }
692        }
693        state.end()
694    }
695}
696
697impl std::fmt::Debug for GetVulnerabilityOccurrencesSummaryRequest {
698    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
699        let mut debug_struct = f.debug_struct("GetVulnerabilityOccurrencesSummaryRequest");
700        debug_struct.field("parent", &self.parent);
701        debug_struct.field("filter", &self.filter);
702        if !self._unknown_fields.is_empty() {
703            debug_struct.field("_unknown_fields", &self._unknown_fields);
704        }
705        debug_struct.finish()
706    }
707}
708
709/// A summary of how many vulnerability occurrences there are per resource and
710/// severity type.
711#[derive(Clone, Default, PartialEq)]
712#[non_exhaustive]
713pub struct VulnerabilityOccurrencesSummary {
714    /// A listing by resource of the number of fixable and total vulnerabilities.
715    pub counts:
716        std::vec::Vec<crate::model::vulnerability_occurrences_summary::FixableTotalByDigest>,
717
718    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
719}
720
721impl VulnerabilityOccurrencesSummary {
722    pub fn new() -> Self {
723        std::default::Default::default()
724    }
725
726    /// Sets the value of [counts][crate::model::VulnerabilityOccurrencesSummary::counts].
727    pub fn set_counts<T, V>(mut self, v: T) -> Self
728    where
729        T: std::iter::IntoIterator<Item = V>,
730        V: std::convert::Into<
731                crate::model::vulnerability_occurrences_summary::FixableTotalByDigest,
732            >,
733    {
734        use std::iter::Iterator;
735        self.counts = v.into_iter().map(|i| i.into()).collect();
736        self
737    }
738}
739
740impl wkt::message::Message for VulnerabilityOccurrencesSummary {
741    fn typename() -> &'static str {
742        "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary"
743    }
744}
745
746#[doc(hidden)]
747impl<'de> serde::de::Deserialize<'de> for VulnerabilityOccurrencesSummary {
748    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
749    where
750        D: serde::Deserializer<'de>,
751    {
752        #[allow(non_camel_case_types)]
753        #[doc(hidden)]
754        #[derive(PartialEq, Eq, Hash)]
755        enum __FieldTag {
756            __counts,
757            Unknown(std::string::String),
758        }
759        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
760            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
761            where
762                D: serde::Deserializer<'de>,
763            {
764                struct Visitor;
765                impl<'de> serde::de::Visitor<'de> for Visitor {
766                    type Value = __FieldTag;
767                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
768                        formatter.write_str("a field name for VulnerabilityOccurrencesSummary")
769                    }
770                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
771                    where
772                        E: serde::de::Error,
773                    {
774                        use std::result::Result::Ok;
775                        use std::string::ToString;
776                        match value {
777                            "counts" => Ok(__FieldTag::__counts),
778                            _ => Ok(__FieldTag::Unknown(value.to_string())),
779                        }
780                    }
781                }
782                deserializer.deserialize_identifier(Visitor)
783            }
784        }
785        struct Visitor;
786        impl<'de> serde::de::Visitor<'de> for Visitor {
787            type Value = VulnerabilityOccurrencesSummary;
788            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
789                formatter.write_str("struct VulnerabilityOccurrencesSummary")
790            }
791            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
792            where
793                A: serde::de::MapAccess<'de>,
794            {
795                #[allow(unused_imports)]
796                use serde::de::Error;
797                use std::option::Option::Some;
798                let mut fields = std::collections::HashSet::new();
799                let mut result = Self::Value::new();
800                while let Some(tag) = map.next_key::<__FieldTag>()? {
801                    #[allow(clippy::match_single_binding)]
802                    match tag {
803                        __FieldTag::__counts => {
804                            if !fields.insert(__FieldTag::__counts) {
805                                return std::result::Result::Err(A::Error::duplicate_field(
806                                    "multiple values for counts",
807                                ));
808                            }
809                            result.counts = map.next_value::<std::option::Option<std::vec::Vec<crate::model::vulnerability_occurrences_summary::FixableTotalByDigest>>>()?.unwrap_or_default();
810                        }
811                        __FieldTag::Unknown(key) => {
812                            let value = map.next_value::<serde_json::Value>()?;
813                            result._unknown_fields.insert(key, value);
814                        }
815                    }
816                }
817                std::result::Result::Ok(result)
818            }
819        }
820        deserializer.deserialize_any(Visitor)
821    }
822}
823
824#[doc(hidden)]
825impl serde::ser::Serialize for VulnerabilityOccurrencesSummary {
826    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
827    where
828        S: serde::ser::Serializer,
829    {
830        use serde::ser::SerializeMap;
831        #[allow(unused_imports)]
832        use std::option::Option::Some;
833        let mut state = serializer.serialize_map(std::option::Option::None)?;
834        if !self.counts.is_empty() {
835            state.serialize_entry("counts", &self.counts)?;
836        }
837        if !self._unknown_fields.is_empty() {
838            for (key, value) in self._unknown_fields.iter() {
839                state.serialize_entry(key, &value)?;
840            }
841        }
842        state.end()
843    }
844}
845
846impl std::fmt::Debug for VulnerabilityOccurrencesSummary {
847    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
848        let mut debug_struct = f.debug_struct("VulnerabilityOccurrencesSummary");
849        debug_struct.field("counts", &self.counts);
850        if !self._unknown_fields.is_empty() {
851            debug_struct.field("_unknown_fields", &self._unknown_fields);
852        }
853        debug_struct.finish()
854    }
855}
856
857/// Defines additional types related to [VulnerabilityOccurrencesSummary].
858pub mod vulnerability_occurrences_summary {
859    #[allow(unused_imports)]
860    use super::*;
861
862    /// Per resource and severity counts of fixable and total vulnerabilities.
863    #[derive(Clone, Default, PartialEq)]
864    #[non_exhaustive]
865    pub struct FixableTotalByDigest {
866        /// The affected resource.
867        pub resource_uri: std::string::String,
868
869        /// The severity for this count. SEVERITY_UNSPECIFIED indicates total across
870        /// all severities.
871        pub severity: grafeas::model::Severity,
872
873        /// The number of fixable vulnerabilities associated with this resource.
874        pub fixable_count: i64,
875
876        /// The total number of vulnerabilities associated with this resource.
877        pub total_count: i64,
878
879        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
880    }
881
882    impl FixableTotalByDigest {
883        pub fn new() -> Self {
884            std::default::Default::default()
885        }
886
887        /// Sets the value of [resource_uri][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::resource_uri].
888        pub fn set_resource_uri<T: std::convert::Into<std::string::String>>(
889            mut self,
890            v: T,
891        ) -> Self {
892            self.resource_uri = v.into();
893            self
894        }
895
896        /// Sets the value of [severity][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::severity].
897        pub fn set_severity<T: std::convert::Into<grafeas::model::Severity>>(
898            mut self,
899            v: T,
900        ) -> Self {
901            self.severity = v.into();
902            self
903        }
904
905        /// Sets the value of [fixable_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::fixable_count].
906        pub fn set_fixable_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
907            self.fixable_count = v.into();
908            self
909        }
910
911        /// Sets the value of [total_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::total_count].
912        pub fn set_total_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
913            self.total_count = v.into();
914            self
915        }
916    }
917
918    impl wkt::message::Message for FixableTotalByDigest {
919        fn typename() -> &'static str {
920            "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary.FixableTotalByDigest"
921        }
922    }
923
924    #[doc(hidden)]
925    impl<'de> serde::de::Deserialize<'de> for FixableTotalByDigest {
926        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
927        where
928            D: serde::Deserializer<'de>,
929        {
930            #[allow(non_camel_case_types)]
931            #[doc(hidden)]
932            #[derive(PartialEq, Eq, Hash)]
933            enum __FieldTag {
934                __resource_uri,
935                __severity,
936                __fixable_count,
937                __total_count,
938                Unknown(std::string::String),
939            }
940            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
941                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
942                where
943                    D: serde::Deserializer<'de>,
944                {
945                    struct Visitor;
946                    impl<'de> serde::de::Visitor<'de> for Visitor {
947                        type Value = __FieldTag;
948                        fn expecting(
949                            &self,
950                            formatter: &mut std::fmt::Formatter,
951                        ) -> std::fmt::Result {
952                            formatter.write_str("a field name for FixableTotalByDigest")
953                        }
954                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
955                        where
956                            E: serde::de::Error,
957                        {
958                            use std::result::Result::Ok;
959                            use std::string::ToString;
960                            match value {
961                                "resourceUri" => Ok(__FieldTag::__resource_uri),
962                                "resource_uri" => Ok(__FieldTag::__resource_uri),
963                                "severity" => Ok(__FieldTag::__severity),
964                                "fixableCount" => Ok(__FieldTag::__fixable_count),
965                                "fixable_count" => Ok(__FieldTag::__fixable_count),
966                                "totalCount" => Ok(__FieldTag::__total_count),
967                                "total_count" => Ok(__FieldTag::__total_count),
968                                _ => Ok(__FieldTag::Unknown(value.to_string())),
969                            }
970                        }
971                    }
972                    deserializer.deserialize_identifier(Visitor)
973                }
974            }
975            struct Visitor;
976            impl<'de> serde::de::Visitor<'de> for Visitor {
977                type Value = FixableTotalByDigest;
978                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
979                    formatter.write_str("struct FixableTotalByDigest")
980                }
981                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
982                where
983                    A: serde::de::MapAccess<'de>,
984                {
985                    #[allow(unused_imports)]
986                    use serde::de::Error;
987                    use std::option::Option::Some;
988                    let mut fields = std::collections::HashSet::new();
989                    let mut result = Self::Value::new();
990                    while let Some(tag) = map.next_key::<__FieldTag>()? {
991                        #[allow(clippy::match_single_binding)]
992                        match tag {
993                            __FieldTag::__resource_uri => {
994                                if !fields.insert(__FieldTag::__resource_uri) {
995                                    return std::result::Result::Err(A::Error::duplicate_field(
996                                        "multiple values for resource_uri",
997                                    ));
998                                }
999                                result.resource_uri = map
1000                                    .next_value::<std::option::Option<std::string::String>>()?
1001                                    .unwrap_or_default();
1002                            }
1003                            __FieldTag::__severity => {
1004                                if !fields.insert(__FieldTag::__severity) {
1005                                    return std::result::Result::Err(A::Error::duplicate_field(
1006                                        "multiple values for severity",
1007                                    ));
1008                                }
1009                                result.severity = map
1010                                    .next_value::<std::option::Option<grafeas::model::Severity>>()?
1011                                    .unwrap_or_default();
1012                            }
1013                            __FieldTag::__fixable_count => {
1014                                if !fields.insert(__FieldTag::__fixable_count) {
1015                                    return std::result::Result::Err(A::Error::duplicate_field(
1016                                        "multiple values for fixable_count",
1017                                    ));
1018                                }
1019                                struct __With(std::option::Option<i64>);
1020                                impl<'de> serde::de::Deserialize<'de> for __With {
1021                                    fn deserialize<D>(
1022                                        deserializer: D,
1023                                    ) -> std::result::Result<Self, D::Error>
1024                                    where
1025                                        D: serde::de::Deserializer<'de>,
1026                                    {
1027                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1028                                    }
1029                                }
1030                                result.fixable_count =
1031                                    map.next_value::<__With>()?.0.unwrap_or_default();
1032                            }
1033                            __FieldTag::__total_count => {
1034                                if !fields.insert(__FieldTag::__total_count) {
1035                                    return std::result::Result::Err(A::Error::duplicate_field(
1036                                        "multiple values for total_count",
1037                                    ));
1038                                }
1039                                struct __With(std::option::Option<i64>);
1040                                impl<'de> serde::de::Deserialize<'de> for __With {
1041                                    fn deserialize<D>(
1042                                        deserializer: D,
1043                                    ) -> std::result::Result<Self, D::Error>
1044                                    where
1045                                        D: serde::de::Deserializer<'de>,
1046                                    {
1047                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1048                                    }
1049                                }
1050                                result.total_count =
1051                                    map.next_value::<__With>()?.0.unwrap_or_default();
1052                            }
1053                            __FieldTag::Unknown(key) => {
1054                                let value = map.next_value::<serde_json::Value>()?;
1055                                result._unknown_fields.insert(key, value);
1056                            }
1057                        }
1058                    }
1059                    std::result::Result::Ok(result)
1060                }
1061            }
1062            deserializer.deserialize_any(Visitor)
1063        }
1064    }
1065
1066    #[doc(hidden)]
1067    impl serde::ser::Serialize for FixableTotalByDigest {
1068        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1069        where
1070            S: serde::ser::Serializer,
1071        {
1072            use serde::ser::SerializeMap;
1073            #[allow(unused_imports)]
1074            use std::option::Option::Some;
1075            let mut state = serializer.serialize_map(std::option::Option::None)?;
1076            if !self.resource_uri.is_empty() {
1077                state.serialize_entry("resourceUri", &self.resource_uri)?;
1078            }
1079            if !wkt::internal::is_default(&self.severity) {
1080                state.serialize_entry("severity", &self.severity)?;
1081            }
1082            if !wkt::internal::is_default(&self.fixable_count) {
1083                struct __With<'a>(&'a i64);
1084                impl<'a> serde::ser::Serialize for __With<'a> {
1085                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1086                    where
1087                        S: serde::ser::Serializer,
1088                    {
1089                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1090                    }
1091                }
1092                state.serialize_entry("fixableCount", &__With(&self.fixable_count))?;
1093            }
1094            if !wkt::internal::is_default(&self.total_count) {
1095                struct __With<'a>(&'a i64);
1096                impl<'a> serde::ser::Serialize for __With<'a> {
1097                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1098                    where
1099                        S: serde::ser::Serializer,
1100                    {
1101                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1102                    }
1103                }
1104                state.serialize_entry("totalCount", &__With(&self.total_count))?;
1105            }
1106            if !self._unknown_fields.is_empty() {
1107                for (key, value) in self._unknown_fields.iter() {
1108                    state.serialize_entry(key, &value)?;
1109                }
1110            }
1111            state.end()
1112        }
1113    }
1114
1115    impl std::fmt::Debug for FixableTotalByDigest {
1116        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1117            let mut debug_struct = f.debug_struct("FixableTotalByDigest");
1118            debug_struct.field("resource_uri", &self.resource_uri);
1119            debug_struct.field("severity", &self.severity);
1120            debug_struct.field("fixable_count", &self.fixable_count);
1121            debug_struct.field("total_count", &self.total_count);
1122            if !self._unknown_fields.is_empty() {
1123                debug_struct.field("_unknown_fields", &self._unknown_fields);
1124            }
1125            debug_struct.finish()
1126        }
1127    }
1128}