google_cloud_api_servicecontrol_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 api;
21extern crate async_trait;
22extern crate bytes;
23extern crate gax;
24extern crate gaxi;
25extern crate lazy_static;
26extern crate logging_type;
27extern crate reqwest;
28extern crate rpc;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36/// Defines the errors to be returned in
37/// [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors].
38///
39/// [google.api.servicecontrol.v1.CheckResponse.check_errors]: crate::model::CheckResponse::check_errors
40#[derive(Clone, Default, PartialEq)]
41#[non_exhaustive]
42pub struct CheckError {
43    /// The error code.
44    pub code: crate::model::check_error::Code,
45
46    /// Subject to whom this error applies. See the specific code enum for more
47    /// details on this field. For example:
48    ///
49    /// - "project:\<project-id or project-number\>"
50    /// - "folder:\<folder-id\>"
51    /// - "organization:\<organization-id\>"
52    pub subject: std::string::String,
53
54    /// Free-form text providing details on the error cause of the error.
55    pub detail: std::string::String,
56
57    /// Contains public information about the check error. If available,
58    /// `status.code` will be non zero and client can propagate it out as public
59    /// error.
60    pub status: std::option::Option<rpc::model::Status>,
61
62    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
63}
64
65impl CheckError {
66    pub fn new() -> Self {
67        std::default::Default::default()
68    }
69
70    /// Sets the value of [code][crate::model::CheckError::code].
71    pub fn set_code<T: std::convert::Into<crate::model::check_error::Code>>(
72        mut self,
73        v: T,
74    ) -> Self {
75        self.code = v.into();
76        self
77    }
78
79    /// Sets the value of [subject][crate::model::CheckError::subject].
80    pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
81        self.subject = v.into();
82        self
83    }
84
85    /// Sets the value of [detail][crate::model::CheckError::detail].
86    pub fn set_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
87        self.detail = v.into();
88        self
89    }
90
91    /// Sets the value of [status][crate::model::CheckError::status].
92    pub fn set_status<T>(mut self, v: T) -> Self
93    where
94        T: std::convert::Into<rpc::model::Status>,
95    {
96        self.status = std::option::Option::Some(v.into());
97        self
98    }
99
100    /// Sets or clears the value of [status][crate::model::CheckError::status].
101    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
102    where
103        T: std::convert::Into<rpc::model::Status>,
104    {
105        self.status = v.map(|x| x.into());
106        self
107    }
108}
109
110impl wkt::message::Message for CheckError {
111    fn typename() -> &'static str {
112        "type.googleapis.com/google.api.servicecontrol.v1.CheckError"
113    }
114}
115
116#[doc(hidden)]
117impl<'de> serde::de::Deserialize<'de> for CheckError {
118    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
119    where
120        D: serde::Deserializer<'de>,
121    {
122        #[allow(non_camel_case_types)]
123        #[doc(hidden)]
124        #[derive(PartialEq, Eq, Hash)]
125        enum __FieldTag {
126            __code,
127            __subject,
128            __detail,
129            __status,
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 CheckError")
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                            "code" => Ok(__FieldTag::__code),
151                            "subject" => Ok(__FieldTag::__subject),
152                            "detail" => Ok(__FieldTag::__detail),
153                            "status" => Ok(__FieldTag::__status),
154                            _ => Ok(__FieldTag::Unknown(value.to_string())),
155                        }
156                    }
157                }
158                deserializer.deserialize_identifier(Visitor)
159            }
160        }
161        struct Visitor;
162        impl<'de> serde::de::Visitor<'de> for Visitor {
163            type Value = CheckError;
164            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
165                formatter.write_str("struct CheckError")
166            }
167            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
168            where
169                A: serde::de::MapAccess<'de>,
170            {
171                #[allow(unused_imports)]
172                use serde::de::Error;
173                use std::option::Option::Some;
174                let mut fields = std::collections::HashSet::new();
175                let mut result = Self::Value::new();
176                while let Some(tag) = map.next_key::<__FieldTag>()? {
177                    #[allow(clippy::match_single_binding)]
178                    match tag {
179                        __FieldTag::__code => {
180                            if !fields.insert(__FieldTag::__code) {
181                                return std::result::Result::Err(A::Error::duplicate_field(
182                                    "multiple values for code",
183                                ));
184                            }
185                            result.code = map
186                                .next_value::<std::option::Option<crate::model::check_error::Code>>(
187                                )?
188                                .unwrap_or_default();
189                        }
190                        __FieldTag::__subject => {
191                            if !fields.insert(__FieldTag::__subject) {
192                                return std::result::Result::Err(A::Error::duplicate_field(
193                                    "multiple values for subject",
194                                ));
195                            }
196                            result.subject = map
197                                .next_value::<std::option::Option<std::string::String>>()?
198                                .unwrap_or_default();
199                        }
200                        __FieldTag::__detail => {
201                            if !fields.insert(__FieldTag::__detail) {
202                                return std::result::Result::Err(A::Error::duplicate_field(
203                                    "multiple values for detail",
204                                ));
205                            }
206                            result.detail = map
207                                .next_value::<std::option::Option<std::string::String>>()?
208                                .unwrap_or_default();
209                        }
210                        __FieldTag::__status => {
211                            if !fields.insert(__FieldTag::__status) {
212                                return std::result::Result::Err(A::Error::duplicate_field(
213                                    "multiple values for status",
214                                ));
215                            }
216                            result.status =
217                                map.next_value::<std::option::Option<rpc::model::Status>>()?;
218                        }
219                        __FieldTag::Unknown(key) => {
220                            let value = map.next_value::<serde_json::Value>()?;
221                            result._unknown_fields.insert(key, value);
222                        }
223                    }
224                }
225                std::result::Result::Ok(result)
226            }
227        }
228        deserializer.deserialize_any(Visitor)
229    }
230}
231
232#[doc(hidden)]
233impl serde::ser::Serialize for CheckError {
234    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
235    where
236        S: serde::ser::Serializer,
237    {
238        use serde::ser::SerializeMap;
239        #[allow(unused_imports)]
240        use std::option::Option::Some;
241        let mut state = serializer.serialize_map(std::option::Option::None)?;
242        if !wkt::internal::is_default(&self.code) {
243            state.serialize_entry("code", &self.code)?;
244        }
245        if !self.subject.is_empty() {
246            state.serialize_entry("subject", &self.subject)?;
247        }
248        if !self.detail.is_empty() {
249            state.serialize_entry("detail", &self.detail)?;
250        }
251        if self.status.is_some() {
252            state.serialize_entry("status", &self.status)?;
253        }
254        if !self._unknown_fields.is_empty() {
255            for (key, value) in self._unknown_fields.iter() {
256                state.serialize_entry(key, &value)?;
257            }
258        }
259        state.end()
260    }
261}
262
263impl std::fmt::Debug for CheckError {
264    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
265        let mut debug_struct = f.debug_struct("CheckError");
266        debug_struct.field("code", &self.code);
267        debug_struct.field("subject", &self.subject);
268        debug_struct.field("detail", &self.detail);
269        debug_struct.field("status", &self.status);
270        if !self._unknown_fields.is_empty() {
271            debug_struct.field("_unknown_fields", &self._unknown_fields);
272        }
273        debug_struct.finish()
274    }
275}
276
277/// Defines additional types related to [CheckError].
278pub mod check_error {
279    #[allow(unused_imports)]
280    use super::*;
281
282    /// Error codes for Check responses.
283    ///
284    /// # Working with unknown values
285    ///
286    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
287    /// additional enum variants at any time. Adding new variants is not considered
288    /// a breaking change. Applications should write their code in anticipation of:
289    ///
290    /// - New values appearing in future releases of the client library, **and**
291    /// - New values received dynamically, without application changes.
292    ///
293    /// Please consult the [Working with enums] section in the user guide for some
294    /// guidelines.
295    ///
296    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
297    #[derive(Clone, Debug, PartialEq)]
298    #[non_exhaustive]
299    pub enum Code {
300        /// This is never used in `CheckResponse`.
301        ErrorCodeUnspecified,
302        /// The consumer's project id, network container, or resource container was
303        /// not found. Same as [google.rpc.Code.NOT_FOUND][google.rpc.Code.NOT_FOUND].
304        NotFound,
305        /// The consumer doesn't have access to the specified resource.
306        /// Same as [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
307        PermissionDenied,
308        /// Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
309        ResourceExhausted,
310        /// The consumer hasn't activated the service.
311        ServiceNotActivated,
312        /// The consumer cannot access the service because billing is disabled.
313        BillingDisabled,
314        /// The consumer's project has been marked as deleted (soft deletion).
315        ProjectDeleted,
316        /// The consumer's project number or id does not represent a valid project.
317        ProjectInvalid,
318        /// The input consumer info does not represent a valid consumer folder or
319        /// organization.
320        ConsumerInvalid,
321        /// The IP address of the consumer is invalid for the specific consumer
322        /// project.
323        IpAddressBlocked,
324        /// The referer address of the consumer request is invalid for the specific
325        /// consumer project.
326        RefererBlocked,
327        /// The client application of the consumer request is invalid for the
328        /// specific consumer project.
329        ClientAppBlocked,
330        /// The API targeted by this request is invalid for the specified consumer
331        /// project.
332        ApiTargetBlocked,
333        /// The consumer's API key is invalid.
334        ApiKeyInvalid,
335        /// The consumer's API Key has expired.
336        ApiKeyExpired,
337        /// The consumer's API Key was not found in config record.
338        ApiKeyNotFound,
339        /// The credential in the request can not be verified.
340        InvalidCredential,
341        /// The backend server for looking up project id/number is unavailable.
342        NamespaceLookupUnavailable,
343        /// The backend server for checking service status is unavailable.
344        ServiceStatusUnavailable,
345        /// The backend server for checking billing status is unavailable.
346        BillingStatusUnavailable,
347        /// Cloud Resource Manager backend server is unavailable.
348        CloudResourceManagerBackendUnavailable,
349        /// If set, the enum was initialized with an unknown value.
350        ///
351        /// Applications can examine the value using [Code::value] or
352        /// [Code::name].
353        UnknownValue(code::UnknownValue),
354    }
355
356    #[doc(hidden)]
357    pub mod code {
358        #[allow(unused_imports)]
359        use super::*;
360        #[derive(Clone, Debug, PartialEq)]
361        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
362    }
363
364    impl Code {
365        /// Gets the enum value.
366        ///
367        /// Returns `None` if the enum contains an unknown value deserialized from
368        /// the string representation of enums.
369        pub fn value(&self) -> std::option::Option<i32> {
370            match self {
371                Self::ErrorCodeUnspecified => std::option::Option::Some(0),
372                Self::NotFound => std::option::Option::Some(5),
373                Self::PermissionDenied => std::option::Option::Some(7),
374                Self::ResourceExhausted => std::option::Option::Some(8),
375                Self::ServiceNotActivated => std::option::Option::Some(104),
376                Self::BillingDisabled => std::option::Option::Some(107),
377                Self::ProjectDeleted => std::option::Option::Some(108),
378                Self::ProjectInvalid => std::option::Option::Some(114),
379                Self::ConsumerInvalid => std::option::Option::Some(125),
380                Self::IpAddressBlocked => std::option::Option::Some(109),
381                Self::RefererBlocked => std::option::Option::Some(110),
382                Self::ClientAppBlocked => std::option::Option::Some(111),
383                Self::ApiTargetBlocked => std::option::Option::Some(122),
384                Self::ApiKeyInvalid => std::option::Option::Some(105),
385                Self::ApiKeyExpired => std::option::Option::Some(112),
386                Self::ApiKeyNotFound => std::option::Option::Some(113),
387                Self::InvalidCredential => std::option::Option::Some(123),
388                Self::NamespaceLookupUnavailable => std::option::Option::Some(300),
389                Self::ServiceStatusUnavailable => std::option::Option::Some(301),
390                Self::BillingStatusUnavailable => std::option::Option::Some(302),
391                Self::CloudResourceManagerBackendUnavailable => std::option::Option::Some(305),
392                Self::UnknownValue(u) => u.0.value(),
393            }
394        }
395
396        /// Gets the enum value as a string.
397        ///
398        /// Returns `None` if the enum contains an unknown value deserialized from
399        /// the integer representation of enums.
400        pub fn name(&self) -> std::option::Option<&str> {
401            match self {
402                Self::ErrorCodeUnspecified => std::option::Option::Some("ERROR_CODE_UNSPECIFIED"),
403                Self::NotFound => std::option::Option::Some("NOT_FOUND"),
404                Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
405                Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
406                Self::ServiceNotActivated => std::option::Option::Some("SERVICE_NOT_ACTIVATED"),
407                Self::BillingDisabled => std::option::Option::Some("BILLING_DISABLED"),
408                Self::ProjectDeleted => std::option::Option::Some("PROJECT_DELETED"),
409                Self::ProjectInvalid => std::option::Option::Some("PROJECT_INVALID"),
410                Self::ConsumerInvalid => std::option::Option::Some("CONSUMER_INVALID"),
411                Self::IpAddressBlocked => std::option::Option::Some("IP_ADDRESS_BLOCKED"),
412                Self::RefererBlocked => std::option::Option::Some("REFERER_BLOCKED"),
413                Self::ClientAppBlocked => std::option::Option::Some("CLIENT_APP_BLOCKED"),
414                Self::ApiTargetBlocked => std::option::Option::Some("API_TARGET_BLOCKED"),
415                Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
416                Self::ApiKeyExpired => std::option::Option::Some("API_KEY_EXPIRED"),
417                Self::ApiKeyNotFound => std::option::Option::Some("API_KEY_NOT_FOUND"),
418                Self::InvalidCredential => std::option::Option::Some("INVALID_CREDENTIAL"),
419                Self::NamespaceLookupUnavailable => {
420                    std::option::Option::Some("NAMESPACE_LOOKUP_UNAVAILABLE")
421                }
422                Self::ServiceStatusUnavailable => {
423                    std::option::Option::Some("SERVICE_STATUS_UNAVAILABLE")
424                }
425                Self::BillingStatusUnavailable => {
426                    std::option::Option::Some("BILLING_STATUS_UNAVAILABLE")
427                }
428                Self::CloudResourceManagerBackendUnavailable => {
429                    std::option::Option::Some("CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE")
430                }
431                Self::UnknownValue(u) => u.0.name(),
432            }
433        }
434    }
435
436    impl std::default::Default for Code {
437        fn default() -> Self {
438            use std::convert::From;
439            Self::from(0)
440        }
441    }
442
443    impl std::fmt::Display for Code {
444        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
445            wkt::internal::display_enum(f, self.name(), self.value())
446        }
447    }
448
449    impl std::convert::From<i32> for Code {
450        fn from(value: i32) -> Self {
451            match value {
452                0 => Self::ErrorCodeUnspecified,
453                5 => Self::NotFound,
454                7 => Self::PermissionDenied,
455                8 => Self::ResourceExhausted,
456                104 => Self::ServiceNotActivated,
457                105 => Self::ApiKeyInvalid,
458                107 => Self::BillingDisabled,
459                108 => Self::ProjectDeleted,
460                109 => Self::IpAddressBlocked,
461                110 => Self::RefererBlocked,
462                111 => Self::ClientAppBlocked,
463                112 => Self::ApiKeyExpired,
464                113 => Self::ApiKeyNotFound,
465                114 => Self::ProjectInvalid,
466                122 => Self::ApiTargetBlocked,
467                123 => Self::InvalidCredential,
468                125 => Self::ConsumerInvalid,
469                300 => Self::NamespaceLookupUnavailable,
470                301 => Self::ServiceStatusUnavailable,
471                302 => Self::BillingStatusUnavailable,
472                305 => Self::CloudResourceManagerBackendUnavailable,
473                _ => Self::UnknownValue(code::UnknownValue(
474                    wkt::internal::UnknownEnumValue::Integer(value),
475                )),
476            }
477        }
478    }
479
480    impl std::convert::From<&str> for Code {
481        fn from(value: &str) -> Self {
482            use std::string::ToString;
483            match value {
484                "ERROR_CODE_UNSPECIFIED" => Self::ErrorCodeUnspecified,
485                "NOT_FOUND" => Self::NotFound,
486                "PERMISSION_DENIED" => Self::PermissionDenied,
487                "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
488                "SERVICE_NOT_ACTIVATED" => Self::ServiceNotActivated,
489                "BILLING_DISABLED" => Self::BillingDisabled,
490                "PROJECT_DELETED" => Self::ProjectDeleted,
491                "PROJECT_INVALID" => Self::ProjectInvalid,
492                "CONSUMER_INVALID" => Self::ConsumerInvalid,
493                "IP_ADDRESS_BLOCKED" => Self::IpAddressBlocked,
494                "REFERER_BLOCKED" => Self::RefererBlocked,
495                "CLIENT_APP_BLOCKED" => Self::ClientAppBlocked,
496                "API_TARGET_BLOCKED" => Self::ApiTargetBlocked,
497                "API_KEY_INVALID" => Self::ApiKeyInvalid,
498                "API_KEY_EXPIRED" => Self::ApiKeyExpired,
499                "API_KEY_NOT_FOUND" => Self::ApiKeyNotFound,
500                "INVALID_CREDENTIAL" => Self::InvalidCredential,
501                "NAMESPACE_LOOKUP_UNAVAILABLE" => Self::NamespaceLookupUnavailable,
502                "SERVICE_STATUS_UNAVAILABLE" => Self::ServiceStatusUnavailable,
503                "BILLING_STATUS_UNAVAILABLE" => Self::BillingStatusUnavailable,
504                "CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE" => {
505                    Self::CloudResourceManagerBackendUnavailable
506                }
507                _ => Self::UnknownValue(code::UnknownValue(
508                    wkt::internal::UnknownEnumValue::String(value.to_string()),
509                )),
510            }
511        }
512    }
513
514    impl serde::ser::Serialize for Code {
515        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
516        where
517            S: serde::Serializer,
518        {
519            match self {
520                Self::ErrorCodeUnspecified => serializer.serialize_i32(0),
521                Self::NotFound => serializer.serialize_i32(5),
522                Self::PermissionDenied => serializer.serialize_i32(7),
523                Self::ResourceExhausted => serializer.serialize_i32(8),
524                Self::ServiceNotActivated => serializer.serialize_i32(104),
525                Self::BillingDisabled => serializer.serialize_i32(107),
526                Self::ProjectDeleted => serializer.serialize_i32(108),
527                Self::ProjectInvalid => serializer.serialize_i32(114),
528                Self::ConsumerInvalid => serializer.serialize_i32(125),
529                Self::IpAddressBlocked => serializer.serialize_i32(109),
530                Self::RefererBlocked => serializer.serialize_i32(110),
531                Self::ClientAppBlocked => serializer.serialize_i32(111),
532                Self::ApiTargetBlocked => serializer.serialize_i32(122),
533                Self::ApiKeyInvalid => serializer.serialize_i32(105),
534                Self::ApiKeyExpired => serializer.serialize_i32(112),
535                Self::ApiKeyNotFound => serializer.serialize_i32(113),
536                Self::InvalidCredential => serializer.serialize_i32(123),
537                Self::NamespaceLookupUnavailable => serializer.serialize_i32(300),
538                Self::ServiceStatusUnavailable => serializer.serialize_i32(301),
539                Self::BillingStatusUnavailable => serializer.serialize_i32(302),
540                Self::CloudResourceManagerBackendUnavailable => serializer.serialize_i32(305),
541                Self::UnknownValue(u) => u.0.serialize(serializer),
542            }
543        }
544    }
545
546    impl<'de> serde::de::Deserialize<'de> for Code {
547        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
548        where
549            D: serde::Deserializer<'de>,
550        {
551            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
552                ".google.api.servicecontrol.v1.CheckError.Code",
553            ))
554        }
555    }
556}
557
558/// Distribution represents a frequency distribution of double-valued sample
559/// points. It contains the size of the population of sample points plus
560/// additional optional information:
561///
562/// * the arithmetic mean of the samples
563/// * the minimum and maximum of the samples
564/// * the sum-squared-deviation of the samples, used to compute variance
565/// * a histogram of the values of the sample points
566#[derive(Clone, Default, PartialEq)]
567#[non_exhaustive]
568pub struct Distribution {
569    /// The total number of samples in the distribution. Must be >= 0.
570    pub count: i64,
571
572    /// The arithmetic mean of the samples in the distribution. If `count` is
573    /// zero then this field must be zero.
574    pub mean: f64,
575
576    /// The minimum of the population of values. Ignored if `count` is zero.
577    pub minimum: f64,
578
579    /// The maximum of the population of values. Ignored if `count` is zero.
580    pub maximum: f64,
581
582    /// The sum of squared deviations from the mean:
583    /// Sum[i=1..count]((x_i - mean)^2)
584    /// where each x_i is a sample values. If `count` is zero then this field
585    /// must be zero, otherwise validation of the request fails.
586    pub sum_of_squared_deviation: f64,
587
588    /// The number of samples in each histogram bucket. `bucket_counts` are
589    /// optional. If present, they must sum to the `count` value.
590    ///
591    /// The buckets are defined below in `bucket_option`. There are N buckets.
592    /// `bucket_counts[0]` is the number of samples in the underflow bucket.
593    /// `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples
594    /// in each of the finite buckets. And `bucket_counts[N] is the number
595    /// of samples in the overflow bucket. See the comments of `bucket_option`
596    /// below for more details.
597    ///
598    /// Any suffix of trailing zeros may be omitted.
599    pub bucket_counts: std::vec::Vec<i64>,
600
601    /// Example points. Must be in increasing order of `value` field.
602    pub exemplars: std::vec::Vec<api::model::distribution::Exemplar>,
603
604    /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
605    /// must be both set, or both unset.
606    ///
607    /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
608    /// There must be at least two buckets (a single-bucket histogram gives
609    /// no information that isn't already provided by `count`).
610    ///
611    /// The first bucket is the underflow bucket which has a lower bound
612    /// of -inf. The last bucket is the overflow bucket which has an
613    /// upper bound of +inf. All other buckets (if any) are called "finite"
614    /// buckets because they have finite lower and upper bounds. As described
615    /// below, there are three ways to define the finite buckets.
616    ///
617    /// (1) Buckets with constant width.
618    /// (2) Buckets with exponentially growing widths.
619    /// (3) Buckets with arbitrary user-provided widths.
620    ///
621    /// In all cases, the buckets cover the entire real number line (-inf,
622    /// +inf). Bucket upper bounds are exclusive and lower bounds are
623    /// inclusive. The upper bound of the underflow bucket is equal to the
624    /// lower bound of the smallest finite bucket; the lower bound of the
625    /// overflow bucket is equal to the upper bound of the largest finite
626    /// bucket.
627    pub bucket_option: std::option::Option<crate::model::distribution::BucketOption>,
628
629    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
630}
631
632impl Distribution {
633    pub fn new() -> Self {
634        std::default::Default::default()
635    }
636
637    /// Sets the value of [count][crate::model::Distribution::count].
638    pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
639        self.count = v.into();
640        self
641    }
642
643    /// Sets the value of [mean][crate::model::Distribution::mean].
644    pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
645        self.mean = v.into();
646        self
647    }
648
649    /// Sets the value of [minimum][crate::model::Distribution::minimum].
650    pub fn set_minimum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
651        self.minimum = v.into();
652        self
653    }
654
655    /// Sets the value of [maximum][crate::model::Distribution::maximum].
656    pub fn set_maximum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
657        self.maximum = v.into();
658        self
659    }
660
661    /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
662    pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
663        self.sum_of_squared_deviation = v.into();
664        self
665    }
666
667    /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
668    pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
669    where
670        T: std::iter::IntoIterator<Item = V>,
671        V: std::convert::Into<i64>,
672    {
673        use std::iter::Iterator;
674        self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
675        self
676    }
677
678    /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
679    pub fn set_exemplars<T, V>(mut self, v: T) -> Self
680    where
681        T: std::iter::IntoIterator<Item = V>,
682        V: std::convert::Into<api::model::distribution::Exemplar>,
683    {
684        use std::iter::Iterator;
685        self.exemplars = v.into_iter().map(|i| i.into()).collect();
686        self
687    }
688
689    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option].
690    ///
691    /// Note that all the setters affecting `bucket_option` are mutually
692    /// exclusive.
693    pub fn set_bucket_option<
694        T: std::convert::Into<std::option::Option<crate::model::distribution::BucketOption>>,
695    >(
696        mut self,
697        v: T,
698    ) -> Self {
699        self.bucket_option = v.into();
700        self
701    }
702
703    /// The value of [bucket_option][crate::model::Distribution::bucket_option]
704    /// if it holds a `LinearBuckets`, `None` if the field is not set or
705    /// holds a different branch.
706    pub fn linear_buckets(
707        &self,
708    ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::LinearBuckets>> {
709        #[allow(unreachable_patterns)]
710        self.bucket_option.as_ref().and_then(|v| match v {
711            crate::model::distribution::BucketOption::LinearBuckets(v) => {
712                std::option::Option::Some(v)
713            }
714            _ => std::option::Option::None,
715        })
716    }
717
718    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
719    /// to hold a `LinearBuckets`.
720    ///
721    /// Note that all the setters affecting `bucket_option` are
722    /// mutually exclusive.
723    pub fn set_linear_buckets<
724        T: std::convert::Into<std::boxed::Box<crate::model::distribution::LinearBuckets>>,
725    >(
726        mut self,
727        v: T,
728    ) -> Self {
729        self.bucket_option = std::option::Option::Some(
730            crate::model::distribution::BucketOption::LinearBuckets(v.into()),
731        );
732        self
733    }
734
735    /// The value of [bucket_option][crate::model::Distribution::bucket_option]
736    /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
737    /// holds a different branch.
738    pub fn exponential_buckets(
739        &self,
740    ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExponentialBuckets>> {
741        #[allow(unreachable_patterns)]
742        self.bucket_option.as_ref().and_then(|v| match v {
743            crate::model::distribution::BucketOption::ExponentialBuckets(v) => {
744                std::option::Option::Some(v)
745            }
746            _ => std::option::Option::None,
747        })
748    }
749
750    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
751    /// to hold a `ExponentialBuckets`.
752    ///
753    /// Note that all the setters affecting `bucket_option` are
754    /// mutually exclusive.
755    pub fn set_exponential_buckets<
756        T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExponentialBuckets>>,
757    >(
758        mut self,
759        v: T,
760    ) -> Self {
761        self.bucket_option = std::option::Option::Some(
762            crate::model::distribution::BucketOption::ExponentialBuckets(v.into()),
763        );
764        self
765    }
766
767    /// The value of [bucket_option][crate::model::Distribution::bucket_option]
768    /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
769    /// holds a different branch.
770    pub fn explicit_buckets(
771        &self,
772    ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExplicitBuckets>> {
773        #[allow(unreachable_patterns)]
774        self.bucket_option.as_ref().and_then(|v| match v {
775            crate::model::distribution::BucketOption::ExplicitBuckets(v) => {
776                std::option::Option::Some(v)
777            }
778            _ => std::option::Option::None,
779        })
780    }
781
782    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
783    /// to hold a `ExplicitBuckets`.
784    ///
785    /// Note that all the setters affecting `bucket_option` are
786    /// mutually exclusive.
787    pub fn set_explicit_buckets<
788        T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExplicitBuckets>>,
789    >(
790        mut self,
791        v: T,
792    ) -> Self {
793        self.bucket_option = std::option::Option::Some(
794            crate::model::distribution::BucketOption::ExplicitBuckets(v.into()),
795        );
796        self
797    }
798}
799
800impl wkt::message::Message for Distribution {
801    fn typename() -> &'static str {
802        "type.googleapis.com/google.api.servicecontrol.v1.Distribution"
803    }
804}
805
806#[doc(hidden)]
807impl<'de> serde::de::Deserialize<'de> for Distribution {
808    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
809    where
810        D: serde::Deserializer<'de>,
811    {
812        #[allow(non_camel_case_types)]
813        #[doc(hidden)]
814        #[derive(PartialEq, Eq, Hash)]
815        enum __FieldTag {
816            __count,
817            __mean,
818            __minimum,
819            __maximum,
820            __sum_of_squared_deviation,
821            __bucket_counts,
822            __linear_buckets,
823            __exponential_buckets,
824            __explicit_buckets,
825            __exemplars,
826            Unknown(std::string::String),
827        }
828        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
829            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
830            where
831                D: serde::Deserializer<'de>,
832            {
833                struct Visitor;
834                impl<'de> serde::de::Visitor<'de> for Visitor {
835                    type Value = __FieldTag;
836                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
837                        formatter.write_str("a field name for Distribution")
838                    }
839                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
840                    where
841                        E: serde::de::Error,
842                    {
843                        use std::result::Result::Ok;
844                        use std::string::ToString;
845                        match value {
846                            "count" => Ok(__FieldTag::__count),
847                            "mean" => Ok(__FieldTag::__mean),
848                            "minimum" => Ok(__FieldTag::__minimum),
849                            "maximum" => Ok(__FieldTag::__maximum),
850                            "sumOfSquaredDeviation" => Ok(__FieldTag::__sum_of_squared_deviation),
851                            "sum_of_squared_deviation" => {
852                                Ok(__FieldTag::__sum_of_squared_deviation)
853                            }
854                            "bucketCounts" => Ok(__FieldTag::__bucket_counts),
855                            "bucket_counts" => Ok(__FieldTag::__bucket_counts),
856                            "linearBuckets" => Ok(__FieldTag::__linear_buckets),
857                            "linear_buckets" => Ok(__FieldTag::__linear_buckets),
858                            "exponentialBuckets" => Ok(__FieldTag::__exponential_buckets),
859                            "exponential_buckets" => Ok(__FieldTag::__exponential_buckets),
860                            "explicitBuckets" => Ok(__FieldTag::__explicit_buckets),
861                            "explicit_buckets" => Ok(__FieldTag::__explicit_buckets),
862                            "exemplars" => Ok(__FieldTag::__exemplars),
863                            _ => Ok(__FieldTag::Unknown(value.to_string())),
864                        }
865                    }
866                }
867                deserializer.deserialize_identifier(Visitor)
868            }
869        }
870        struct Visitor;
871        impl<'de> serde::de::Visitor<'de> for Visitor {
872            type Value = Distribution;
873            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
874                formatter.write_str("struct Distribution")
875            }
876            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
877            where
878                A: serde::de::MapAccess<'de>,
879            {
880                #[allow(unused_imports)]
881                use serde::de::Error;
882                use std::option::Option::Some;
883                let mut fields = std::collections::HashSet::new();
884                let mut result = Self::Value::new();
885                while let Some(tag) = map.next_key::<__FieldTag>()? {
886                    #[allow(clippy::match_single_binding)]
887                    match tag {
888                        __FieldTag::__count => {
889                            if !fields.insert(__FieldTag::__count) {
890                                return std::result::Result::Err(A::Error::duplicate_field(
891                                    "multiple values for count",
892                                ));
893                            }
894                            struct __With(std::option::Option<i64>);
895                            impl<'de> serde::de::Deserialize<'de> for __With {
896                                fn deserialize<D>(
897                                    deserializer: D,
898                                ) -> std::result::Result<Self, D::Error>
899                                where
900                                    D: serde::de::Deserializer<'de>,
901                                {
902                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
903                                }
904                            }
905                            result.count = map.next_value::<__With>()?.0.unwrap_or_default();
906                        }
907                        __FieldTag::__mean => {
908                            if !fields.insert(__FieldTag::__mean) {
909                                return std::result::Result::Err(A::Error::duplicate_field(
910                                    "multiple values for mean",
911                                ));
912                            }
913                            struct __With(std::option::Option<f64>);
914                            impl<'de> serde::de::Deserialize<'de> for __With {
915                                fn deserialize<D>(
916                                    deserializer: D,
917                                ) -> std::result::Result<Self, D::Error>
918                                where
919                                    D: serde::de::Deserializer<'de>,
920                                {
921                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
922                                }
923                            }
924                            result.mean = map.next_value::<__With>()?.0.unwrap_or_default();
925                        }
926                        __FieldTag::__minimum => {
927                            if !fields.insert(__FieldTag::__minimum) {
928                                return std::result::Result::Err(A::Error::duplicate_field(
929                                    "multiple values for minimum",
930                                ));
931                            }
932                            struct __With(std::option::Option<f64>);
933                            impl<'de> serde::de::Deserialize<'de> for __With {
934                                fn deserialize<D>(
935                                    deserializer: D,
936                                ) -> std::result::Result<Self, D::Error>
937                                where
938                                    D: serde::de::Deserializer<'de>,
939                                {
940                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
941                                }
942                            }
943                            result.minimum = map.next_value::<__With>()?.0.unwrap_or_default();
944                        }
945                        __FieldTag::__maximum => {
946                            if !fields.insert(__FieldTag::__maximum) {
947                                return std::result::Result::Err(A::Error::duplicate_field(
948                                    "multiple values for maximum",
949                                ));
950                            }
951                            struct __With(std::option::Option<f64>);
952                            impl<'de> serde::de::Deserialize<'de> for __With {
953                                fn deserialize<D>(
954                                    deserializer: D,
955                                ) -> std::result::Result<Self, D::Error>
956                                where
957                                    D: serde::de::Deserializer<'de>,
958                                {
959                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
960                                }
961                            }
962                            result.maximum = map.next_value::<__With>()?.0.unwrap_or_default();
963                        }
964                        __FieldTag::__sum_of_squared_deviation => {
965                            if !fields.insert(__FieldTag::__sum_of_squared_deviation) {
966                                return std::result::Result::Err(A::Error::duplicate_field(
967                                    "multiple values for sum_of_squared_deviation",
968                                ));
969                            }
970                            struct __With(std::option::Option<f64>);
971                            impl<'de> serde::de::Deserialize<'de> for __With {
972                                fn deserialize<D>(
973                                    deserializer: D,
974                                ) -> std::result::Result<Self, D::Error>
975                                where
976                                    D: serde::de::Deserializer<'de>,
977                                {
978                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
979                                }
980                            }
981                            result.sum_of_squared_deviation =
982                                map.next_value::<__With>()?.0.unwrap_or_default();
983                        }
984                        __FieldTag::__bucket_counts => {
985                            if !fields.insert(__FieldTag::__bucket_counts) {
986                                return std::result::Result::Err(A::Error::duplicate_field(
987                                    "multiple values for bucket_counts",
988                                ));
989                            }
990                            struct __With(std::option::Option<std::vec::Vec<i64>>);
991                            impl<'de> serde::de::Deserialize<'de> for __With {
992                                fn deserialize<D>(
993                                    deserializer: D,
994                                ) -> std::result::Result<Self, D::Error>
995                                where
996                                    D: serde::de::Deserializer<'de>,
997                                {
998                                    serde_with::As::<
999                                        std::option::Option<std::vec::Vec<wkt::internal::I64>>,
1000                                    >::deserialize(deserializer)
1001                                    .map(__With)
1002                                }
1003                            }
1004                            result.bucket_counts =
1005                                map.next_value::<__With>()?.0.unwrap_or_default();
1006                        }
1007                        __FieldTag::__linear_buckets => {
1008                            if !fields.insert(__FieldTag::__linear_buckets) {
1009                                return std::result::Result::Err(A::Error::duplicate_field(
1010                                    "multiple values for linear_buckets",
1011                                ));
1012                            }
1013                            if result.bucket_option.is_some() {
1014                                return std::result::Result::Err(A::Error::duplicate_field(
1015                                    "multiple values for `bucket_option`, a oneof with full ID .google.api.servicecontrol.v1.Distribution.linear_buckets, latest field was linearBuckets",
1016                                ));
1017                            }
1018                            result.bucket_option = std::option::Option::Some(
1019                                crate::model::distribution::BucketOption::LinearBuckets(
1020                                    map.next_value::<std::option::Option<
1021                                        std::boxed::Box<crate::model::distribution::LinearBuckets>,
1022                                    >>()?
1023                                    .unwrap_or_default(),
1024                                ),
1025                            );
1026                        }
1027                        __FieldTag::__exponential_buckets => {
1028                            if !fields.insert(__FieldTag::__exponential_buckets) {
1029                                return std::result::Result::Err(A::Error::duplicate_field(
1030                                    "multiple values for exponential_buckets",
1031                                ));
1032                            }
1033                            if result.bucket_option.is_some() {
1034                                return std::result::Result::Err(A::Error::duplicate_field(
1035                                    "multiple values for `bucket_option`, a oneof with full ID .google.api.servicecontrol.v1.Distribution.exponential_buckets, latest field was exponentialBuckets",
1036                                ));
1037                            }
1038                            result.bucket_option = std::option::Option::Some(
1039                                crate::model::distribution::BucketOption::ExponentialBuckets(
1040                                    map.next_value::<std::option::Option<
1041                                        std::boxed::Box<
1042                                            crate::model::distribution::ExponentialBuckets,
1043                                        >,
1044                                    >>()?
1045                                    .unwrap_or_default(),
1046                                ),
1047                            );
1048                        }
1049                        __FieldTag::__explicit_buckets => {
1050                            if !fields.insert(__FieldTag::__explicit_buckets) {
1051                                return std::result::Result::Err(A::Error::duplicate_field(
1052                                    "multiple values for explicit_buckets",
1053                                ));
1054                            }
1055                            if result.bucket_option.is_some() {
1056                                return std::result::Result::Err(A::Error::duplicate_field(
1057                                    "multiple values for `bucket_option`, a oneof with full ID .google.api.servicecontrol.v1.Distribution.explicit_buckets, latest field was explicitBuckets",
1058                                ));
1059                            }
1060                            result.bucket_option = std::option::Option::Some(
1061                                crate::model::distribution::BucketOption::ExplicitBuckets(
1062                                    map.next_value::<std::option::Option<
1063                                        std::boxed::Box<
1064                                            crate::model::distribution::ExplicitBuckets,
1065                                        >,
1066                                    >>()?
1067                                    .unwrap_or_default(),
1068                                ),
1069                            );
1070                        }
1071                        __FieldTag::__exemplars => {
1072                            if !fields.insert(__FieldTag::__exemplars) {
1073                                return std::result::Result::Err(A::Error::duplicate_field(
1074                                    "multiple values for exemplars",
1075                                ));
1076                            }
1077                            result.exemplars = map
1078                                .next_value::<std::option::Option<
1079                                    std::vec::Vec<api::model::distribution::Exemplar>,
1080                                >>()?
1081                                .unwrap_or_default();
1082                        }
1083                        __FieldTag::Unknown(key) => {
1084                            let value = map.next_value::<serde_json::Value>()?;
1085                            result._unknown_fields.insert(key, value);
1086                        }
1087                    }
1088                }
1089                std::result::Result::Ok(result)
1090            }
1091        }
1092        deserializer.deserialize_any(Visitor)
1093    }
1094}
1095
1096#[doc(hidden)]
1097impl serde::ser::Serialize for Distribution {
1098    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1099    where
1100        S: serde::ser::Serializer,
1101    {
1102        use serde::ser::SerializeMap;
1103        #[allow(unused_imports)]
1104        use std::option::Option::Some;
1105        let mut state = serializer.serialize_map(std::option::Option::None)?;
1106        if !wkt::internal::is_default(&self.count) {
1107            struct __With<'a>(&'a i64);
1108            impl<'a> serde::ser::Serialize for __With<'a> {
1109                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1110                where
1111                    S: serde::ser::Serializer,
1112                {
1113                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1114                }
1115            }
1116            state.serialize_entry("count", &__With(&self.count))?;
1117        }
1118        if !wkt::internal::is_default(&self.mean) {
1119            struct __With<'a>(&'a f64);
1120            impl<'a> serde::ser::Serialize for __With<'a> {
1121                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1122                where
1123                    S: serde::ser::Serializer,
1124                {
1125                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1126                }
1127            }
1128            state.serialize_entry("mean", &__With(&self.mean))?;
1129        }
1130        if !wkt::internal::is_default(&self.minimum) {
1131            struct __With<'a>(&'a f64);
1132            impl<'a> serde::ser::Serialize for __With<'a> {
1133                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1134                where
1135                    S: serde::ser::Serializer,
1136                {
1137                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1138                }
1139            }
1140            state.serialize_entry("minimum", &__With(&self.minimum))?;
1141        }
1142        if !wkt::internal::is_default(&self.maximum) {
1143            struct __With<'a>(&'a f64);
1144            impl<'a> serde::ser::Serialize for __With<'a> {
1145                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1146                where
1147                    S: serde::ser::Serializer,
1148                {
1149                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1150                }
1151            }
1152            state.serialize_entry("maximum", &__With(&self.maximum))?;
1153        }
1154        if !wkt::internal::is_default(&self.sum_of_squared_deviation) {
1155            struct __With<'a>(&'a f64);
1156            impl<'a> serde::ser::Serialize for __With<'a> {
1157                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1158                where
1159                    S: serde::ser::Serializer,
1160                {
1161                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1162                }
1163            }
1164            state.serialize_entry(
1165                "sumOfSquaredDeviation",
1166                &__With(&self.sum_of_squared_deviation),
1167            )?;
1168        }
1169        if !self.bucket_counts.is_empty() {
1170            struct __With<'a>(&'a std::vec::Vec<i64>);
1171            impl<'a> serde::ser::Serialize for __With<'a> {
1172                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1173                where
1174                    S: serde::ser::Serializer,
1175                {
1176                    serde_with::As::<std::vec::Vec<wkt::internal::I64>>::serialize(
1177                        self.0, serializer,
1178                    )
1179                }
1180            }
1181            state.serialize_entry("bucketCounts", &__With(&self.bucket_counts))?;
1182        }
1183        if let Some(value) = self.linear_buckets() {
1184            state.serialize_entry("linearBuckets", value)?;
1185        }
1186        if let Some(value) = self.exponential_buckets() {
1187            state.serialize_entry("exponentialBuckets", value)?;
1188        }
1189        if let Some(value) = self.explicit_buckets() {
1190            state.serialize_entry("explicitBuckets", value)?;
1191        }
1192        if !self.exemplars.is_empty() {
1193            state.serialize_entry("exemplars", &self.exemplars)?;
1194        }
1195        if !self._unknown_fields.is_empty() {
1196            for (key, value) in self._unknown_fields.iter() {
1197                state.serialize_entry(key, &value)?;
1198            }
1199        }
1200        state.end()
1201    }
1202}
1203
1204impl std::fmt::Debug for Distribution {
1205    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1206        let mut debug_struct = f.debug_struct("Distribution");
1207        debug_struct.field("count", &self.count);
1208        debug_struct.field("mean", &self.mean);
1209        debug_struct.field("minimum", &self.minimum);
1210        debug_struct.field("maximum", &self.maximum);
1211        debug_struct.field("sum_of_squared_deviation", &self.sum_of_squared_deviation);
1212        debug_struct.field("bucket_counts", &self.bucket_counts);
1213        debug_struct.field("exemplars", &self.exemplars);
1214        debug_struct.field("bucket_option", &self.bucket_option);
1215        if !self._unknown_fields.is_empty() {
1216            debug_struct.field("_unknown_fields", &self._unknown_fields);
1217        }
1218        debug_struct.finish()
1219    }
1220}
1221
1222/// Defines additional types related to [Distribution].
1223pub mod distribution {
1224    #[allow(unused_imports)]
1225    use super::*;
1226
1227    /// Describing buckets with constant width.
1228    #[derive(Clone, Default, PartialEq)]
1229    #[non_exhaustive]
1230    pub struct LinearBuckets {
1231        /// The number of finite buckets. With the underflow and overflow buckets,
1232        /// the total number of buckets is `num_finite_buckets` + 2.
1233        /// See comments on `bucket_options` for details.
1234        pub num_finite_buckets: i32,
1235
1236        /// The i'th linear bucket covers the interval
1237        /// [offset + (i-1) * width, offset + i * width)
1238        /// where i ranges from 1 to num_finite_buckets, inclusive.
1239        /// Must be strictly positive.
1240        pub width: f64,
1241
1242        /// The i'th linear bucket covers the interval
1243        /// [offset + (i-1) * width, offset + i * width)
1244        /// where i ranges from 1 to num_finite_buckets, inclusive.
1245        pub offset: f64,
1246
1247        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1248    }
1249
1250    impl LinearBuckets {
1251        pub fn new() -> Self {
1252            std::default::Default::default()
1253        }
1254
1255        /// Sets the value of [num_finite_buckets][crate::model::distribution::LinearBuckets::num_finite_buckets].
1256        pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1257            self.num_finite_buckets = v.into();
1258            self
1259        }
1260
1261        /// Sets the value of [width][crate::model::distribution::LinearBuckets::width].
1262        pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1263            self.width = v.into();
1264            self
1265        }
1266
1267        /// Sets the value of [offset][crate::model::distribution::LinearBuckets::offset].
1268        pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1269            self.offset = v.into();
1270            self
1271        }
1272    }
1273
1274    impl wkt::message::Message for LinearBuckets {
1275        fn typename() -> &'static str {
1276            "type.googleapis.com/google.api.servicecontrol.v1.Distribution.LinearBuckets"
1277        }
1278    }
1279
1280    #[doc(hidden)]
1281    impl<'de> serde::de::Deserialize<'de> for LinearBuckets {
1282        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1283        where
1284            D: serde::Deserializer<'de>,
1285        {
1286            #[allow(non_camel_case_types)]
1287            #[doc(hidden)]
1288            #[derive(PartialEq, Eq, Hash)]
1289            enum __FieldTag {
1290                __num_finite_buckets,
1291                __width,
1292                __offset,
1293                Unknown(std::string::String),
1294            }
1295            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1296                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1297                where
1298                    D: serde::Deserializer<'de>,
1299                {
1300                    struct Visitor;
1301                    impl<'de> serde::de::Visitor<'de> for Visitor {
1302                        type Value = __FieldTag;
1303                        fn expecting(
1304                            &self,
1305                            formatter: &mut std::fmt::Formatter,
1306                        ) -> std::fmt::Result {
1307                            formatter.write_str("a field name for LinearBuckets")
1308                        }
1309                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1310                        where
1311                            E: serde::de::Error,
1312                        {
1313                            use std::result::Result::Ok;
1314                            use std::string::ToString;
1315                            match value {
1316                                "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
1317                                "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
1318                                "width" => Ok(__FieldTag::__width),
1319                                "offset" => Ok(__FieldTag::__offset),
1320                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1321                            }
1322                        }
1323                    }
1324                    deserializer.deserialize_identifier(Visitor)
1325                }
1326            }
1327            struct Visitor;
1328            impl<'de> serde::de::Visitor<'de> for Visitor {
1329                type Value = LinearBuckets;
1330                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1331                    formatter.write_str("struct LinearBuckets")
1332                }
1333                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1334                where
1335                    A: serde::de::MapAccess<'de>,
1336                {
1337                    #[allow(unused_imports)]
1338                    use serde::de::Error;
1339                    use std::option::Option::Some;
1340                    let mut fields = std::collections::HashSet::new();
1341                    let mut result = Self::Value::new();
1342                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1343                        #[allow(clippy::match_single_binding)]
1344                        match tag {
1345                            __FieldTag::__num_finite_buckets => {
1346                                if !fields.insert(__FieldTag::__num_finite_buckets) {
1347                                    return std::result::Result::Err(A::Error::duplicate_field(
1348                                        "multiple values for num_finite_buckets",
1349                                    ));
1350                                }
1351                                struct __With(std::option::Option<i32>);
1352                                impl<'de> serde::de::Deserialize<'de> for __With {
1353                                    fn deserialize<D>(
1354                                        deserializer: D,
1355                                    ) -> std::result::Result<Self, D::Error>
1356                                    where
1357                                        D: serde::de::Deserializer<'de>,
1358                                    {
1359                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1360                                    }
1361                                }
1362                                result.num_finite_buckets =
1363                                    map.next_value::<__With>()?.0.unwrap_or_default();
1364                            }
1365                            __FieldTag::__width => {
1366                                if !fields.insert(__FieldTag::__width) {
1367                                    return std::result::Result::Err(A::Error::duplicate_field(
1368                                        "multiple values for width",
1369                                    ));
1370                                }
1371                                struct __With(std::option::Option<f64>);
1372                                impl<'de> serde::de::Deserialize<'de> for __With {
1373                                    fn deserialize<D>(
1374                                        deserializer: D,
1375                                    ) -> std::result::Result<Self, D::Error>
1376                                    where
1377                                        D: serde::de::Deserializer<'de>,
1378                                    {
1379                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1380                                    }
1381                                }
1382                                result.width = map.next_value::<__With>()?.0.unwrap_or_default();
1383                            }
1384                            __FieldTag::__offset => {
1385                                if !fields.insert(__FieldTag::__offset) {
1386                                    return std::result::Result::Err(A::Error::duplicate_field(
1387                                        "multiple values for offset",
1388                                    ));
1389                                }
1390                                struct __With(std::option::Option<f64>);
1391                                impl<'de> serde::de::Deserialize<'de> for __With {
1392                                    fn deserialize<D>(
1393                                        deserializer: D,
1394                                    ) -> std::result::Result<Self, D::Error>
1395                                    where
1396                                        D: serde::de::Deserializer<'de>,
1397                                    {
1398                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1399                                    }
1400                                }
1401                                result.offset = map.next_value::<__With>()?.0.unwrap_or_default();
1402                            }
1403                            __FieldTag::Unknown(key) => {
1404                                let value = map.next_value::<serde_json::Value>()?;
1405                                result._unknown_fields.insert(key, value);
1406                            }
1407                        }
1408                    }
1409                    std::result::Result::Ok(result)
1410                }
1411            }
1412            deserializer.deserialize_any(Visitor)
1413        }
1414    }
1415
1416    #[doc(hidden)]
1417    impl serde::ser::Serialize for LinearBuckets {
1418        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1419        where
1420            S: serde::ser::Serializer,
1421        {
1422            use serde::ser::SerializeMap;
1423            #[allow(unused_imports)]
1424            use std::option::Option::Some;
1425            let mut state = serializer.serialize_map(std::option::Option::None)?;
1426            if !wkt::internal::is_default(&self.num_finite_buckets) {
1427                struct __With<'a>(&'a i32);
1428                impl<'a> serde::ser::Serialize for __With<'a> {
1429                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1430                    where
1431                        S: serde::ser::Serializer,
1432                    {
1433                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1434                    }
1435                }
1436                state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
1437            }
1438            if !wkt::internal::is_default(&self.width) {
1439                struct __With<'a>(&'a f64);
1440                impl<'a> serde::ser::Serialize for __With<'a> {
1441                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1442                    where
1443                        S: serde::ser::Serializer,
1444                    {
1445                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1446                    }
1447                }
1448                state.serialize_entry("width", &__With(&self.width))?;
1449            }
1450            if !wkt::internal::is_default(&self.offset) {
1451                struct __With<'a>(&'a f64);
1452                impl<'a> serde::ser::Serialize for __With<'a> {
1453                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1454                    where
1455                        S: serde::ser::Serializer,
1456                    {
1457                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1458                    }
1459                }
1460                state.serialize_entry("offset", &__With(&self.offset))?;
1461            }
1462            if !self._unknown_fields.is_empty() {
1463                for (key, value) in self._unknown_fields.iter() {
1464                    state.serialize_entry(key, &value)?;
1465                }
1466            }
1467            state.end()
1468        }
1469    }
1470
1471    impl std::fmt::Debug for LinearBuckets {
1472        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1473            let mut debug_struct = f.debug_struct("LinearBuckets");
1474            debug_struct.field("num_finite_buckets", &self.num_finite_buckets);
1475            debug_struct.field("width", &self.width);
1476            debug_struct.field("offset", &self.offset);
1477            if !self._unknown_fields.is_empty() {
1478                debug_struct.field("_unknown_fields", &self._unknown_fields);
1479            }
1480            debug_struct.finish()
1481        }
1482    }
1483
1484    /// Describing buckets with exponentially growing width.
1485    #[derive(Clone, Default, PartialEq)]
1486    #[non_exhaustive]
1487    pub struct ExponentialBuckets {
1488        /// The number of finite buckets. With the underflow and overflow buckets,
1489        /// the total number of buckets is `num_finite_buckets` + 2.
1490        /// See comments on `bucket_options` for details.
1491        pub num_finite_buckets: i32,
1492
1493        /// The i'th exponential bucket covers the interval
1494        /// [scale * growth_factor^(i-1), scale * growth_factor^i)
1495        /// where i ranges from 1 to num_finite_buckets inclusive.
1496        /// Must be larger than 1.0.
1497        pub growth_factor: f64,
1498
1499        /// The i'th exponential bucket covers the interval
1500        /// [scale * growth_factor^(i-1), scale * growth_factor^i)
1501        /// where i ranges from 1 to num_finite_buckets inclusive.
1502        /// Must be > 0.
1503        pub scale: f64,
1504
1505        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1506    }
1507
1508    impl ExponentialBuckets {
1509        pub fn new() -> Self {
1510            std::default::Default::default()
1511        }
1512
1513        /// Sets the value of [num_finite_buckets][crate::model::distribution::ExponentialBuckets::num_finite_buckets].
1514        pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1515            self.num_finite_buckets = v.into();
1516            self
1517        }
1518
1519        /// Sets the value of [growth_factor][crate::model::distribution::ExponentialBuckets::growth_factor].
1520        pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1521            self.growth_factor = v.into();
1522            self
1523        }
1524
1525        /// Sets the value of [scale][crate::model::distribution::ExponentialBuckets::scale].
1526        pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1527            self.scale = v.into();
1528            self
1529        }
1530    }
1531
1532    impl wkt::message::Message for ExponentialBuckets {
1533        fn typename() -> &'static str {
1534            "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExponentialBuckets"
1535        }
1536    }
1537
1538    #[doc(hidden)]
1539    impl<'de> serde::de::Deserialize<'de> for ExponentialBuckets {
1540        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1541        where
1542            D: serde::Deserializer<'de>,
1543        {
1544            #[allow(non_camel_case_types)]
1545            #[doc(hidden)]
1546            #[derive(PartialEq, Eq, Hash)]
1547            enum __FieldTag {
1548                __num_finite_buckets,
1549                __growth_factor,
1550                __scale,
1551                Unknown(std::string::String),
1552            }
1553            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1554                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1555                where
1556                    D: serde::Deserializer<'de>,
1557                {
1558                    struct Visitor;
1559                    impl<'de> serde::de::Visitor<'de> for Visitor {
1560                        type Value = __FieldTag;
1561                        fn expecting(
1562                            &self,
1563                            formatter: &mut std::fmt::Formatter,
1564                        ) -> std::fmt::Result {
1565                            formatter.write_str("a field name for ExponentialBuckets")
1566                        }
1567                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1568                        where
1569                            E: serde::de::Error,
1570                        {
1571                            use std::result::Result::Ok;
1572                            use std::string::ToString;
1573                            match value {
1574                                "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
1575                                "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
1576                                "growthFactor" => Ok(__FieldTag::__growth_factor),
1577                                "growth_factor" => Ok(__FieldTag::__growth_factor),
1578                                "scale" => Ok(__FieldTag::__scale),
1579                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1580                            }
1581                        }
1582                    }
1583                    deserializer.deserialize_identifier(Visitor)
1584                }
1585            }
1586            struct Visitor;
1587            impl<'de> serde::de::Visitor<'de> for Visitor {
1588                type Value = ExponentialBuckets;
1589                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1590                    formatter.write_str("struct ExponentialBuckets")
1591                }
1592                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1593                where
1594                    A: serde::de::MapAccess<'de>,
1595                {
1596                    #[allow(unused_imports)]
1597                    use serde::de::Error;
1598                    use std::option::Option::Some;
1599                    let mut fields = std::collections::HashSet::new();
1600                    let mut result = Self::Value::new();
1601                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1602                        #[allow(clippy::match_single_binding)]
1603                        match tag {
1604                            __FieldTag::__num_finite_buckets => {
1605                                if !fields.insert(__FieldTag::__num_finite_buckets) {
1606                                    return std::result::Result::Err(A::Error::duplicate_field(
1607                                        "multiple values for num_finite_buckets",
1608                                    ));
1609                                }
1610                                struct __With(std::option::Option<i32>);
1611                                impl<'de> serde::de::Deserialize<'de> for __With {
1612                                    fn deserialize<D>(
1613                                        deserializer: D,
1614                                    ) -> std::result::Result<Self, D::Error>
1615                                    where
1616                                        D: serde::de::Deserializer<'de>,
1617                                    {
1618                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1619                                    }
1620                                }
1621                                result.num_finite_buckets =
1622                                    map.next_value::<__With>()?.0.unwrap_or_default();
1623                            }
1624                            __FieldTag::__growth_factor => {
1625                                if !fields.insert(__FieldTag::__growth_factor) {
1626                                    return std::result::Result::Err(A::Error::duplicate_field(
1627                                        "multiple values for growth_factor",
1628                                    ));
1629                                }
1630                                struct __With(std::option::Option<f64>);
1631                                impl<'de> serde::de::Deserialize<'de> for __With {
1632                                    fn deserialize<D>(
1633                                        deserializer: D,
1634                                    ) -> std::result::Result<Self, D::Error>
1635                                    where
1636                                        D: serde::de::Deserializer<'de>,
1637                                    {
1638                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1639                                    }
1640                                }
1641                                result.growth_factor =
1642                                    map.next_value::<__With>()?.0.unwrap_or_default();
1643                            }
1644                            __FieldTag::__scale => {
1645                                if !fields.insert(__FieldTag::__scale) {
1646                                    return std::result::Result::Err(A::Error::duplicate_field(
1647                                        "multiple values for scale",
1648                                    ));
1649                                }
1650                                struct __With(std::option::Option<f64>);
1651                                impl<'de> serde::de::Deserialize<'de> for __With {
1652                                    fn deserialize<D>(
1653                                        deserializer: D,
1654                                    ) -> std::result::Result<Self, D::Error>
1655                                    where
1656                                        D: serde::de::Deserializer<'de>,
1657                                    {
1658                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1659                                    }
1660                                }
1661                                result.scale = map.next_value::<__With>()?.0.unwrap_or_default();
1662                            }
1663                            __FieldTag::Unknown(key) => {
1664                                let value = map.next_value::<serde_json::Value>()?;
1665                                result._unknown_fields.insert(key, value);
1666                            }
1667                        }
1668                    }
1669                    std::result::Result::Ok(result)
1670                }
1671            }
1672            deserializer.deserialize_any(Visitor)
1673        }
1674    }
1675
1676    #[doc(hidden)]
1677    impl serde::ser::Serialize for ExponentialBuckets {
1678        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1679        where
1680            S: serde::ser::Serializer,
1681        {
1682            use serde::ser::SerializeMap;
1683            #[allow(unused_imports)]
1684            use std::option::Option::Some;
1685            let mut state = serializer.serialize_map(std::option::Option::None)?;
1686            if !wkt::internal::is_default(&self.num_finite_buckets) {
1687                struct __With<'a>(&'a i32);
1688                impl<'a> serde::ser::Serialize for __With<'a> {
1689                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1690                    where
1691                        S: serde::ser::Serializer,
1692                    {
1693                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1694                    }
1695                }
1696                state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
1697            }
1698            if !wkt::internal::is_default(&self.growth_factor) {
1699                struct __With<'a>(&'a f64);
1700                impl<'a> serde::ser::Serialize for __With<'a> {
1701                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1702                    where
1703                        S: serde::ser::Serializer,
1704                    {
1705                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1706                    }
1707                }
1708                state.serialize_entry("growthFactor", &__With(&self.growth_factor))?;
1709            }
1710            if !wkt::internal::is_default(&self.scale) {
1711                struct __With<'a>(&'a f64);
1712                impl<'a> serde::ser::Serialize for __With<'a> {
1713                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1714                    where
1715                        S: serde::ser::Serializer,
1716                    {
1717                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1718                    }
1719                }
1720                state.serialize_entry("scale", &__With(&self.scale))?;
1721            }
1722            if !self._unknown_fields.is_empty() {
1723                for (key, value) in self._unknown_fields.iter() {
1724                    state.serialize_entry(key, &value)?;
1725                }
1726            }
1727            state.end()
1728        }
1729    }
1730
1731    impl std::fmt::Debug for ExponentialBuckets {
1732        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1733            let mut debug_struct = f.debug_struct("ExponentialBuckets");
1734            debug_struct.field("num_finite_buckets", &self.num_finite_buckets);
1735            debug_struct.field("growth_factor", &self.growth_factor);
1736            debug_struct.field("scale", &self.scale);
1737            if !self._unknown_fields.is_empty() {
1738                debug_struct.field("_unknown_fields", &self._unknown_fields);
1739            }
1740            debug_struct.finish()
1741        }
1742    }
1743
1744    /// Describing buckets with arbitrary user-provided width.
1745    #[derive(Clone, Default, PartialEq)]
1746    #[non_exhaustive]
1747    pub struct ExplicitBuckets {
1748        /// 'bound' is a list of strictly increasing boundaries between
1749        /// buckets. Note that a list of length N-1 defines N buckets because
1750        /// of fenceposting. See comments on `bucket_options` for details.
1751        ///
1752        /// The i'th finite bucket covers the interval
1753        /// [bound[i-1], bound[i])
1754        /// where i ranges from 1 to bound_size() - 1. Note that there are no
1755        /// finite buckets at all if 'bound' only contains a single element; in
1756        /// that special case the single bound defines the boundary between the
1757        /// underflow and overflow buckets.
1758        ///
1759        /// bucket number                   lower bound    upper bound
1760        /// i == 0 (underflow)              -inf           bound[i]
1761        /// 0 < i < bound_size()            bound[i-1]     bound[i]
1762        /// i == bound_size() (overflow)    bound[i-1]     +inf
1763        pub bounds: std::vec::Vec<f64>,
1764
1765        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1766    }
1767
1768    impl ExplicitBuckets {
1769        pub fn new() -> Self {
1770            std::default::Default::default()
1771        }
1772
1773        /// Sets the value of [bounds][crate::model::distribution::ExplicitBuckets::bounds].
1774        pub fn set_bounds<T, V>(mut self, v: T) -> Self
1775        where
1776            T: std::iter::IntoIterator<Item = V>,
1777            V: std::convert::Into<f64>,
1778        {
1779            use std::iter::Iterator;
1780            self.bounds = v.into_iter().map(|i| i.into()).collect();
1781            self
1782        }
1783    }
1784
1785    impl wkt::message::Message for ExplicitBuckets {
1786        fn typename() -> &'static str {
1787            "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExplicitBuckets"
1788        }
1789    }
1790
1791    #[doc(hidden)]
1792    impl<'de> serde::de::Deserialize<'de> for ExplicitBuckets {
1793        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1794        where
1795            D: serde::Deserializer<'de>,
1796        {
1797            #[allow(non_camel_case_types)]
1798            #[doc(hidden)]
1799            #[derive(PartialEq, Eq, Hash)]
1800            enum __FieldTag {
1801                __bounds,
1802                Unknown(std::string::String),
1803            }
1804            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1805                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1806                where
1807                    D: serde::Deserializer<'de>,
1808                {
1809                    struct Visitor;
1810                    impl<'de> serde::de::Visitor<'de> for Visitor {
1811                        type Value = __FieldTag;
1812                        fn expecting(
1813                            &self,
1814                            formatter: &mut std::fmt::Formatter,
1815                        ) -> std::fmt::Result {
1816                            formatter.write_str("a field name for ExplicitBuckets")
1817                        }
1818                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1819                        where
1820                            E: serde::de::Error,
1821                        {
1822                            use std::result::Result::Ok;
1823                            use std::string::ToString;
1824                            match value {
1825                                "bounds" => Ok(__FieldTag::__bounds),
1826                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1827                            }
1828                        }
1829                    }
1830                    deserializer.deserialize_identifier(Visitor)
1831                }
1832            }
1833            struct Visitor;
1834            impl<'de> serde::de::Visitor<'de> for Visitor {
1835                type Value = ExplicitBuckets;
1836                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1837                    formatter.write_str("struct ExplicitBuckets")
1838                }
1839                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1840                where
1841                    A: serde::de::MapAccess<'de>,
1842                {
1843                    #[allow(unused_imports)]
1844                    use serde::de::Error;
1845                    use std::option::Option::Some;
1846                    let mut fields = std::collections::HashSet::new();
1847                    let mut result = Self::Value::new();
1848                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1849                        #[allow(clippy::match_single_binding)]
1850                        match tag {
1851                            __FieldTag::__bounds => {
1852                                if !fields.insert(__FieldTag::__bounds) {
1853                                    return std::result::Result::Err(A::Error::duplicate_field(
1854                                        "multiple values for bounds",
1855                                    ));
1856                                }
1857                                struct __With(std::option::Option<std::vec::Vec<f64>>);
1858                                impl<'de> serde::de::Deserialize<'de> for __With {
1859                                    fn deserialize<D>(
1860                                        deserializer: D,
1861                                    ) -> std::result::Result<Self, D::Error>
1862                                    where
1863                                        D: serde::de::Deserializer<'de>,
1864                                    {
1865                                        serde_with::As::<
1866                                            std::option::Option<std::vec::Vec<wkt::internal::F64>>,
1867                                        >::deserialize(
1868                                            deserializer
1869                                        )
1870                                        .map(__With)
1871                                    }
1872                                }
1873                                result.bounds = map.next_value::<__With>()?.0.unwrap_or_default();
1874                            }
1875                            __FieldTag::Unknown(key) => {
1876                                let value = map.next_value::<serde_json::Value>()?;
1877                                result._unknown_fields.insert(key, value);
1878                            }
1879                        }
1880                    }
1881                    std::result::Result::Ok(result)
1882                }
1883            }
1884            deserializer.deserialize_any(Visitor)
1885        }
1886    }
1887
1888    #[doc(hidden)]
1889    impl serde::ser::Serialize for ExplicitBuckets {
1890        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1891        where
1892            S: serde::ser::Serializer,
1893        {
1894            use serde::ser::SerializeMap;
1895            #[allow(unused_imports)]
1896            use std::option::Option::Some;
1897            let mut state = serializer.serialize_map(std::option::Option::None)?;
1898            if !self.bounds.is_empty() {
1899                struct __With<'a>(&'a std::vec::Vec<f64>);
1900                impl<'a> serde::ser::Serialize for __With<'a> {
1901                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1902                    where
1903                        S: serde::ser::Serializer,
1904                    {
1905                        serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
1906                            self.0, serializer,
1907                        )
1908                    }
1909                }
1910                state.serialize_entry("bounds", &__With(&self.bounds))?;
1911            }
1912            if !self._unknown_fields.is_empty() {
1913                for (key, value) in self._unknown_fields.iter() {
1914                    state.serialize_entry(key, &value)?;
1915                }
1916            }
1917            state.end()
1918        }
1919    }
1920
1921    impl std::fmt::Debug for ExplicitBuckets {
1922        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1923            let mut debug_struct = f.debug_struct("ExplicitBuckets");
1924            debug_struct.field("bounds", &self.bounds);
1925            if !self._unknown_fields.is_empty() {
1926                debug_struct.field("_unknown_fields", &self._unknown_fields);
1927            }
1928            debug_struct.finish()
1929        }
1930    }
1931
1932    /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
1933    /// must be both set, or both unset.
1934    ///
1935    /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
1936    /// There must be at least two buckets (a single-bucket histogram gives
1937    /// no information that isn't already provided by `count`).
1938    ///
1939    /// The first bucket is the underflow bucket which has a lower bound
1940    /// of -inf. The last bucket is the overflow bucket which has an
1941    /// upper bound of +inf. All other buckets (if any) are called "finite"
1942    /// buckets because they have finite lower and upper bounds. As described
1943    /// below, there are three ways to define the finite buckets.
1944    ///
1945    /// (1) Buckets with constant width.
1946    /// (2) Buckets with exponentially growing widths.
1947    /// (3) Buckets with arbitrary user-provided widths.
1948    ///
1949    /// In all cases, the buckets cover the entire real number line (-inf,
1950    /// +inf). Bucket upper bounds are exclusive and lower bounds are
1951    /// inclusive. The upper bound of the underflow bucket is equal to the
1952    /// lower bound of the smallest finite bucket; the lower bound of the
1953    /// overflow bucket is equal to the upper bound of the largest finite
1954    /// bucket.
1955    #[derive(Clone, Debug, PartialEq)]
1956    #[non_exhaustive]
1957    pub enum BucketOption {
1958        /// Buckets with constant width.
1959        LinearBuckets(std::boxed::Box<crate::model::distribution::LinearBuckets>),
1960        /// Buckets with exponentially growing width.
1961        ExponentialBuckets(std::boxed::Box<crate::model::distribution::ExponentialBuckets>),
1962        /// Buckets with arbitrary user-provided width.
1963        ExplicitBuckets(std::boxed::Box<crate::model::distribution::ExplicitBuckets>),
1964    }
1965}
1966
1967/// A common proto for logging HTTP requests. Only contains semantics
1968/// defined by the HTTP specification. Product-specific logging
1969/// information MUST be defined in a separate message.
1970#[derive(Clone, Default, PartialEq)]
1971#[non_exhaustive]
1972pub struct HttpRequest {
1973    /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
1974    pub request_method: std::string::String,
1975
1976    /// The scheme (http, https), the host name, the path, and the query
1977    /// portion of the URL that was requested.
1978    /// Example: ``http://example.com/some/info?color=red``.
1979    pub request_url: std::string::String,
1980
1981    /// The size of the HTTP request message in bytes, including the request
1982    /// headers and the request body.
1983    pub request_size: i64,
1984
1985    /// The response code indicating the status of the response.
1986    /// Examples: 200, 404.
1987    pub status: i32,
1988
1989    /// The size of the HTTP response message sent back to the client, in bytes,
1990    /// including the response headers and the response body.
1991    pub response_size: i64,
1992
1993    /// The user agent sent by the client. Example:
1994    /// `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
1995    /// CLR 1.0.3705)"`.
1996    pub user_agent: std::string::String,
1997
1998    /// The IP address (IPv4 or IPv6) of the client that issued the HTTP
1999    /// request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
2000    pub remote_ip: std::string::String,
2001
2002    /// The IP address (IPv4 or IPv6) of the origin server that the request was
2003    /// sent to.
2004    pub server_ip: std::string::String,
2005
2006    /// The referer URL of the request, as defined in
2007    /// [HTTP/1.1 Header Field
2008    /// Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
2009    pub referer: std::string::String,
2010
2011    /// The request processing latency on the server, from the time the request was
2012    /// received until the response was sent.
2013    pub latency: std::option::Option<wkt::Duration>,
2014
2015    /// Whether or not a cache lookup was attempted.
2016    pub cache_lookup: bool,
2017
2018    /// Whether or not an entity was served from cache
2019    /// (with or without validation).
2020    pub cache_hit: bool,
2021
2022    /// Whether or not the response was validated with the origin server before
2023    /// being served from cache. This field is only meaningful if `cache_hit` is
2024    /// True.
2025    pub cache_validated_with_origin_server: bool,
2026
2027    /// The number of HTTP response bytes inserted into cache. Set only when a
2028    /// cache fill was attempted.
2029    pub cache_fill_bytes: i64,
2030
2031    /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
2032    pub protocol: std::string::String,
2033
2034    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2035}
2036
2037impl HttpRequest {
2038    pub fn new() -> Self {
2039        std::default::Default::default()
2040    }
2041
2042    /// Sets the value of [request_method][crate::model::HttpRequest::request_method].
2043    pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2044        self.request_method = v.into();
2045        self
2046    }
2047
2048    /// Sets the value of [request_url][crate::model::HttpRequest::request_url].
2049    pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2050        self.request_url = v.into();
2051        self
2052    }
2053
2054    /// Sets the value of [request_size][crate::model::HttpRequest::request_size].
2055    pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2056        self.request_size = v.into();
2057        self
2058    }
2059
2060    /// Sets the value of [status][crate::model::HttpRequest::status].
2061    pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2062        self.status = v.into();
2063        self
2064    }
2065
2066    /// Sets the value of [response_size][crate::model::HttpRequest::response_size].
2067    pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2068        self.response_size = v.into();
2069        self
2070    }
2071
2072    /// Sets the value of [user_agent][crate::model::HttpRequest::user_agent].
2073    pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2074        self.user_agent = v.into();
2075        self
2076    }
2077
2078    /// Sets the value of [remote_ip][crate::model::HttpRequest::remote_ip].
2079    pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2080        self.remote_ip = v.into();
2081        self
2082    }
2083
2084    /// Sets the value of [server_ip][crate::model::HttpRequest::server_ip].
2085    pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2086        self.server_ip = v.into();
2087        self
2088    }
2089
2090    /// Sets the value of [referer][crate::model::HttpRequest::referer].
2091    pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2092        self.referer = v.into();
2093        self
2094    }
2095
2096    /// Sets the value of [latency][crate::model::HttpRequest::latency].
2097    pub fn set_latency<T>(mut self, v: T) -> Self
2098    where
2099        T: std::convert::Into<wkt::Duration>,
2100    {
2101        self.latency = std::option::Option::Some(v.into());
2102        self
2103    }
2104
2105    /// Sets or clears the value of [latency][crate::model::HttpRequest::latency].
2106    pub fn set_or_clear_latency<T>(mut self, v: std::option::Option<T>) -> Self
2107    where
2108        T: std::convert::Into<wkt::Duration>,
2109    {
2110        self.latency = v.map(|x| x.into());
2111        self
2112    }
2113
2114    /// Sets the value of [cache_lookup][crate::model::HttpRequest::cache_lookup].
2115    pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2116        self.cache_lookup = v.into();
2117        self
2118    }
2119
2120    /// Sets the value of [cache_hit][crate::model::HttpRequest::cache_hit].
2121    pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2122        self.cache_hit = v.into();
2123        self
2124    }
2125
2126    /// Sets the value of [cache_validated_with_origin_server][crate::model::HttpRequest::cache_validated_with_origin_server].
2127    pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
2128        mut self,
2129        v: T,
2130    ) -> Self {
2131        self.cache_validated_with_origin_server = v.into();
2132        self
2133    }
2134
2135    /// Sets the value of [cache_fill_bytes][crate::model::HttpRequest::cache_fill_bytes].
2136    pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2137        self.cache_fill_bytes = v.into();
2138        self
2139    }
2140
2141    /// Sets the value of [protocol][crate::model::HttpRequest::protocol].
2142    pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2143        self.protocol = v.into();
2144        self
2145    }
2146}
2147
2148impl wkt::message::Message for HttpRequest {
2149    fn typename() -> &'static str {
2150        "type.googleapis.com/google.api.servicecontrol.v1.HttpRequest"
2151    }
2152}
2153
2154#[doc(hidden)]
2155impl<'de> serde::de::Deserialize<'de> for HttpRequest {
2156    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2157    where
2158        D: serde::Deserializer<'de>,
2159    {
2160        #[allow(non_camel_case_types)]
2161        #[doc(hidden)]
2162        #[derive(PartialEq, Eq, Hash)]
2163        enum __FieldTag {
2164            __request_method,
2165            __request_url,
2166            __request_size,
2167            __status,
2168            __response_size,
2169            __user_agent,
2170            __remote_ip,
2171            __server_ip,
2172            __referer,
2173            __latency,
2174            __cache_lookup,
2175            __cache_hit,
2176            __cache_validated_with_origin_server,
2177            __cache_fill_bytes,
2178            __protocol,
2179            Unknown(std::string::String),
2180        }
2181        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2182            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2183            where
2184                D: serde::Deserializer<'de>,
2185            {
2186                struct Visitor;
2187                impl<'de> serde::de::Visitor<'de> for Visitor {
2188                    type Value = __FieldTag;
2189                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2190                        formatter.write_str("a field name for HttpRequest")
2191                    }
2192                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2193                    where
2194                        E: serde::de::Error,
2195                    {
2196                        use std::result::Result::Ok;
2197                        use std::string::ToString;
2198                        match value {
2199                            "requestMethod" => Ok(__FieldTag::__request_method),
2200                            "request_method" => Ok(__FieldTag::__request_method),
2201                            "requestUrl" => Ok(__FieldTag::__request_url),
2202                            "request_url" => Ok(__FieldTag::__request_url),
2203                            "requestSize" => Ok(__FieldTag::__request_size),
2204                            "request_size" => Ok(__FieldTag::__request_size),
2205                            "status" => Ok(__FieldTag::__status),
2206                            "responseSize" => Ok(__FieldTag::__response_size),
2207                            "response_size" => Ok(__FieldTag::__response_size),
2208                            "userAgent" => Ok(__FieldTag::__user_agent),
2209                            "user_agent" => Ok(__FieldTag::__user_agent),
2210                            "remoteIp" => Ok(__FieldTag::__remote_ip),
2211                            "remote_ip" => Ok(__FieldTag::__remote_ip),
2212                            "serverIp" => Ok(__FieldTag::__server_ip),
2213                            "server_ip" => Ok(__FieldTag::__server_ip),
2214                            "referer" => Ok(__FieldTag::__referer),
2215                            "latency" => Ok(__FieldTag::__latency),
2216                            "cacheLookup" => Ok(__FieldTag::__cache_lookup),
2217                            "cache_lookup" => Ok(__FieldTag::__cache_lookup),
2218                            "cacheHit" => Ok(__FieldTag::__cache_hit),
2219                            "cache_hit" => Ok(__FieldTag::__cache_hit),
2220                            "cacheValidatedWithOriginServer" => {
2221                                Ok(__FieldTag::__cache_validated_with_origin_server)
2222                            }
2223                            "cache_validated_with_origin_server" => {
2224                                Ok(__FieldTag::__cache_validated_with_origin_server)
2225                            }
2226                            "cacheFillBytes" => Ok(__FieldTag::__cache_fill_bytes),
2227                            "cache_fill_bytes" => Ok(__FieldTag::__cache_fill_bytes),
2228                            "protocol" => Ok(__FieldTag::__protocol),
2229                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2230                        }
2231                    }
2232                }
2233                deserializer.deserialize_identifier(Visitor)
2234            }
2235        }
2236        struct Visitor;
2237        impl<'de> serde::de::Visitor<'de> for Visitor {
2238            type Value = HttpRequest;
2239            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2240                formatter.write_str("struct HttpRequest")
2241            }
2242            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2243            where
2244                A: serde::de::MapAccess<'de>,
2245            {
2246                #[allow(unused_imports)]
2247                use serde::de::Error;
2248                use std::option::Option::Some;
2249                let mut fields = std::collections::HashSet::new();
2250                let mut result = Self::Value::new();
2251                while let Some(tag) = map.next_key::<__FieldTag>()? {
2252                    #[allow(clippy::match_single_binding)]
2253                    match tag {
2254                        __FieldTag::__request_method => {
2255                            if !fields.insert(__FieldTag::__request_method) {
2256                                return std::result::Result::Err(A::Error::duplicate_field(
2257                                    "multiple values for request_method",
2258                                ));
2259                            }
2260                            result.request_method = map
2261                                .next_value::<std::option::Option<std::string::String>>()?
2262                                .unwrap_or_default();
2263                        }
2264                        __FieldTag::__request_url => {
2265                            if !fields.insert(__FieldTag::__request_url) {
2266                                return std::result::Result::Err(A::Error::duplicate_field(
2267                                    "multiple values for request_url",
2268                                ));
2269                            }
2270                            result.request_url = map
2271                                .next_value::<std::option::Option<std::string::String>>()?
2272                                .unwrap_or_default();
2273                        }
2274                        __FieldTag::__request_size => {
2275                            if !fields.insert(__FieldTag::__request_size) {
2276                                return std::result::Result::Err(A::Error::duplicate_field(
2277                                    "multiple values for request_size",
2278                                ));
2279                            }
2280                            struct __With(std::option::Option<i64>);
2281                            impl<'de> serde::de::Deserialize<'de> for __With {
2282                                fn deserialize<D>(
2283                                    deserializer: D,
2284                                ) -> std::result::Result<Self, D::Error>
2285                                where
2286                                    D: serde::de::Deserializer<'de>,
2287                                {
2288                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2289                                }
2290                            }
2291                            result.request_size = map.next_value::<__With>()?.0.unwrap_or_default();
2292                        }
2293                        __FieldTag::__status => {
2294                            if !fields.insert(__FieldTag::__status) {
2295                                return std::result::Result::Err(A::Error::duplicate_field(
2296                                    "multiple values for status",
2297                                ));
2298                            }
2299                            struct __With(std::option::Option<i32>);
2300                            impl<'de> serde::de::Deserialize<'de> for __With {
2301                                fn deserialize<D>(
2302                                    deserializer: D,
2303                                ) -> std::result::Result<Self, D::Error>
2304                                where
2305                                    D: serde::de::Deserializer<'de>,
2306                                {
2307                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2308                                }
2309                            }
2310                            result.status = map.next_value::<__With>()?.0.unwrap_or_default();
2311                        }
2312                        __FieldTag::__response_size => {
2313                            if !fields.insert(__FieldTag::__response_size) {
2314                                return std::result::Result::Err(A::Error::duplicate_field(
2315                                    "multiple values for response_size",
2316                                ));
2317                            }
2318                            struct __With(std::option::Option<i64>);
2319                            impl<'de> serde::de::Deserialize<'de> for __With {
2320                                fn deserialize<D>(
2321                                    deserializer: D,
2322                                ) -> std::result::Result<Self, D::Error>
2323                                where
2324                                    D: serde::de::Deserializer<'de>,
2325                                {
2326                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2327                                }
2328                            }
2329                            result.response_size =
2330                                map.next_value::<__With>()?.0.unwrap_or_default();
2331                        }
2332                        __FieldTag::__user_agent => {
2333                            if !fields.insert(__FieldTag::__user_agent) {
2334                                return std::result::Result::Err(A::Error::duplicate_field(
2335                                    "multiple values for user_agent",
2336                                ));
2337                            }
2338                            result.user_agent = map
2339                                .next_value::<std::option::Option<std::string::String>>()?
2340                                .unwrap_or_default();
2341                        }
2342                        __FieldTag::__remote_ip => {
2343                            if !fields.insert(__FieldTag::__remote_ip) {
2344                                return std::result::Result::Err(A::Error::duplicate_field(
2345                                    "multiple values for remote_ip",
2346                                ));
2347                            }
2348                            result.remote_ip = map
2349                                .next_value::<std::option::Option<std::string::String>>()?
2350                                .unwrap_or_default();
2351                        }
2352                        __FieldTag::__server_ip => {
2353                            if !fields.insert(__FieldTag::__server_ip) {
2354                                return std::result::Result::Err(A::Error::duplicate_field(
2355                                    "multiple values for server_ip",
2356                                ));
2357                            }
2358                            result.server_ip = map
2359                                .next_value::<std::option::Option<std::string::String>>()?
2360                                .unwrap_or_default();
2361                        }
2362                        __FieldTag::__referer => {
2363                            if !fields.insert(__FieldTag::__referer) {
2364                                return std::result::Result::Err(A::Error::duplicate_field(
2365                                    "multiple values for referer",
2366                                ));
2367                            }
2368                            result.referer = map
2369                                .next_value::<std::option::Option<std::string::String>>()?
2370                                .unwrap_or_default();
2371                        }
2372                        __FieldTag::__latency => {
2373                            if !fields.insert(__FieldTag::__latency) {
2374                                return std::result::Result::Err(A::Error::duplicate_field(
2375                                    "multiple values for latency",
2376                                ));
2377                            }
2378                            result.latency =
2379                                map.next_value::<std::option::Option<wkt::Duration>>()?;
2380                        }
2381                        __FieldTag::__cache_lookup => {
2382                            if !fields.insert(__FieldTag::__cache_lookup) {
2383                                return std::result::Result::Err(A::Error::duplicate_field(
2384                                    "multiple values for cache_lookup",
2385                                ));
2386                            }
2387                            result.cache_lookup = map
2388                                .next_value::<std::option::Option<bool>>()?
2389                                .unwrap_or_default();
2390                        }
2391                        __FieldTag::__cache_hit => {
2392                            if !fields.insert(__FieldTag::__cache_hit) {
2393                                return std::result::Result::Err(A::Error::duplicate_field(
2394                                    "multiple values for cache_hit",
2395                                ));
2396                            }
2397                            result.cache_hit = map
2398                                .next_value::<std::option::Option<bool>>()?
2399                                .unwrap_or_default();
2400                        }
2401                        __FieldTag::__cache_validated_with_origin_server => {
2402                            if !fields.insert(__FieldTag::__cache_validated_with_origin_server) {
2403                                return std::result::Result::Err(A::Error::duplicate_field(
2404                                    "multiple values for cache_validated_with_origin_server",
2405                                ));
2406                            }
2407                            result.cache_validated_with_origin_server = map
2408                                .next_value::<std::option::Option<bool>>()?
2409                                .unwrap_or_default();
2410                        }
2411                        __FieldTag::__cache_fill_bytes => {
2412                            if !fields.insert(__FieldTag::__cache_fill_bytes) {
2413                                return std::result::Result::Err(A::Error::duplicate_field(
2414                                    "multiple values for cache_fill_bytes",
2415                                ));
2416                            }
2417                            struct __With(std::option::Option<i64>);
2418                            impl<'de> serde::de::Deserialize<'de> for __With {
2419                                fn deserialize<D>(
2420                                    deserializer: D,
2421                                ) -> std::result::Result<Self, D::Error>
2422                                where
2423                                    D: serde::de::Deserializer<'de>,
2424                                {
2425                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2426                                }
2427                            }
2428                            result.cache_fill_bytes =
2429                                map.next_value::<__With>()?.0.unwrap_or_default();
2430                        }
2431                        __FieldTag::__protocol => {
2432                            if !fields.insert(__FieldTag::__protocol) {
2433                                return std::result::Result::Err(A::Error::duplicate_field(
2434                                    "multiple values for protocol",
2435                                ));
2436                            }
2437                            result.protocol = map
2438                                .next_value::<std::option::Option<std::string::String>>()?
2439                                .unwrap_or_default();
2440                        }
2441                        __FieldTag::Unknown(key) => {
2442                            let value = map.next_value::<serde_json::Value>()?;
2443                            result._unknown_fields.insert(key, value);
2444                        }
2445                    }
2446                }
2447                std::result::Result::Ok(result)
2448            }
2449        }
2450        deserializer.deserialize_any(Visitor)
2451    }
2452}
2453
2454#[doc(hidden)]
2455impl serde::ser::Serialize for HttpRequest {
2456    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2457    where
2458        S: serde::ser::Serializer,
2459    {
2460        use serde::ser::SerializeMap;
2461        #[allow(unused_imports)]
2462        use std::option::Option::Some;
2463        let mut state = serializer.serialize_map(std::option::Option::None)?;
2464        if !self.request_method.is_empty() {
2465            state.serialize_entry("requestMethod", &self.request_method)?;
2466        }
2467        if !self.request_url.is_empty() {
2468            state.serialize_entry("requestUrl", &self.request_url)?;
2469        }
2470        if !wkt::internal::is_default(&self.request_size) {
2471            struct __With<'a>(&'a i64);
2472            impl<'a> serde::ser::Serialize for __With<'a> {
2473                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2474                where
2475                    S: serde::ser::Serializer,
2476                {
2477                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2478                }
2479            }
2480            state.serialize_entry("requestSize", &__With(&self.request_size))?;
2481        }
2482        if !wkt::internal::is_default(&self.status) {
2483            struct __With<'a>(&'a i32);
2484            impl<'a> serde::ser::Serialize for __With<'a> {
2485                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2486                where
2487                    S: serde::ser::Serializer,
2488                {
2489                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
2490                }
2491            }
2492            state.serialize_entry("status", &__With(&self.status))?;
2493        }
2494        if !wkt::internal::is_default(&self.response_size) {
2495            struct __With<'a>(&'a i64);
2496            impl<'a> serde::ser::Serialize for __With<'a> {
2497                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2498                where
2499                    S: serde::ser::Serializer,
2500                {
2501                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2502                }
2503            }
2504            state.serialize_entry("responseSize", &__With(&self.response_size))?;
2505        }
2506        if !self.user_agent.is_empty() {
2507            state.serialize_entry("userAgent", &self.user_agent)?;
2508        }
2509        if !self.remote_ip.is_empty() {
2510            state.serialize_entry("remoteIp", &self.remote_ip)?;
2511        }
2512        if !self.server_ip.is_empty() {
2513            state.serialize_entry("serverIp", &self.server_ip)?;
2514        }
2515        if !self.referer.is_empty() {
2516            state.serialize_entry("referer", &self.referer)?;
2517        }
2518        if self.latency.is_some() {
2519            state.serialize_entry("latency", &self.latency)?;
2520        }
2521        if !wkt::internal::is_default(&self.cache_lookup) {
2522            state.serialize_entry("cacheLookup", &self.cache_lookup)?;
2523        }
2524        if !wkt::internal::is_default(&self.cache_hit) {
2525            state.serialize_entry("cacheHit", &self.cache_hit)?;
2526        }
2527        if !wkt::internal::is_default(&self.cache_validated_with_origin_server) {
2528            state.serialize_entry(
2529                "cacheValidatedWithOriginServer",
2530                &self.cache_validated_with_origin_server,
2531            )?;
2532        }
2533        if !wkt::internal::is_default(&self.cache_fill_bytes) {
2534            struct __With<'a>(&'a i64);
2535            impl<'a> serde::ser::Serialize for __With<'a> {
2536                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2537                where
2538                    S: serde::ser::Serializer,
2539                {
2540                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2541                }
2542            }
2543            state.serialize_entry("cacheFillBytes", &__With(&self.cache_fill_bytes))?;
2544        }
2545        if !self.protocol.is_empty() {
2546            state.serialize_entry("protocol", &self.protocol)?;
2547        }
2548        if !self._unknown_fields.is_empty() {
2549            for (key, value) in self._unknown_fields.iter() {
2550                state.serialize_entry(key, &value)?;
2551            }
2552        }
2553        state.end()
2554    }
2555}
2556
2557impl std::fmt::Debug for HttpRequest {
2558    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2559        let mut debug_struct = f.debug_struct("HttpRequest");
2560        debug_struct.field("request_method", &self.request_method);
2561        debug_struct.field("request_url", &self.request_url);
2562        debug_struct.field("request_size", &self.request_size);
2563        debug_struct.field("status", &self.status);
2564        debug_struct.field("response_size", &self.response_size);
2565        debug_struct.field("user_agent", &self.user_agent);
2566        debug_struct.field("remote_ip", &self.remote_ip);
2567        debug_struct.field("server_ip", &self.server_ip);
2568        debug_struct.field("referer", &self.referer);
2569        debug_struct.field("latency", &self.latency);
2570        debug_struct.field("cache_lookup", &self.cache_lookup);
2571        debug_struct.field("cache_hit", &self.cache_hit);
2572        debug_struct.field(
2573            "cache_validated_with_origin_server",
2574            &self.cache_validated_with_origin_server,
2575        );
2576        debug_struct.field("cache_fill_bytes", &self.cache_fill_bytes);
2577        debug_struct.field("protocol", &self.protocol);
2578        if !self._unknown_fields.is_empty() {
2579            debug_struct.field("_unknown_fields", &self._unknown_fields);
2580        }
2581        debug_struct.finish()
2582    }
2583}
2584
2585/// An individual log entry.
2586#[derive(Clone, Default, PartialEq)]
2587#[non_exhaustive]
2588pub struct LogEntry {
2589    /// Required. The log to which this log entry belongs. Examples: `"syslog"`,
2590    /// `"book_log"`.
2591    pub name: std::string::String,
2592
2593    /// The time the event described by the log entry occurred. If
2594    /// omitted, defaults to operation start time.
2595    pub timestamp: std::option::Option<wkt::Timestamp>,
2596
2597    /// The severity of the log entry. The default value is
2598    /// `LogSeverity.DEFAULT`.
2599    pub severity: logging_type::model::LogSeverity,
2600
2601    /// Optional. Information about the HTTP request associated with this
2602    /// log entry, if applicable.
2603    pub http_request: std::option::Option<crate::model::HttpRequest>,
2604
2605    /// Optional. Resource name of the trace associated with the log entry, if any.
2606    /// If this field contains a relative resource name, you can assume the name is
2607    /// relative to `//tracing.googleapis.com`. Example:
2608    /// `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824`
2609    pub trace: std::string::String,
2610
2611    /// A unique ID for the log entry used for deduplication. If omitted,
2612    /// the implementation will generate one based on operation_id.
2613    pub insert_id: std::string::String,
2614
2615    /// A set of user-defined (key, value) data that provides additional
2616    /// information about the log entry.
2617    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
2618
2619    /// Optional. Information about an operation associated with the log entry, if
2620    /// applicable.
2621    pub operation: std::option::Option<crate::model::LogEntryOperation>,
2622
2623    /// Optional. Source code location information associated with the log entry,
2624    /// if any.
2625    pub source_location: std::option::Option<crate::model::LogEntrySourceLocation>,
2626
2627    /// The log entry payload, which can be one of multiple types.
2628    pub payload: std::option::Option<crate::model::log_entry::Payload>,
2629
2630    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2631}
2632
2633impl LogEntry {
2634    pub fn new() -> Self {
2635        std::default::Default::default()
2636    }
2637
2638    /// Sets the value of [name][crate::model::LogEntry::name].
2639    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2640        self.name = v.into();
2641        self
2642    }
2643
2644    /// Sets the value of [timestamp][crate::model::LogEntry::timestamp].
2645    pub fn set_timestamp<T>(mut self, v: T) -> Self
2646    where
2647        T: std::convert::Into<wkt::Timestamp>,
2648    {
2649        self.timestamp = std::option::Option::Some(v.into());
2650        self
2651    }
2652
2653    /// Sets or clears the value of [timestamp][crate::model::LogEntry::timestamp].
2654    pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
2655    where
2656        T: std::convert::Into<wkt::Timestamp>,
2657    {
2658        self.timestamp = v.map(|x| x.into());
2659        self
2660    }
2661
2662    /// Sets the value of [severity][crate::model::LogEntry::severity].
2663    pub fn set_severity<T: std::convert::Into<logging_type::model::LogSeverity>>(
2664        mut self,
2665        v: T,
2666    ) -> Self {
2667        self.severity = v.into();
2668        self
2669    }
2670
2671    /// Sets the value of [http_request][crate::model::LogEntry::http_request].
2672    pub fn set_http_request<T>(mut self, v: T) -> Self
2673    where
2674        T: std::convert::Into<crate::model::HttpRequest>,
2675    {
2676        self.http_request = std::option::Option::Some(v.into());
2677        self
2678    }
2679
2680    /// Sets or clears the value of [http_request][crate::model::LogEntry::http_request].
2681    pub fn set_or_clear_http_request<T>(mut self, v: std::option::Option<T>) -> Self
2682    where
2683        T: std::convert::Into<crate::model::HttpRequest>,
2684    {
2685        self.http_request = v.map(|x| x.into());
2686        self
2687    }
2688
2689    /// Sets the value of [trace][crate::model::LogEntry::trace].
2690    pub fn set_trace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2691        self.trace = v.into();
2692        self
2693    }
2694
2695    /// Sets the value of [insert_id][crate::model::LogEntry::insert_id].
2696    pub fn set_insert_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2697        self.insert_id = v.into();
2698        self
2699    }
2700
2701    /// Sets the value of [labels][crate::model::LogEntry::labels].
2702    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
2703    where
2704        T: std::iter::IntoIterator<Item = (K, V)>,
2705        K: std::convert::Into<std::string::String>,
2706        V: std::convert::Into<std::string::String>,
2707    {
2708        use std::iter::Iterator;
2709        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2710        self
2711    }
2712
2713    /// Sets the value of [operation][crate::model::LogEntry::operation].
2714    pub fn set_operation<T>(mut self, v: T) -> Self
2715    where
2716        T: std::convert::Into<crate::model::LogEntryOperation>,
2717    {
2718        self.operation = std::option::Option::Some(v.into());
2719        self
2720    }
2721
2722    /// Sets or clears the value of [operation][crate::model::LogEntry::operation].
2723    pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
2724    where
2725        T: std::convert::Into<crate::model::LogEntryOperation>,
2726    {
2727        self.operation = v.map(|x| x.into());
2728        self
2729    }
2730
2731    /// Sets the value of [source_location][crate::model::LogEntry::source_location].
2732    pub fn set_source_location<T>(mut self, v: T) -> Self
2733    where
2734        T: std::convert::Into<crate::model::LogEntrySourceLocation>,
2735    {
2736        self.source_location = std::option::Option::Some(v.into());
2737        self
2738    }
2739
2740    /// Sets or clears the value of [source_location][crate::model::LogEntry::source_location].
2741    pub fn set_or_clear_source_location<T>(mut self, v: std::option::Option<T>) -> Self
2742    where
2743        T: std::convert::Into<crate::model::LogEntrySourceLocation>,
2744    {
2745        self.source_location = v.map(|x| x.into());
2746        self
2747    }
2748
2749    /// Sets the value of [payload][crate::model::LogEntry::payload].
2750    ///
2751    /// Note that all the setters affecting `payload` are mutually
2752    /// exclusive.
2753    pub fn set_payload<
2754        T: std::convert::Into<std::option::Option<crate::model::log_entry::Payload>>,
2755    >(
2756        mut self,
2757        v: T,
2758    ) -> Self {
2759        self.payload = v.into();
2760        self
2761    }
2762
2763    /// The value of [payload][crate::model::LogEntry::payload]
2764    /// if it holds a `ProtoPayload`, `None` if the field is not set or
2765    /// holds a different branch.
2766    pub fn proto_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Any>> {
2767        #[allow(unreachable_patterns)]
2768        self.payload.as_ref().and_then(|v| match v {
2769            crate::model::log_entry::Payload::ProtoPayload(v) => std::option::Option::Some(v),
2770            _ => std::option::Option::None,
2771        })
2772    }
2773
2774    /// Sets the value of [payload][crate::model::LogEntry::payload]
2775    /// to hold a `ProtoPayload`.
2776    ///
2777    /// Note that all the setters affecting `payload` are
2778    /// mutually exclusive.
2779    pub fn set_proto_payload<T: std::convert::Into<std::boxed::Box<wkt::Any>>>(
2780        mut self,
2781        v: T,
2782    ) -> Self {
2783        self.payload =
2784            std::option::Option::Some(crate::model::log_entry::Payload::ProtoPayload(v.into()));
2785        self
2786    }
2787
2788    /// The value of [payload][crate::model::LogEntry::payload]
2789    /// if it holds a `TextPayload`, `None` if the field is not set or
2790    /// holds a different branch.
2791    pub fn text_payload(&self) -> std::option::Option<&std::string::String> {
2792        #[allow(unreachable_patterns)]
2793        self.payload.as_ref().and_then(|v| match v {
2794            crate::model::log_entry::Payload::TextPayload(v) => std::option::Option::Some(v),
2795            _ => std::option::Option::None,
2796        })
2797    }
2798
2799    /// Sets the value of [payload][crate::model::LogEntry::payload]
2800    /// to hold a `TextPayload`.
2801    ///
2802    /// Note that all the setters affecting `payload` are
2803    /// mutually exclusive.
2804    pub fn set_text_payload<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2805        self.payload =
2806            std::option::Option::Some(crate::model::log_entry::Payload::TextPayload(v.into()));
2807        self
2808    }
2809
2810    /// The value of [payload][crate::model::LogEntry::payload]
2811    /// if it holds a `StructPayload`, `None` if the field is not set or
2812    /// holds a different branch.
2813    pub fn struct_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Struct>> {
2814        #[allow(unreachable_patterns)]
2815        self.payload.as_ref().and_then(|v| match v {
2816            crate::model::log_entry::Payload::StructPayload(v) => std::option::Option::Some(v),
2817            _ => std::option::Option::None,
2818        })
2819    }
2820
2821    /// Sets the value of [payload][crate::model::LogEntry::payload]
2822    /// to hold a `StructPayload`.
2823    ///
2824    /// Note that all the setters affecting `payload` are
2825    /// mutually exclusive.
2826    pub fn set_struct_payload<T: std::convert::Into<std::boxed::Box<wkt::Struct>>>(
2827        mut self,
2828        v: T,
2829    ) -> Self {
2830        self.payload =
2831            std::option::Option::Some(crate::model::log_entry::Payload::StructPayload(v.into()));
2832        self
2833    }
2834}
2835
2836impl wkt::message::Message for LogEntry {
2837    fn typename() -> &'static str {
2838        "type.googleapis.com/google.api.servicecontrol.v1.LogEntry"
2839    }
2840}
2841
2842#[doc(hidden)]
2843impl<'de> serde::de::Deserialize<'de> for LogEntry {
2844    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2845    where
2846        D: serde::Deserializer<'de>,
2847    {
2848        #[allow(non_camel_case_types)]
2849        #[doc(hidden)]
2850        #[derive(PartialEq, Eq, Hash)]
2851        enum __FieldTag {
2852            __name,
2853            __timestamp,
2854            __severity,
2855            __http_request,
2856            __trace,
2857            __insert_id,
2858            __labels,
2859            __proto_payload,
2860            __text_payload,
2861            __struct_payload,
2862            __operation,
2863            __source_location,
2864            Unknown(std::string::String),
2865        }
2866        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2867            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2868            where
2869                D: serde::Deserializer<'de>,
2870            {
2871                struct Visitor;
2872                impl<'de> serde::de::Visitor<'de> for Visitor {
2873                    type Value = __FieldTag;
2874                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2875                        formatter.write_str("a field name for LogEntry")
2876                    }
2877                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2878                    where
2879                        E: serde::de::Error,
2880                    {
2881                        use std::result::Result::Ok;
2882                        use std::string::ToString;
2883                        match value {
2884                            "name" => Ok(__FieldTag::__name),
2885                            "timestamp" => Ok(__FieldTag::__timestamp),
2886                            "severity" => Ok(__FieldTag::__severity),
2887                            "httpRequest" => Ok(__FieldTag::__http_request),
2888                            "http_request" => Ok(__FieldTag::__http_request),
2889                            "trace" => Ok(__FieldTag::__trace),
2890                            "insertId" => Ok(__FieldTag::__insert_id),
2891                            "insert_id" => Ok(__FieldTag::__insert_id),
2892                            "labels" => Ok(__FieldTag::__labels),
2893                            "protoPayload" => Ok(__FieldTag::__proto_payload),
2894                            "proto_payload" => Ok(__FieldTag::__proto_payload),
2895                            "textPayload" => Ok(__FieldTag::__text_payload),
2896                            "text_payload" => Ok(__FieldTag::__text_payload),
2897                            "structPayload" => Ok(__FieldTag::__struct_payload),
2898                            "struct_payload" => Ok(__FieldTag::__struct_payload),
2899                            "operation" => Ok(__FieldTag::__operation),
2900                            "sourceLocation" => Ok(__FieldTag::__source_location),
2901                            "source_location" => Ok(__FieldTag::__source_location),
2902                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2903                        }
2904                    }
2905                }
2906                deserializer.deserialize_identifier(Visitor)
2907            }
2908        }
2909        struct Visitor;
2910        impl<'de> serde::de::Visitor<'de> for Visitor {
2911            type Value = LogEntry;
2912            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2913                formatter.write_str("struct LogEntry")
2914            }
2915            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2916            where
2917                A: serde::de::MapAccess<'de>,
2918            {
2919                #[allow(unused_imports)]
2920                use serde::de::Error;
2921                use std::option::Option::Some;
2922                let mut fields = std::collections::HashSet::new();
2923                let mut result = Self::Value::new();
2924                while let Some(tag) = map.next_key::<__FieldTag>()? {
2925                    #[allow(clippy::match_single_binding)]
2926                    match tag {
2927                        __FieldTag::__name => {
2928                            if !fields.insert(__FieldTag::__name) {
2929                                return std::result::Result::Err(A::Error::duplicate_field(
2930                                    "multiple values for name",
2931                                ));
2932                            }
2933                            result.name = map
2934                                .next_value::<std::option::Option<std::string::String>>()?
2935                                .unwrap_or_default();
2936                        }
2937                        __FieldTag::__timestamp => {
2938                            if !fields.insert(__FieldTag::__timestamp) {
2939                                return std::result::Result::Err(A::Error::duplicate_field(
2940                                    "multiple values for timestamp",
2941                                ));
2942                            }
2943                            result.timestamp =
2944                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2945                        }
2946                        __FieldTag::__severity => {
2947                            if !fields.insert(__FieldTag::__severity) {
2948                                return std::result::Result::Err(A::Error::duplicate_field(
2949                                    "multiple values for severity",
2950                                ));
2951                            }
2952                            result.severity = map.next_value::<std::option::Option<logging_type::model::LogSeverity>>()?.unwrap_or_default();
2953                        }
2954                        __FieldTag::__http_request => {
2955                            if !fields.insert(__FieldTag::__http_request) {
2956                                return std::result::Result::Err(A::Error::duplicate_field(
2957                                    "multiple values for http_request",
2958                                ));
2959                            }
2960                            result.http_request =
2961                                map.next_value::<std::option::Option<crate::model::HttpRequest>>()?;
2962                        }
2963                        __FieldTag::__trace => {
2964                            if !fields.insert(__FieldTag::__trace) {
2965                                return std::result::Result::Err(A::Error::duplicate_field(
2966                                    "multiple values for trace",
2967                                ));
2968                            }
2969                            result.trace = map
2970                                .next_value::<std::option::Option<std::string::String>>()?
2971                                .unwrap_or_default();
2972                        }
2973                        __FieldTag::__insert_id => {
2974                            if !fields.insert(__FieldTag::__insert_id) {
2975                                return std::result::Result::Err(A::Error::duplicate_field(
2976                                    "multiple values for insert_id",
2977                                ));
2978                            }
2979                            result.insert_id = map
2980                                .next_value::<std::option::Option<std::string::String>>()?
2981                                .unwrap_or_default();
2982                        }
2983                        __FieldTag::__labels => {
2984                            if !fields.insert(__FieldTag::__labels) {
2985                                return std::result::Result::Err(A::Error::duplicate_field(
2986                                    "multiple values for labels",
2987                                ));
2988                            }
2989                            result.labels = map
2990                                .next_value::<std::option::Option<
2991                                    std::collections::HashMap<
2992                                        std::string::String,
2993                                        std::string::String,
2994                                    >,
2995                                >>()?
2996                                .unwrap_or_default();
2997                        }
2998                        __FieldTag::__proto_payload => {
2999                            if !fields.insert(__FieldTag::__proto_payload) {
3000                                return std::result::Result::Err(A::Error::duplicate_field(
3001                                    "multiple values for proto_payload",
3002                                ));
3003                            }
3004                            if result.payload.is_some() {
3005                                return std::result::Result::Err(A::Error::duplicate_field(
3006                                    "multiple values for `payload`, a oneof with full ID .google.api.servicecontrol.v1.LogEntry.proto_payload, latest field was protoPayload",
3007                                ));
3008                            }
3009                            result.payload = std::option::Option::Some(
3010                                crate::model::log_entry::Payload::ProtoPayload(
3011                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Any>>>()?.unwrap_or_default()
3012                                ),
3013                            );
3014                        }
3015                        __FieldTag::__text_payload => {
3016                            if !fields.insert(__FieldTag::__text_payload) {
3017                                return std::result::Result::Err(A::Error::duplicate_field(
3018                                    "multiple values for text_payload",
3019                                ));
3020                            }
3021                            if result.payload.is_some() {
3022                                return std::result::Result::Err(A::Error::duplicate_field(
3023                                    "multiple values for `payload`, a oneof with full ID .google.api.servicecontrol.v1.LogEntry.text_payload, latest field was textPayload",
3024                                ));
3025                            }
3026                            result.payload = std::option::Option::Some(
3027                                crate::model::log_entry::Payload::TextPayload(
3028                                    map.next_value::<std::option::Option<std::string::String>>()?
3029                                        .unwrap_or_default(),
3030                                ),
3031                            );
3032                        }
3033                        __FieldTag::__struct_payload => {
3034                            if !fields.insert(__FieldTag::__struct_payload) {
3035                                return std::result::Result::Err(A::Error::duplicate_field(
3036                                    "multiple values for struct_payload",
3037                                ));
3038                            }
3039                            if result.payload.is_some() {
3040                                return std::result::Result::Err(A::Error::duplicate_field(
3041                                    "multiple values for `payload`, a oneof with full ID .google.api.servicecontrol.v1.LogEntry.struct_payload, latest field was structPayload",
3042                                ));
3043                            }
3044                            result.payload = std::option::Option::Some(
3045                                crate::model::log_entry::Payload::StructPayload(
3046                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Struct>>>()?.unwrap_or_default()
3047                                ),
3048                            );
3049                        }
3050                        __FieldTag::__operation => {
3051                            if !fields.insert(__FieldTag::__operation) {
3052                                return std::result::Result::Err(A::Error::duplicate_field(
3053                                    "multiple values for operation",
3054                                ));
3055                            }
3056                            result.operation = map
3057                                .next_value::<std::option::Option<crate::model::LogEntryOperation>>(
3058                                )?;
3059                        }
3060                        __FieldTag::__source_location => {
3061                            if !fields.insert(__FieldTag::__source_location) {
3062                                return std::result::Result::Err(A::Error::duplicate_field(
3063                                    "multiple values for source_location",
3064                                ));
3065                            }
3066                            result.source_location = map.next_value::<std::option::Option<crate::model::LogEntrySourceLocation>>()?
3067                                ;
3068                        }
3069                        __FieldTag::Unknown(key) => {
3070                            let value = map.next_value::<serde_json::Value>()?;
3071                            result._unknown_fields.insert(key, value);
3072                        }
3073                    }
3074                }
3075                std::result::Result::Ok(result)
3076            }
3077        }
3078        deserializer.deserialize_any(Visitor)
3079    }
3080}
3081
3082#[doc(hidden)]
3083impl serde::ser::Serialize for LogEntry {
3084    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3085    where
3086        S: serde::ser::Serializer,
3087    {
3088        use serde::ser::SerializeMap;
3089        #[allow(unused_imports)]
3090        use std::option::Option::Some;
3091        let mut state = serializer.serialize_map(std::option::Option::None)?;
3092        if !self.name.is_empty() {
3093            state.serialize_entry("name", &self.name)?;
3094        }
3095        if self.timestamp.is_some() {
3096            state.serialize_entry("timestamp", &self.timestamp)?;
3097        }
3098        if !wkt::internal::is_default(&self.severity) {
3099            state.serialize_entry("severity", &self.severity)?;
3100        }
3101        if self.http_request.is_some() {
3102            state.serialize_entry("httpRequest", &self.http_request)?;
3103        }
3104        if !self.trace.is_empty() {
3105            state.serialize_entry("trace", &self.trace)?;
3106        }
3107        if !self.insert_id.is_empty() {
3108            state.serialize_entry("insertId", &self.insert_id)?;
3109        }
3110        if !self.labels.is_empty() {
3111            state.serialize_entry("labels", &self.labels)?;
3112        }
3113        if let Some(value) = self.proto_payload() {
3114            state.serialize_entry("protoPayload", value)?;
3115        }
3116        if let Some(value) = self.text_payload() {
3117            state.serialize_entry("textPayload", value)?;
3118        }
3119        if let Some(value) = self.struct_payload() {
3120            state.serialize_entry("structPayload", value)?;
3121        }
3122        if self.operation.is_some() {
3123            state.serialize_entry("operation", &self.operation)?;
3124        }
3125        if self.source_location.is_some() {
3126            state.serialize_entry("sourceLocation", &self.source_location)?;
3127        }
3128        if !self._unknown_fields.is_empty() {
3129            for (key, value) in self._unknown_fields.iter() {
3130                state.serialize_entry(key, &value)?;
3131            }
3132        }
3133        state.end()
3134    }
3135}
3136
3137impl std::fmt::Debug for LogEntry {
3138    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3139        let mut debug_struct = f.debug_struct("LogEntry");
3140        debug_struct.field("name", &self.name);
3141        debug_struct.field("timestamp", &self.timestamp);
3142        debug_struct.field("severity", &self.severity);
3143        debug_struct.field("http_request", &self.http_request);
3144        debug_struct.field("trace", &self.trace);
3145        debug_struct.field("insert_id", &self.insert_id);
3146        debug_struct.field("labels", &self.labels);
3147        debug_struct.field("operation", &self.operation);
3148        debug_struct.field("source_location", &self.source_location);
3149        debug_struct.field("payload", &self.payload);
3150        if !self._unknown_fields.is_empty() {
3151            debug_struct.field("_unknown_fields", &self._unknown_fields);
3152        }
3153        debug_struct.finish()
3154    }
3155}
3156
3157/// Defines additional types related to [LogEntry].
3158pub mod log_entry {
3159    #[allow(unused_imports)]
3160    use super::*;
3161
3162    /// The log entry payload, which can be one of multiple types.
3163    #[derive(Clone, Debug, PartialEq)]
3164    #[non_exhaustive]
3165    pub enum Payload {
3166        /// The log entry payload, represented as a protocol buffer that is
3167        /// expressed as a JSON object. The only accepted type currently is
3168        /// [AuditLog][google.cloud.audit.AuditLog].
3169        ProtoPayload(std::boxed::Box<wkt::Any>),
3170        /// The log entry payload, represented as a Unicode string (UTF-8).
3171        TextPayload(std::string::String),
3172        /// The log entry payload, represented as a structure that
3173        /// is expressed as a JSON object.
3174        StructPayload(std::boxed::Box<wkt::Struct>),
3175    }
3176}
3177
3178/// Additional information about a potentially long-running operation with which
3179/// a log entry is associated.
3180#[derive(Clone, Default, PartialEq)]
3181#[non_exhaustive]
3182pub struct LogEntryOperation {
3183    /// Optional. An arbitrary operation identifier. Log entries with the
3184    /// same identifier are assumed to be part of the same operation.
3185    pub id: std::string::String,
3186
3187    /// Optional. An arbitrary producer identifier. The combination of
3188    /// `id` and `producer` must be globally unique.  Examples for `producer`:
3189    /// `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`.
3190    pub producer: std::string::String,
3191
3192    /// Optional. Set this to True if this is the first log entry in the operation.
3193    pub first: bool,
3194
3195    /// Optional. Set this to True if this is the last log entry in the operation.
3196    pub last: bool,
3197
3198    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3199}
3200
3201impl LogEntryOperation {
3202    pub fn new() -> Self {
3203        std::default::Default::default()
3204    }
3205
3206    /// Sets the value of [id][crate::model::LogEntryOperation::id].
3207    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3208        self.id = v.into();
3209        self
3210    }
3211
3212    /// Sets the value of [producer][crate::model::LogEntryOperation::producer].
3213    pub fn set_producer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3214        self.producer = v.into();
3215        self
3216    }
3217
3218    /// Sets the value of [first][crate::model::LogEntryOperation::first].
3219    pub fn set_first<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3220        self.first = v.into();
3221        self
3222    }
3223
3224    /// Sets the value of [last][crate::model::LogEntryOperation::last].
3225    pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3226        self.last = v.into();
3227        self
3228    }
3229}
3230
3231impl wkt::message::Message for LogEntryOperation {
3232    fn typename() -> &'static str {
3233        "type.googleapis.com/google.api.servicecontrol.v1.LogEntryOperation"
3234    }
3235}
3236
3237#[doc(hidden)]
3238impl<'de> serde::de::Deserialize<'de> for LogEntryOperation {
3239    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3240    where
3241        D: serde::Deserializer<'de>,
3242    {
3243        #[allow(non_camel_case_types)]
3244        #[doc(hidden)]
3245        #[derive(PartialEq, Eq, Hash)]
3246        enum __FieldTag {
3247            __id,
3248            __producer,
3249            __first,
3250            __last,
3251            Unknown(std::string::String),
3252        }
3253        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3254            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3255            where
3256                D: serde::Deserializer<'de>,
3257            {
3258                struct Visitor;
3259                impl<'de> serde::de::Visitor<'de> for Visitor {
3260                    type Value = __FieldTag;
3261                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3262                        formatter.write_str("a field name for LogEntryOperation")
3263                    }
3264                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3265                    where
3266                        E: serde::de::Error,
3267                    {
3268                        use std::result::Result::Ok;
3269                        use std::string::ToString;
3270                        match value {
3271                            "id" => Ok(__FieldTag::__id),
3272                            "producer" => Ok(__FieldTag::__producer),
3273                            "first" => Ok(__FieldTag::__first),
3274                            "last" => Ok(__FieldTag::__last),
3275                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3276                        }
3277                    }
3278                }
3279                deserializer.deserialize_identifier(Visitor)
3280            }
3281        }
3282        struct Visitor;
3283        impl<'de> serde::de::Visitor<'de> for Visitor {
3284            type Value = LogEntryOperation;
3285            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3286                formatter.write_str("struct LogEntryOperation")
3287            }
3288            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3289            where
3290                A: serde::de::MapAccess<'de>,
3291            {
3292                #[allow(unused_imports)]
3293                use serde::de::Error;
3294                use std::option::Option::Some;
3295                let mut fields = std::collections::HashSet::new();
3296                let mut result = Self::Value::new();
3297                while let Some(tag) = map.next_key::<__FieldTag>()? {
3298                    #[allow(clippy::match_single_binding)]
3299                    match tag {
3300                        __FieldTag::__id => {
3301                            if !fields.insert(__FieldTag::__id) {
3302                                return std::result::Result::Err(A::Error::duplicate_field(
3303                                    "multiple values for id",
3304                                ));
3305                            }
3306                            result.id = map
3307                                .next_value::<std::option::Option<std::string::String>>()?
3308                                .unwrap_or_default();
3309                        }
3310                        __FieldTag::__producer => {
3311                            if !fields.insert(__FieldTag::__producer) {
3312                                return std::result::Result::Err(A::Error::duplicate_field(
3313                                    "multiple values for producer",
3314                                ));
3315                            }
3316                            result.producer = map
3317                                .next_value::<std::option::Option<std::string::String>>()?
3318                                .unwrap_or_default();
3319                        }
3320                        __FieldTag::__first => {
3321                            if !fields.insert(__FieldTag::__first) {
3322                                return std::result::Result::Err(A::Error::duplicate_field(
3323                                    "multiple values for first",
3324                                ));
3325                            }
3326                            result.first = map
3327                                .next_value::<std::option::Option<bool>>()?
3328                                .unwrap_or_default();
3329                        }
3330                        __FieldTag::__last => {
3331                            if !fields.insert(__FieldTag::__last) {
3332                                return std::result::Result::Err(A::Error::duplicate_field(
3333                                    "multiple values for last",
3334                                ));
3335                            }
3336                            result.last = map
3337                                .next_value::<std::option::Option<bool>>()?
3338                                .unwrap_or_default();
3339                        }
3340                        __FieldTag::Unknown(key) => {
3341                            let value = map.next_value::<serde_json::Value>()?;
3342                            result._unknown_fields.insert(key, value);
3343                        }
3344                    }
3345                }
3346                std::result::Result::Ok(result)
3347            }
3348        }
3349        deserializer.deserialize_any(Visitor)
3350    }
3351}
3352
3353#[doc(hidden)]
3354impl serde::ser::Serialize for LogEntryOperation {
3355    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3356    where
3357        S: serde::ser::Serializer,
3358    {
3359        use serde::ser::SerializeMap;
3360        #[allow(unused_imports)]
3361        use std::option::Option::Some;
3362        let mut state = serializer.serialize_map(std::option::Option::None)?;
3363        if !self.id.is_empty() {
3364            state.serialize_entry("id", &self.id)?;
3365        }
3366        if !self.producer.is_empty() {
3367            state.serialize_entry("producer", &self.producer)?;
3368        }
3369        if !wkt::internal::is_default(&self.first) {
3370            state.serialize_entry("first", &self.first)?;
3371        }
3372        if !wkt::internal::is_default(&self.last) {
3373            state.serialize_entry("last", &self.last)?;
3374        }
3375        if !self._unknown_fields.is_empty() {
3376            for (key, value) in self._unknown_fields.iter() {
3377                state.serialize_entry(key, &value)?;
3378            }
3379        }
3380        state.end()
3381    }
3382}
3383
3384impl std::fmt::Debug for LogEntryOperation {
3385    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3386        let mut debug_struct = f.debug_struct("LogEntryOperation");
3387        debug_struct.field("id", &self.id);
3388        debug_struct.field("producer", &self.producer);
3389        debug_struct.field("first", &self.first);
3390        debug_struct.field("last", &self.last);
3391        if !self._unknown_fields.is_empty() {
3392            debug_struct.field("_unknown_fields", &self._unknown_fields);
3393        }
3394        debug_struct.finish()
3395    }
3396}
3397
3398/// Additional information about the source code location that produced the log
3399/// entry.
3400#[derive(Clone, Default, PartialEq)]
3401#[non_exhaustive]
3402pub struct LogEntrySourceLocation {
3403    /// Optional. Source file name. Depending on the runtime environment, this
3404    /// might be a simple name or a fully-qualified name.
3405    pub file: std::string::String,
3406
3407    /// Optional. Line within the source file. 1-based; 0 indicates no line number
3408    /// available.
3409    pub line: i64,
3410
3411    /// Optional. Human-readable name of the function or method being invoked, with
3412    /// optional context such as the class or package name. This information may be
3413    /// used in contexts such as the logs viewer, where a file and line number are
3414    /// less meaningful. The format can vary by language. For example:
3415    /// `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function`
3416    /// (Python).
3417    pub function: std::string::String,
3418
3419    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3420}
3421
3422impl LogEntrySourceLocation {
3423    pub fn new() -> Self {
3424        std::default::Default::default()
3425    }
3426
3427    /// Sets the value of [file][crate::model::LogEntrySourceLocation::file].
3428    pub fn set_file<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3429        self.file = v.into();
3430        self
3431    }
3432
3433    /// Sets the value of [line][crate::model::LogEntrySourceLocation::line].
3434    pub fn set_line<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3435        self.line = v.into();
3436        self
3437    }
3438
3439    /// Sets the value of [function][crate::model::LogEntrySourceLocation::function].
3440    pub fn set_function<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3441        self.function = v.into();
3442        self
3443    }
3444}
3445
3446impl wkt::message::Message for LogEntrySourceLocation {
3447    fn typename() -> &'static str {
3448        "type.googleapis.com/google.api.servicecontrol.v1.LogEntrySourceLocation"
3449    }
3450}
3451
3452#[doc(hidden)]
3453impl<'de> serde::de::Deserialize<'de> for LogEntrySourceLocation {
3454    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3455    where
3456        D: serde::Deserializer<'de>,
3457    {
3458        #[allow(non_camel_case_types)]
3459        #[doc(hidden)]
3460        #[derive(PartialEq, Eq, Hash)]
3461        enum __FieldTag {
3462            __file,
3463            __line,
3464            __function,
3465            Unknown(std::string::String),
3466        }
3467        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3468            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3469            where
3470                D: serde::Deserializer<'de>,
3471            {
3472                struct Visitor;
3473                impl<'de> serde::de::Visitor<'de> for Visitor {
3474                    type Value = __FieldTag;
3475                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3476                        formatter.write_str("a field name for LogEntrySourceLocation")
3477                    }
3478                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3479                    where
3480                        E: serde::de::Error,
3481                    {
3482                        use std::result::Result::Ok;
3483                        use std::string::ToString;
3484                        match value {
3485                            "file" => Ok(__FieldTag::__file),
3486                            "line" => Ok(__FieldTag::__line),
3487                            "function" => Ok(__FieldTag::__function),
3488                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3489                        }
3490                    }
3491                }
3492                deserializer.deserialize_identifier(Visitor)
3493            }
3494        }
3495        struct Visitor;
3496        impl<'de> serde::de::Visitor<'de> for Visitor {
3497            type Value = LogEntrySourceLocation;
3498            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3499                formatter.write_str("struct LogEntrySourceLocation")
3500            }
3501            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3502            where
3503                A: serde::de::MapAccess<'de>,
3504            {
3505                #[allow(unused_imports)]
3506                use serde::de::Error;
3507                use std::option::Option::Some;
3508                let mut fields = std::collections::HashSet::new();
3509                let mut result = Self::Value::new();
3510                while let Some(tag) = map.next_key::<__FieldTag>()? {
3511                    #[allow(clippy::match_single_binding)]
3512                    match tag {
3513                        __FieldTag::__file => {
3514                            if !fields.insert(__FieldTag::__file) {
3515                                return std::result::Result::Err(A::Error::duplicate_field(
3516                                    "multiple values for file",
3517                                ));
3518                            }
3519                            result.file = map
3520                                .next_value::<std::option::Option<std::string::String>>()?
3521                                .unwrap_or_default();
3522                        }
3523                        __FieldTag::__line => {
3524                            if !fields.insert(__FieldTag::__line) {
3525                                return std::result::Result::Err(A::Error::duplicate_field(
3526                                    "multiple values for line",
3527                                ));
3528                            }
3529                            struct __With(std::option::Option<i64>);
3530                            impl<'de> serde::de::Deserialize<'de> for __With {
3531                                fn deserialize<D>(
3532                                    deserializer: D,
3533                                ) -> std::result::Result<Self, D::Error>
3534                                where
3535                                    D: serde::de::Deserializer<'de>,
3536                                {
3537                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
3538                                }
3539                            }
3540                            result.line = map.next_value::<__With>()?.0.unwrap_or_default();
3541                        }
3542                        __FieldTag::__function => {
3543                            if !fields.insert(__FieldTag::__function) {
3544                                return std::result::Result::Err(A::Error::duplicate_field(
3545                                    "multiple values for function",
3546                                ));
3547                            }
3548                            result.function = map
3549                                .next_value::<std::option::Option<std::string::String>>()?
3550                                .unwrap_or_default();
3551                        }
3552                        __FieldTag::Unknown(key) => {
3553                            let value = map.next_value::<serde_json::Value>()?;
3554                            result._unknown_fields.insert(key, value);
3555                        }
3556                    }
3557                }
3558                std::result::Result::Ok(result)
3559            }
3560        }
3561        deserializer.deserialize_any(Visitor)
3562    }
3563}
3564
3565#[doc(hidden)]
3566impl serde::ser::Serialize for LogEntrySourceLocation {
3567    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3568    where
3569        S: serde::ser::Serializer,
3570    {
3571        use serde::ser::SerializeMap;
3572        #[allow(unused_imports)]
3573        use std::option::Option::Some;
3574        let mut state = serializer.serialize_map(std::option::Option::None)?;
3575        if !self.file.is_empty() {
3576            state.serialize_entry("file", &self.file)?;
3577        }
3578        if !wkt::internal::is_default(&self.line) {
3579            struct __With<'a>(&'a i64);
3580            impl<'a> serde::ser::Serialize for __With<'a> {
3581                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3582                where
3583                    S: serde::ser::Serializer,
3584                {
3585                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
3586                }
3587            }
3588            state.serialize_entry("line", &__With(&self.line))?;
3589        }
3590        if !self.function.is_empty() {
3591            state.serialize_entry("function", &self.function)?;
3592        }
3593        if !self._unknown_fields.is_empty() {
3594            for (key, value) in self._unknown_fields.iter() {
3595                state.serialize_entry(key, &value)?;
3596            }
3597        }
3598        state.end()
3599    }
3600}
3601
3602impl std::fmt::Debug for LogEntrySourceLocation {
3603    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3604        let mut debug_struct = f.debug_struct("LogEntrySourceLocation");
3605        debug_struct.field("file", &self.file);
3606        debug_struct.field("line", &self.line);
3607        debug_struct.field("function", &self.function);
3608        if !self._unknown_fields.is_empty() {
3609            debug_struct.field("_unknown_fields", &self._unknown_fields);
3610        }
3611        debug_struct.finish()
3612    }
3613}
3614
3615/// Represents a single metric value.
3616#[derive(Clone, Default, PartialEq)]
3617#[non_exhaustive]
3618pub struct MetricValue {
3619    /// The labels describing the metric value.
3620    /// See comments on [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels] for
3621    /// the overriding relationship.
3622    /// Note that this map must not contain monitored resource labels.
3623    ///
3624    /// [google.api.servicecontrol.v1.Operation.labels]: crate::model::Operation::labels
3625    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
3626
3627    /// The start of the time period over which this metric value's measurement
3628    /// applies. The time period has different semantics for different metric
3629    /// types (cumulative, delta, and gauge). See the metric definition
3630    /// documentation in the service configuration for details. If not specified,
3631    /// [google.api.servicecontrol.v1.Operation.start_time][google.api.servicecontrol.v1.Operation.start_time] will be used.
3632    ///
3633    /// [google.api.servicecontrol.v1.Operation.start_time]: crate::model::Operation::start_time
3634    pub start_time: std::option::Option<wkt::Timestamp>,
3635
3636    /// The end of the time period over which this metric value's measurement
3637    /// applies.  If not specified,
3638    /// [google.api.servicecontrol.v1.Operation.end_time][google.api.servicecontrol.v1.Operation.end_time] will be used.
3639    ///
3640    /// [google.api.servicecontrol.v1.Operation.end_time]: crate::model::Operation::end_time
3641    pub end_time: std::option::Option<wkt::Timestamp>,
3642
3643    /// The value. The type of value used in the request must
3644    /// agree with the metric definition in the service configuration, otherwise
3645    /// the MetricValue is rejected.
3646    pub value: std::option::Option<crate::model::metric_value::Value>,
3647
3648    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3649}
3650
3651impl MetricValue {
3652    pub fn new() -> Self {
3653        std::default::Default::default()
3654    }
3655
3656    /// Sets the value of [labels][crate::model::MetricValue::labels].
3657    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
3658    where
3659        T: std::iter::IntoIterator<Item = (K, V)>,
3660        K: std::convert::Into<std::string::String>,
3661        V: std::convert::Into<std::string::String>,
3662    {
3663        use std::iter::Iterator;
3664        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3665        self
3666    }
3667
3668    /// Sets the value of [start_time][crate::model::MetricValue::start_time].
3669    pub fn set_start_time<T>(mut self, v: T) -> Self
3670    where
3671        T: std::convert::Into<wkt::Timestamp>,
3672    {
3673        self.start_time = std::option::Option::Some(v.into());
3674        self
3675    }
3676
3677    /// Sets or clears the value of [start_time][crate::model::MetricValue::start_time].
3678    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3679    where
3680        T: std::convert::Into<wkt::Timestamp>,
3681    {
3682        self.start_time = v.map(|x| x.into());
3683        self
3684    }
3685
3686    /// Sets the value of [end_time][crate::model::MetricValue::end_time].
3687    pub fn set_end_time<T>(mut self, v: T) -> Self
3688    where
3689        T: std::convert::Into<wkt::Timestamp>,
3690    {
3691        self.end_time = std::option::Option::Some(v.into());
3692        self
3693    }
3694
3695    /// Sets or clears the value of [end_time][crate::model::MetricValue::end_time].
3696    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
3697    where
3698        T: std::convert::Into<wkt::Timestamp>,
3699    {
3700        self.end_time = v.map(|x| x.into());
3701        self
3702    }
3703
3704    /// Sets the value of [value][crate::model::MetricValue::value].
3705    ///
3706    /// Note that all the setters affecting `value` are mutually
3707    /// exclusive.
3708    pub fn set_value<
3709        T: std::convert::Into<std::option::Option<crate::model::metric_value::Value>>,
3710    >(
3711        mut self,
3712        v: T,
3713    ) -> Self {
3714        self.value = v.into();
3715        self
3716    }
3717
3718    /// The value of [value][crate::model::MetricValue::value]
3719    /// if it holds a `BoolValue`, `None` if the field is not set or
3720    /// holds a different branch.
3721    pub fn bool_value(&self) -> std::option::Option<&bool> {
3722        #[allow(unreachable_patterns)]
3723        self.value.as_ref().and_then(|v| match v {
3724            crate::model::metric_value::Value::BoolValue(v) => std::option::Option::Some(v),
3725            _ => std::option::Option::None,
3726        })
3727    }
3728
3729    /// Sets the value of [value][crate::model::MetricValue::value]
3730    /// to hold a `BoolValue`.
3731    ///
3732    /// Note that all the setters affecting `value` are
3733    /// mutually exclusive.
3734    pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3735        self.value =
3736            std::option::Option::Some(crate::model::metric_value::Value::BoolValue(v.into()));
3737        self
3738    }
3739
3740    /// The value of [value][crate::model::MetricValue::value]
3741    /// if it holds a `Int64Value`, `None` if the field is not set or
3742    /// holds a different branch.
3743    pub fn int64_value(&self) -> std::option::Option<&i64> {
3744        #[allow(unreachable_patterns)]
3745        self.value.as_ref().and_then(|v| match v {
3746            crate::model::metric_value::Value::Int64Value(v) => std::option::Option::Some(v),
3747            _ => std::option::Option::None,
3748        })
3749    }
3750
3751    /// Sets the value of [value][crate::model::MetricValue::value]
3752    /// to hold a `Int64Value`.
3753    ///
3754    /// Note that all the setters affecting `value` are
3755    /// mutually exclusive.
3756    pub fn set_int64_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3757        self.value =
3758            std::option::Option::Some(crate::model::metric_value::Value::Int64Value(v.into()));
3759        self
3760    }
3761
3762    /// The value of [value][crate::model::MetricValue::value]
3763    /// if it holds a `DoubleValue`, `None` if the field is not set or
3764    /// holds a different branch.
3765    pub fn double_value(&self) -> std::option::Option<&f64> {
3766        #[allow(unreachable_patterns)]
3767        self.value.as_ref().and_then(|v| match v {
3768            crate::model::metric_value::Value::DoubleValue(v) => std::option::Option::Some(v),
3769            _ => std::option::Option::None,
3770        })
3771    }
3772
3773    /// Sets the value of [value][crate::model::MetricValue::value]
3774    /// to hold a `DoubleValue`.
3775    ///
3776    /// Note that all the setters affecting `value` are
3777    /// mutually exclusive.
3778    pub fn set_double_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3779        self.value =
3780            std::option::Option::Some(crate::model::metric_value::Value::DoubleValue(v.into()));
3781        self
3782    }
3783
3784    /// The value of [value][crate::model::MetricValue::value]
3785    /// if it holds a `StringValue`, `None` if the field is not set or
3786    /// holds a different branch.
3787    pub fn string_value(&self) -> std::option::Option<&std::string::String> {
3788        #[allow(unreachable_patterns)]
3789        self.value.as_ref().and_then(|v| match v {
3790            crate::model::metric_value::Value::StringValue(v) => std::option::Option::Some(v),
3791            _ => std::option::Option::None,
3792        })
3793    }
3794
3795    /// Sets the value of [value][crate::model::MetricValue::value]
3796    /// to hold a `StringValue`.
3797    ///
3798    /// Note that all the setters affecting `value` are
3799    /// mutually exclusive.
3800    pub fn set_string_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3801        self.value =
3802            std::option::Option::Some(crate::model::metric_value::Value::StringValue(v.into()));
3803        self
3804    }
3805
3806    /// The value of [value][crate::model::MetricValue::value]
3807    /// if it holds a `DistributionValue`, `None` if the field is not set or
3808    /// holds a different branch.
3809    pub fn distribution_value(
3810        &self,
3811    ) -> std::option::Option<&std::boxed::Box<crate::model::Distribution>> {
3812        #[allow(unreachable_patterns)]
3813        self.value.as_ref().and_then(|v| match v {
3814            crate::model::metric_value::Value::DistributionValue(v) => std::option::Option::Some(v),
3815            _ => std::option::Option::None,
3816        })
3817    }
3818
3819    /// Sets the value of [value][crate::model::MetricValue::value]
3820    /// to hold a `DistributionValue`.
3821    ///
3822    /// Note that all the setters affecting `value` are
3823    /// mutually exclusive.
3824    pub fn set_distribution_value<
3825        T: std::convert::Into<std::boxed::Box<crate::model::Distribution>>,
3826    >(
3827        mut self,
3828        v: T,
3829    ) -> Self {
3830        self.value = std::option::Option::Some(
3831            crate::model::metric_value::Value::DistributionValue(v.into()),
3832        );
3833        self
3834    }
3835}
3836
3837impl wkt::message::Message for MetricValue {
3838    fn typename() -> &'static str {
3839        "type.googleapis.com/google.api.servicecontrol.v1.MetricValue"
3840    }
3841}
3842
3843#[doc(hidden)]
3844impl<'de> serde::de::Deserialize<'de> for MetricValue {
3845    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3846    where
3847        D: serde::Deserializer<'de>,
3848    {
3849        #[allow(non_camel_case_types)]
3850        #[doc(hidden)]
3851        #[derive(PartialEq, Eq, Hash)]
3852        enum __FieldTag {
3853            __labels,
3854            __start_time,
3855            __end_time,
3856            __bool_value,
3857            __int64_value,
3858            __double_value,
3859            __string_value,
3860            __distribution_value,
3861            Unknown(std::string::String),
3862        }
3863        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3864            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3865            where
3866                D: serde::Deserializer<'de>,
3867            {
3868                struct Visitor;
3869                impl<'de> serde::de::Visitor<'de> for Visitor {
3870                    type Value = __FieldTag;
3871                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3872                        formatter.write_str("a field name for MetricValue")
3873                    }
3874                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3875                    where
3876                        E: serde::de::Error,
3877                    {
3878                        use std::result::Result::Ok;
3879                        use std::string::ToString;
3880                        match value {
3881                            "labels" => Ok(__FieldTag::__labels),
3882                            "startTime" => Ok(__FieldTag::__start_time),
3883                            "start_time" => Ok(__FieldTag::__start_time),
3884                            "endTime" => Ok(__FieldTag::__end_time),
3885                            "end_time" => Ok(__FieldTag::__end_time),
3886                            "boolValue" => Ok(__FieldTag::__bool_value),
3887                            "bool_value" => Ok(__FieldTag::__bool_value),
3888                            "int64Value" => Ok(__FieldTag::__int64_value),
3889                            "int64_value" => Ok(__FieldTag::__int64_value),
3890                            "doubleValue" => Ok(__FieldTag::__double_value),
3891                            "double_value" => Ok(__FieldTag::__double_value),
3892                            "stringValue" => Ok(__FieldTag::__string_value),
3893                            "string_value" => Ok(__FieldTag::__string_value),
3894                            "distributionValue" => Ok(__FieldTag::__distribution_value),
3895                            "distribution_value" => Ok(__FieldTag::__distribution_value),
3896                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3897                        }
3898                    }
3899                }
3900                deserializer.deserialize_identifier(Visitor)
3901            }
3902        }
3903        struct Visitor;
3904        impl<'de> serde::de::Visitor<'de> for Visitor {
3905            type Value = MetricValue;
3906            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3907                formatter.write_str("struct MetricValue")
3908            }
3909            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3910            where
3911                A: serde::de::MapAccess<'de>,
3912            {
3913                #[allow(unused_imports)]
3914                use serde::de::Error;
3915                use std::option::Option::Some;
3916                let mut fields = std::collections::HashSet::new();
3917                let mut result = Self::Value::new();
3918                while let Some(tag) = map.next_key::<__FieldTag>()? {
3919                    #[allow(clippy::match_single_binding)]
3920                    match tag {
3921                        __FieldTag::__labels => {
3922                            if !fields.insert(__FieldTag::__labels) {
3923                                return std::result::Result::Err(A::Error::duplicate_field(
3924                                    "multiple values for labels",
3925                                ));
3926                            }
3927                            result.labels = map
3928                                .next_value::<std::option::Option<
3929                                    std::collections::HashMap<
3930                                        std::string::String,
3931                                        std::string::String,
3932                                    >,
3933                                >>()?
3934                                .unwrap_or_default();
3935                        }
3936                        __FieldTag::__start_time => {
3937                            if !fields.insert(__FieldTag::__start_time) {
3938                                return std::result::Result::Err(A::Error::duplicate_field(
3939                                    "multiple values for start_time",
3940                                ));
3941                            }
3942                            result.start_time =
3943                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3944                        }
3945                        __FieldTag::__end_time => {
3946                            if !fields.insert(__FieldTag::__end_time) {
3947                                return std::result::Result::Err(A::Error::duplicate_field(
3948                                    "multiple values for end_time",
3949                                ));
3950                            }
3951                            result.end_time =
3952                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3953                        }
3954                        __FieldTag::__bool_value => {
3955                            if !fields.insert(__FieldTag::__bool_value) {
3956                                return std::result::Result::Err(A::Error::duplicate_field(
3957                                    "multiple values for bool_value",
3958                                ));
3959                            }
3960                            if result.value.is_some() {
3961                                return std::result::Result::Err(A::Error::duplicate_field(
3962                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.bool_value, latest field was boolValue",
3963                                ));
3964                            }
3965                            result.value = std::option::Option::Some(
3966                                crate::model::metric_value::Value::BoolValue(
3967                                    map.next_value::<std::option::Option<bool>>()?
3968                                        .unwrap_or_default(),
3969                                ),
3970                            );
3971                        }
3972                        __FieldTag::__int64_value => {
3973                            if !fields.insert(__FieldTag::__int64_value) {
3974                                return std::result::Result::Err(A::Error::duplicate_field(
3975                                    "multiple values for int64_value",
3976                                ));
3977                            }
3978                            struct __With(std::option::Option<i64>);
3979                            impl<'de> serde::de::Deserialize<'de> for __With {
3980                                fn deserialize<D>(
3981                                    deserializer: D,
3982                                ) -> std::result::Result<Self, D::Error>
3983                                where
3984                                    D: serde::de::Deserializer<'de>,
3985                                {
3986                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
3987                                }
3988                            }
3989                            if result.value.is_some() {
3990                                return std::result::Result::Err(A::Error::duplicate_field(
3991                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.int64_value, latest field was int64Value",
3992                                ));
3993                            }
3994                            result.value = std::option::Option::Some(
3995                                crate::model::metric_value::Value::Int64Value(
3996                                    map.next_value::<__With>()?.0.unwrap_or_default(),
3997                                ),
3998                            );
3999                        }
4000                        __FieldTag::__double_value => {
4001                            if !fields.insert(__FieldTag::__double_value) {
4002                                return std::result::Result::Err(A::Error::duplicate_field(
4003                                    "multiple values for double_value",
4004                                ));
4005                            }
4006                            struct __With(std::option::Option<f64>);
4007                            impl<'de> serde::de::Deserialize<'de> for __With {
4008                                fn deserialize<D>(
4009                                    deserializer: D,
4010                                ) -> std::result::Result<Self, D::Error>
4011                                where
4012                                    D: serde::de::Deserializer<'de>,
4013                                {
4014                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4015                                }
4016                            }
4017                            if result.value.is_some() {
4018                                return std::result::Result::Err(A::Error::duplicate_field(
4019                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.double_value, latest field was doubleValue",
4020                                ));
4021                            }
4022                            result.value = std::option::Option::Some(
4023                                crate::model::metric_value::Value::DoubleValue(
4024                                    map.next_value::<__With>()?.0.unwrap_or_default(),
4025                                ),
4026                            );
4027                        }
4028                        __FieldTag::__string_value => {
4029                            if !fields.insert(__FieldTag::__string_value) {
4030                                return std::result::Result::Err(A::Error::duplicate_field(
4031                                    "multiple values for string_value",
4032                                ));
4033                            }
4034                            if result.value.is_some() {
4035                                return std::result::Result::Err(A::Error::duplicate_field(
4036                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.string_value, latest field was stringValue",
4037                                ));
4038                            }
4039                            result.value = std::option::Option::Some(
4040                                crate::model::metric_value::Value::StringValue(
4041                                    map.next_value::<std::option::Option<std::string::String>>()?
4042                                        .unwrap_or_default(),
4043                                ),
4044                            );
4045                        }
4046                        __FieldTag::__distribution_value => {
4047                            if !fields.insert(__FieldTag::__distribution_value) {
4048                                return std::result::Result::Err(A::Error::duplicate_field(
4049                                    "multiple values for distribution_value",
4050                                ));
4051                            }
4052                            if result.value.is_some() {
4053                                return std::result::Result::Err(A::Error::duplicate_field(
4054                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.distribution_value, latest field was distributionValue",
4055                                ));
4056                            }
4057                            result.value = std::option::Option::Some(
4058                                crate::model::metric_value::Value::DistributionValue(
4059                                    map.next_value::<std::option::Option<
4060                                        std::boxed::Box<crate::model::Distribution>,
4061                                    >>()?
4062                                    .unwrap_or_default(),
4063                                ),
4064                            );
4065                        }
4066                        __FieldTag::Unknown(key) => {
4067                            let value = map.next_value::<serde_json::Value>()?;
4068                            result._unknown_fields.insert(key, value);
4069                        }
4070                    }
4071                }
4072                std::result::Result::Ok(result)
4073            }
4074        }
4075        deserializer.deserialize_any(Visitor)
4076    }
4077}
4078
4079#[doc(hidden)]
4080impl serde::ser::Serialize for MetricValue {
4081    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4082    where
4083        S: serde::ser::Serializer,
4084    {
4085        use serde::ser::SerializeMap;
4086        #[allow(unused_imports)]
4087        use std::option::Option::Some;
4088        let mut state = serializer.serialize_map(std::option::Option::None)?;
4089        if !self.labels.is_empty() {
4090            state.serialize_entry("labels", &self.labels)?;
4091        }
4092        if self.start_time.is_some() {
4093            state.serialize_entry("startTime", &self.start_time)?;
4094        }
4095        if self.end_time.is_some() {
4096            state.serialize_entry("endTime", &self.end_time)?;
4097        }
4098        if let Some(value) = self.bool_value() {
4099            state.serialize_entry("boolValue", value)?;
4100        }
4101        if let Some(value) = self.int64_value() {
4102            struct __With<'a>(&'a i64);
4103            impl<'a> serde::ser::Serialize for __With<'a> {
4104                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4105                where
4106                    S: serde::ser::Serializer,
4107                {
4108                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
4109                }
4110            }
4111            state.serialize_entry("int64Value", &__With(value))?;
4112        }
4113        if let Some(value) = self.double_value() {
4114            struct __With<'a>(&'a f64);
4115            impl<'a> serde::ser::Serialize for __With<'a> {
4116                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4117                where
4118                    S: serde::ser::Serializer,
4119                {
4120                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4121                }
4122            }
4123            state.serialize_entry("doubleValue", &__With(value))?;
4124        }
4125        if let Some(value) = self.string_value() {
4126            state.serialize_entry("stringValue", value)?;
4127        }
4128        if let Some(value) = self.distribution_value() {
4129            state.serialize_entry("distributionValue", value)?;
4130        }
4131        if !self._unknown_fields.is_empty() {
4132            for (key, value) in self._unknown_fields.iter() {
4133                state.serialize_entry(key, &value)?;
4134            }
4135        }
4136        state.end()
4137    }
4138}
4139
4140impl std::fmt::Debug for MetricValue {
4141    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4142        let mut debug_struct = f.debug_struct("MetricValue");
4143        debug_struct.field("labels", &self.labels);
4144        debug_struct.field("start_time", &self.start_time);
4145        debug_struct.field("end_time", &self.end_time);
4146        debug_struct.field("value", &self.value);
4147        if !self._unknown_fields.is_empty() {
4148            debug_struct.field("_unknown_fields", &self._unknown_fields);
4149        }
4150        debug_struct.finish()
4151    }
4152}
4153
4154/// Defines additional types related to [MetricValue].
4155pub mod metric_value {
4156    #[allow(unused_imports)]
4157    use super::*;
4158
4159    /// The value. The type of value used in the request must
4160    /// agree with the metric definition in the service configuration, otherwise
4161    /// the MetricValue is rejected.
4162    #[derive(Clone, Debug, PartialEq)]
4163    #[non_exhaustive]
4164    pub enum Value {
4165        /// A boolean value.
4166        BoolValue(bool),
4167        /// A signed 64-bit integer value.
4168        Int64Value(i64),
4169        /// A double precision floating point value.
4170        DoubleValue(f64),
4171        /// A text string value.
4172        StringValue(std::string::String),
4173        /// A distribution value.
4174        DistributionValue(std::boxed::Box<crate::model::Distribution>),
4175    }
4176}
4177
4178/// Represents a set of metric values in the same metric.
4179/// Each metric value in the set should have a unique combination of start time,
4180/// end time, and label values.
4181#[derive(Clone, Default, PartialEq)]
4182#[non_exhaustive]
4183pub struct MetricValueSet {
4184    /// The metric name defined in the service configuration.
4185    pub metric_name: std::string::String,
4186
4187    /// The values in this metric.
4188    pub metric_values: std::vec::Vec<crate::model::MetricValue>,
4189
4190    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4191}
4192
4193impl MetricValueSet {
4194    pub fn new() -> Self {
4195        std::default::Default::default()
4196    }
4197
4198    /// Sets the value of [metric_name][crate::model::MetricValueSet::metric_name].
4199    pub fn set_metric_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4200        self.metric_name = v.into();
4201        self
4202    }
4203
4204    /// Sets the value of [metric_values][crate::model::MetricValueSet::metric_values].
4205    pub fn set_metric_values<T, V>(mut self, v: T) -> Self
4206    where
4207        T: std::iter::IntoIterator<Item = V>,
4208        V: std::convert::Into<crate::model::MetricValue>,
4209    {
4210        use std::iter::Iterator;
4211        self.metric_values = v.into_iter().map(|i| i.into()).collect();
4212        self
4213    }
4214}
4215
4216impl wkt::message::Message for MetricValueSet {
4217    fn typename() -> &'static str {
4218        "type.googleapis.com/google.api.servicecontrol.v1.MetricValueSet"
4219    }
4220}
4221
4222#[doc(hidden)]
4223impl<'de> serde::de::Deserialize<'de> for MetricValueSet {
4224    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4225    where
4226        D: serde::Deserializer<'de>,
4227    {
4228        #[allow(non_camel_case_types)]
4229        #[doc(hidden)]
4230        #[derive(PartialEq, Eq, Hash)]
4231        enum __FieldTag {
4232            __metric_name,
4233            __metric_values,
4234            Unknown(std::string::String),
4235        }
4236        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4237            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4238            where
4239                D: serde::Deserializer<'de>,
4240            {
4241                struct Visitor;
4242                impl<'de> serde::de::Visitor<'de> for Visitor {
4243                    type Value = __FieldTag;
4244                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4245                        formatter.write_str("a field name for MetricValueSet")
4246                    }
4247                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4248                    where
4249                        E: serde::de::Error,
4250                    {
4251                        use std::result::Result::Ok;
4252                        use std::string::ToString;
4253                        match value {
4254                            "metricName" => Ok(__FieldTag::__metric_name),
4255                            "metric_name" => Ok(__FieldTag::__metric_name),
4256                            "metricValues" => Ok(__FieldTag::__metric_values),
4257                            "metric_values" => Ok(__FieldTag::__metric_values),
4258                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4259                        }
4260                    }
4261                }
4262                deserializer.deserialize_identifier(Visitor)
4263            }
4264        }
4265        struct Visitor;
4266        impl<'de> serde::de::Visitor<'de> for Visitor {
4267            type Value = MetricValueSet;
4268            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4269                formatter.write_str("struct MetricValueSet")
4270            }
4271            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4272            where
4273                A: serde::de::MapAccess<'de>,
4274            {
4275                #[allow(unused_imports)]
4276                use serde::de::Error;
4277                use std::option::Option::Some;
4278                let mut fields = std::collections::HashSet::new();
4279                let mut result = Self::Value::new();
4280                while let Some(tag) = map.next_key::<__FieldTag>()? {
4281                    #[allow(clippy::match_single_binding)]
4282                    match tag {
4283                        __FieldTag::__metric_name => {
4284                            if !fields.insert(__FieldTag::__metric_name) {
4285                                return std::result::Result::Err(A::Error::duplicate_field(
4286                                    "multiple values for metric_name",
4287                                ));
4288                            }
4289                            result.metric_name = map
4290                                .next_value::<std::option::Option<std::string::String>>()?
4291                                .unwrap_or_default();
4292                        }
4293                        __FieldTag::__metric_values => {
4294                            if !fields.insert(__FieldTag::__metric_values) {
4295                                return std::result::Result::Err(A::Error::duplicate_field(
4296                                    "multiple values for metric_values",
4297                                ));
4298                            }
4299                            result.metric_values = map.next_value::<std::option::Option<std::vec::Vec<crate::model::MetricValue>>>()?.unwrap_or_default();
4300                        }
4301                        __FieldTag::Unknown(key) => {
4302                            let value = map.next_value::<serde_json::Value>()?;
4303                            result._unknown_fields.insert(key, value);
4304                        }
4305                    }
4306                }
4307                std::result::Result::Ok(result)
4308            }
4309        }
4310        deserializer.deserialize_any(Visitor)
4311    }
4312}
4313
4314#[doc(hidden)]
4315impl serde::ser::Serialize for MetricValueSet {
4316    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4317    where
4318        S: serde::ser::Serializer,
4319    {
4320        use serde::ser::SerializeMap;
4321        #[allow(unused_imports)]
4322        use std::option::Option::Some;
4323        let mut state = serializer.serialize_map(std::option::Option::None)?;
4324        if !self.metric_name.is_empty() {
4325            state.serialize_entry("metricName", &self.metric_name)?;
4326        }
4327        if !self.metric_values.is_empty() {
4328            state.serialize_entry("metricValues", &self.metric_values)?;
4329        }
4330        if !self._unknown_fields.is_empty() {
4331            for (key, value) in self._unknown_fields.iter() {
4332                state.serialize_entry(key, &value)?;
4333            }
4334        }
4335        state.end()
4336    }
4337}
4338
4339impl std::fmt::Debug for MetricValueSet {
4340    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4341        let mut debug_struct = f.debug_struct("MetricValueSet");
4342        debug_struct.field("metric_name", &self.metric_name);
4343        debug_struct.field("metric_values", &self.metric_values);
4344        if !self._unknown_fields.is_empty() {
4345            debug_struct.field("_unknown_fields", &self._unknown_fields);
4346        }
4347        debug_struct.finish()
4348    }
4349}
4350
4351/// Represents information regarding an operation.
4352#[derive(Clone, Default, PartialEq)]
4353#[non_exhaustive]
4354pub struct Operation {
4355    /// Identity of the operation. This must be unique within the scope of the
4356    /// service that generated the operation. If the service calls
4357    /// Check() and Report() on the same operation, the two calls should carry
4358    /// the same id.
4359    ///
4360    /// UUID version 4 is recommended, though not required.
4361    /// In scenarios where an operation is computed from existing information
4362    /// and an idempotent id is desirable for deduplication purpose, UUID version 5
4363    /// is recommended. See RFC 4122 for details.
4364    pub operation_id: std::string::String,
4365
4366    /// Fully qualified name of the operation. Reserved for future use.
4367    pub operation_name: std::string::String,
4368
4369    /// Identity of the consumer who is using the service.
4370    /// This field should be filled in for the operations initiated by a
4371    /// consumer, but not for service-initiated operations that are
4372    /// not related to a specific consumer.
4373    ///
4374    /// - This can be in one of the following formats:
4375    ///   - project:PROJECT_ID,
4376    ///   - project`_`number:PROJECT_NUMBER,
4377    ///   - projects/PROJECT_ID or PROJECT_NUMBER,
4378    ///   - folders/FOLDER_NUMBER,
4379    ///   - organizations/ORGANIZATION_NUMBER,
4380    ///   - api`_`key:API_KEY.
4381    pub consumer_id: std::string::String,
4382
4383    /// Required. Start time of the operation.
4384    pub start_time: std::option::Option<wkt::Timestamp>,
4385
4386    /// End time of the operation.
4387    /// Required when the operation is used in
4388    /// [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report],
4389    /// but optional when the operation is used in
4390    /// [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check].
4391    ///
4392    /// [google.api.servicecontrol.v1.ServiceController.Check]: crate::client::ServiceController::check
4393    /// [google.api.servicecontrol.v1.ServiceController.Report]: crate::client::ServiceController::report
4394    pub end_time: std::option::Option<wkt::Timestamp>,
4395
4396    /// Labels describing the operation. Only the following labels are allowed:
4397    ///
4398    /// - Labels describing monitored resources as defined in
4399    ///   the service configuration.
4400    /// - Default labels of metric values. When specified, labels defined in the
4401    ///   metric value override these default.
4402    /// - The following labels defined by Google Cloud Platform:
4403    ///   - `cloud.googleapis.com/location` describing the location where the
4404    ///     operation happened,
4405    ///   - `servicecontrol.googleapis.com/user_agent` describing the user agent
4406    ///     of the API request,
4407    ///   - `servicecontrol.googleapis.com/service_agent` describing the service
4408    ///     used to handle the API request (e.g. ESP),
4409    ///   - `servicecontrol.googleapis.com/platform` describing the platform
4410    ///     where the API is served, such as App Engine, Compute Engine, or
4411    ///     Kubernetes Engine.
4412    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
4413
4414    /// Represents information about this operation. Each MetricValueSet
4415    /// corresponds to a metric defined in the service configuration.
4416    /// The data type used in the MetricValueSet must agree with
4417    /// the data type specified in the metric definition.
4418    ///
4419    /// Within a single operation, it is not allowed to have more than one
4420    /// MetricValue instances that have the same metric names and identical
4421    /// label value combinations. If a request has such duplicated MetricValue
4422    /// instances, the entire request is rejected with
4423    /// an invalid argument error.
4424    pub metric_value_sets: std::vec::Vec<crate::model::MetricValueSet>,
4425
4426    /// Represents information to be logged.
4427    pub log_entries: std::vec::Vec<crate::model::LogEntry>,
4428
4429    /// DO NOT USE. This is an experimental field.
4430    pub importance: crate::model::operation::Importance,
4431
4432    /// Unimplemented.
4433    pub extensions: std::vec::Vec<wkt::Any>,
4434
4435    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4436}
4437
4438impl Operation {
4439    pub fn new() -> Self {
4440        std::default::Default::default()
4441    }
4442
4443    /// Sets the value of [operation_id][crate::model::Operation::operation_id].
4444    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4445        self.operation_id = v.into();
4446        self
4447    }
4448
4449    /// Sets the value of [operation_name][crate::model::Operation::operation_name].
4450    pub fn set_operation_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4451        self.operation_name = v.into();
4452        self
4453    }
4454
4455    /// Sets the value of [consumer_id][crate::model::Operation::consumer_id].
4456    pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4457        self.consumer_id = v.into();
4458        self
4459    }
4460
4461    /// Sets the value of [start_time][crate::model::Operation::start_time].
4462    pub fn set_start_time<T>(mut self, v: T) -> Self
4463    where
4464        T: std::convert::Into<wkt::Timestamp>,
4465    {
4466        self.start_time = std::option::Option::Some(v.into());
4467        self
4468    }
4469
4470    /// Sets or clears the value of [start_time][crate::model::Operation::start_time].
4471    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
4472    where
4473        T: std::convert::Into<wkt::Timestamp>,
4474    {
4475        self.start_time = v.map(|x| x.into());
4476        self
4477    }
4478
4479    /// Sets the value of [end_time][crate::model::Operation::end_time].
4480    pub fn set_end_time<T>(mut self, v: T) -> Self
4481    where
4482        T: std::convert::Into<wkt::Timestamp>,
4483    {
4484        self.end_time = std::option::Option::Some(v.into());
4485        self
4486    }
4487
4488    /// Sets or clears the value of [end_time][crate::model::Operation::end_time].
4489    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
4490    where
4491        T: std::convert::Into<wkt::Timestamp>,
4492    {
4493        self.end_time = v.map(|x| x.into());
4494        self
4495    }
4496
4497    /// Sets the value of [labels][crate::model::Operation::labels].
4498    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
4499    where
4500        T: std::iter::IntoIterator<Item = (K, V)>,
4501        K: std::convert::Into<std::string::String>,
4502        V: std::convert::Into<std::string::String>,
4503    {
4504        use std::iter::Iterator;
4505        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4506        self
4507    }
4508
4509    /// Sets the value of [metric_value_sets][crate::model::Operation::metric_value_sets].
4510    pub fn set_metric_value_sets<T, V>(mut self, v: T) -> Self
4511    where
4512        T: std::iter::IntoIterator<Item = V>,
4513        V: std::convert::Into<crate::model::MetricValueSet>,
4514    {
4515        use std::iter::Iterator;
4516        self.metric_value_sets = v.into_iter().map(|i| i.into()).collect();
4517        self
4518    }
4519
4520    /// Sets the value of [log_entries][crate::model::Operation::log_entries].
4521    pub fn set_log_entries<T, V>(mut self, v: T) -> Self
4522    where
4523        T: std::iter::IntoIterator<Item = V>,
4524        V: std::convert::Into<crate::model::LogEntry>,
4525    {
4526        use std::iter::Iterator;
4527        self.log_entries = v.into_iter().map(|i| i.into()).collect();
4528        self
4529    }
4530
4531    /// Sets the value of [importance][crate::model::Operation::importance].
4532    pub fn set_importance<T: std::convert::Into<crate::model::operation::Importance>>(
4533        mut self,
4534        v: T,
4535    ) -> Self {
4536        self.importance = v.into();
4537        self
4538    }
4539
4540    /// Sets the value of [extensions][crate::model::Operation::extensions].
4541    pub fn set_extensions<T, V>(mut self, v: T) -> Self
4542    where
4543        T: std::iter::IntoIterator<Item = V>,
4544        V: std::convert::Into<wkt::Any>,
4545    {
4546        use std::iter::Iterator;
4547        self.extensions = v.into_iter().map(|i| i.into()).collect();
4548        self
4549    }
4550}
4551
4552impl wkt::message::Message for Operation {
4553    fn typename() -> &'static str {
4554        "type.googleapis.com/google.api.servicecontrol.v1.Operation"
4555    }
4556}
4557
4558#[doc(hidden)]
4559impl<'de> serde::de::Deserialize<'de> for Operation {
4560    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4561    where
4562        D: serde::Deserializer<'de>,
4563    {
4564        #[allow(non_camel_case_types)]
4565        #[doc(hidden)]
4566        #[derive(PartialEq, Eq, Hash)]
4567        enum __FieldTag {
4568            __operation_id,
4569            __operation_name,
4570            __consumer_id,
4571            __start_time,
4572            __end_time,
4573            __labels,
4574            __metric_value_sets,
4575            __log_entries,
4576            __importance,
4577            __extensions,
4578            Unknown(std::string::String),
4579        }
4580        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4581            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4582            where
4583                D: serde::Deserializer<'de>,
4584            {
4585                struct Visitor;
4586                impl<'de> serde::de::Visitor<'de> for Visitor {
4587                    type Value = __FieldTag;
4588                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4589                        formatter.write_str("a field name for Operation")
4590                    }
4591                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4592                    where
4593                        E: serde::de::Error,
4594                    {
4595                        use std::result::Result::Ok;
4596                        use std::string::ToString;
4597                        match value {
4598                            "operationId" => Ok(__FieldTag::__operation_id),
4599                            "operation_id" => Ok(__FieldTag::__operation_id),
4600                            "operationName" => Ok(__FieldTag::__operation_name),
4601                            "operation_name" => Ok(__FieldTag::__operation_name),
4602                            "consumerId" => Ok(__FieldTag::__consumer_id),
4603                            "consumer_id" => Ok(__FieldTag::__consumer_id),
4604                            "startTime" => Ok(__FieldTag::__start_time),
4605                            "start_time" => Ok(__FieldTag::__start_time),
4606                            "endTime" => Ok(__FieldTag::__end_time),
4607                            "end_time" => Ok(__FieldTag::__end_time),
4608                            "labels" => Ok(__FieldTag::__labels),
4609                            "metricValueSets" => Ok(__FieldTag::__metric_value_sets),
4610                            "metric_value_sets" => Ok(__FieldTag::__metric_value_sets),
4611                            "logEntries" => Ok(__FieldTag::__log_entries),
4612                            "log_entries" => Ok(__FieldTag::__log_entries),
4613                            "importance" => Ok(__FieldTag::__importance),
4614                            "extensions" => Ok(__FieldTag::__extensions),
4615                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4616                        }
4617                    }
4618                }
4619                deserializer.deserialize_identifier(Visitor)
4620            }
4621        }
4622        struct Visitor;
4623        impl<'de> serde::de::Visitor<'de> for Visitor {
4624            type Value = Operation;
4625            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4626                formatter.write_str("struct Operation")
4627            }
4628            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4629            where
4630                A: serde::de::MapAccess<'de>,
4631            {
4632                #[allow(unused_imports)]
4633                use serde::de::Error;
4634                use std::option::Option::Some;
4635                let mut fields = std::collections::HashSet::new();
4636                let mut result = Self::Value::new();
4637                while let Some(tag) = map.next_key::<__FieldTag>()? {
4638                    #[allow(clippy::match_single_binding)]
4639                    match tag {
4640                        __FieldTag::__operation_id => {
4641                            if !fields.insert(__FieldTag::__operation_id) {
4642                                return std::result::Result::Err(A::Error::duplicate_field(
4643                                    "multiple values for operation_id",
4644                                ));
4645                            }
4646                            result.operation_id = map
4647                                .next_value::<std::option::Option<std::string::String>>()?
4648                                .unwrap_or_default();
4649                        }
4650                        __FieldTag::__operation_name => {
4651                            if !fields.insert(__FieldTag::__operation_name) {
4652                                return std::result::Result::Err(A::Error::duplicate_field(
4653                                    "multiple values for operation_name",
4654                                ));
4655                            }
4656                            result.operation_name = map
4657                                .next_value::<std::option::Option<std::string::String>>()?
4658                                .unwrap_or_default();
4659                        }
4660                        __FieldTag::__consumer_id => {
4661                            if !fields.insert(__FieldTag::__consumer_id) {
4662                                return std::result::Result::Err(A::Error::duplicate_field(
4663                                    "multiple values for consumer_id",
4664                                ));
4665                            }
4666                            result.consumer_id = map
4667                                .next_value::<std::option::Option<std::string::String>>()?
4668                                .unwrap_or_default();
4669                        }
4670                        __FieldTag::__start_time => {
4671                            if !fields.insert(__FieldTag::__start_time) {
4672                                return std::result::Result::Err(A::Error::duplicate_field(
4673                                    "multiple values for start_time",
4674                                ));
4675                            }
4676                            result.start_time =
4677                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4678                        }
4679                        __FieldTag::__end_time => {
4680                            if !fields.insert(__FieldTag::__end_time) {
4681                                return std::result::Result::Err(A::Error::duplicate_field(
4682                                    "multiple values for end_time",
4683                                ));
4684                            }
4685                            result.end_time =
4686                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4687                        }
4688                        __FieldTag::__labels => {
4689                            if !fields.insert(__FieldTag::__labels) {
4690                                return std::result::Result::Err(A::Error::duplicate_field(
4691                                    "multiple values for labels",
4692                                ));
4693                            }
4694                            result.labels = map
4695                                .next_value::<std::option::Option<
4696                                    std::collections::HashMap<
4697                                        std::string::String,
4698                                        std::string::String,
4699                                    >,
4700                                >>()?
4701                                .unwrap_or_default();
4702                        }
4703                        __FieldTag::__metric_value_sets => {
4704                            if !fields.insert(__FieldTag::__metric_value_sets) {
4705                                return std::result::Result::Err(A::Error::duplicate_field(
4706                                    "multiple values for metric_value_sets",
4707                                ));
4708                            }
4709                            result.metric_value_sets =
4710                                map.next_value::<std::option::Option<
4711                                    std::vec::Vec<crate::model::MetricValueSet>,
4712                                >>()?
4713                                .unwrap_or_default();
4714                        }
4715                        __FieldTag::__log_entries => {
4716                            if !fields.insert(__FieldTag::__log_entries) {
4717                                return std::result::Result::Err(A::Error::duplicate_field(
4718                                    "multiple values for log_entries",
4719                                ));
4720                            }
4721                            result.log_entries = map.next_value::<std::option::Option<std::vec::Vec<crate::model::LogEntry>>>()?.unwrap_or_default();
4722                        }
4723                        __FieldTag::__importance => {
4724                            if !fields.insert(__FieldTag::__importance) {
4725                                return std::result::Result::Err(A::Error::duplicate_field(
4726                                    "multiple values for importance",
4727                                ));
4728                            }
4729                            result.importance = map.next_value::<std::option::Option<crate::model::operation::Importance>>()?.unwrap_or_default();
4730                        }
4731                        __FieldTag::__extensions => {
4732                            if !fields.insert(__FieldTag::__extensions) {
4733                                return std::result::Result::Err(A::Error::duplicate_field(
4734                                    "multiple values for extensions",
4735                                ));
4736                            }
4737                            result.extensions = map
4738                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
4739                                .unwrap_or_default();
4740                        }
4741                        __FieldTag::Unknown(key) => {
4742                            let value = map.next_value::<serde_json::Value>()?;
4743                            result._unknown_fields.insert(key, value);
4744                        }
4745                    }
4746                }
4747                std::result::Result::Ok(result)
4748            }
4749        }
4750        deserializer.deserialize_any(Visitor)
4751    }
4752}
4753
4754#[doc(hidden)]
4755impl serde::ser::Serialize for Operation {
4756    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4757    where
4758        S: serde::ser::Serializer,
4759    {
4760        use serde::ser::SerializeMap;
4761        #[allow(unused_imports)]
4762        use std::option::Option::Some;
4763        let mut state = serializer.serialize_map(std::option::Option::None)?;
4764        if !self.operation_id.is_empty() {
4765            state.serialize_entry("operationId", &self.operation_id)?;
4766        }
4767        if !self.operation_name.is_empty() {
4768            state.serialize_entry("operationName", &self.operation_name)?;
4769        }
4770        if !self.consumer_id.is_empty() {
4771            state.serialize_entry("consumerId", &self.consumer_id)?;
4772        }
4773        if self.start_time.is_some() {
4774            state.serialize_entry("startTime", &self.start_time)?;
4775        }
4776        if self.end_time.is_some() {
4777            state.serialize_entry("endTime", &self.end_time)?;
4778        }
4779        if !self.labels.is_empty() {
4780            state.serialize_entry("labels", &self.labels)?;
4781        }
4782        if !self.metric_value_sets.is_empty() {
4783            state.serialize_entry("metricValueSets", &self.metric_value_sets)?;
4784        }
4785        if !self.log_entries.is_empty() {
4786            state.serialize_entry("logEntries", &self.log_entries)?;
4787        }
4788        if !wkt::internal::is_default(&self.importance) {
4789            state.serialize_entry("importance", &self.importance)?;
4790        }
4791        if !self.extensions.is_empty() {
4792            state.serialize_entry("extensions", &self.extensions)?;
4793        }
4794        if !self._unknown_fields.is_empty() {
4795            for (key, value) in self._unknown_fields.iter() {
4796                state.serialize_entry(key, &value)?;
4797            }
4798        }
4799        state.end()
4800    }
4801}
4802
4803impl std::fmt::Debug for Operation {
4804    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4805        let mut debug_struct = f.debug_struct("Operation");
4806        debug_struct.field("operation_id", &self.operation_id);
4807        debug_struct.field("operation_name", &self.operation_name);
4808        debug_struct.field("consumer_id", &self.consumer_id);
4809        debug_struct.field("start_time", &self.start_time);
4810        debug_struct.field("end_time", &self.end_time);
4811        debug_struct.field("labels", &self.labels);
4812        debug_struct.field("metric_value_sets", &self.metric_value_sets);
4813        debug_struct.field("log_entries", &self.log_entries);
4814        debug_struct.field("importance", &self.importance);
4815        debug_struct.field("extensions", &self.extensions);
4816        if !self._unknown_fields.is_empty() {
4817            debug_struct.field("_unknown_fields", &self._unknown_fields);
4818        }
4819        debug_struct.finish()
4820    }
4821}
4822
4823/// Defines additional types related to [Operation].
4824pub mod operation {
4825    #[allow(unused_imports)]
4826    use super::*;
4827
4828    /// Defines the importance of the data contained in the operation.
4829    ///
4830    /// # Working with unknown values
4831    ///
4832    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4833    /// additional enum variants at any time. Adding new variants is not considered
4834    /// a breaking change. Applications should write their code in anticipation of:
4835    ///
4836    /// - New values appearing in future releases of the client library, **and**
4837    /// - New values received dynamically, without application changes.
4838    ///
4839    /// Please consult the [Working with enums] section in the user guide for some
4840    /// guidelines.
4841    ///
4842    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4843    #[derive(Clone, Debug, PartialEq)]
4844    #[non_exhaustive]
4845    pub enum Importance {
4846        /// Allows data caching, batching, and aggregation. It provides
4847        /// higher performance with higher data loss risk.
4848        Low,
4849        /// Disables data aggregation to minimize data loss. It is for operations
4850        /// that contains significant monetary value or audit trail. This feature
4851        /// only applies to the client libraries.
4852        High,
4853        /// If set, the enum was initialized with an unknown value.
4854        ///
4855        /// Applications can examine the value using [Importance::value] or
4856        /// [Importance::name].
4857        UnknownValue(importance::UnknownValue),
4858    }
4859
4860    #[doc(hidden)]
4861    pub mod importance {
4862        #[allow(unused_imports)]
4863        use super::*;
4864        #[derive(Clone, Debug, PartialEq)]
4865        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4866    }
4867
4868    impl Importance {
4869        /// Gets the enum value.
4870        ///
4871        /// Returns `None` if the enum contains an unknown value deserialized from
4872        /// the string representation of enums.
4873        pub fn value(&self) -> std::option::Option<i32> {
4874            match self {
4875                Self::Low => std::option::Option::Some(0),
4876                Self::High => std::option::Option::Some(1),
4877                Self::UnknownValue(u) => u.0.value(),
4878            }
4879        }
4880
4881        /// Gets the enum value as a string.
4882        ///
4883        /// Returns `None` if the enum contains an unknown value deserialized from
4884        /// the integer representation of enums.
4885        pub fn name(&self) -> std::option::Option<&str> {
4886            match self {
4887                Self::Low => std::option::Option::Some("LOW"),
4888                Self::High => std::option::Option::Some("HIGH"),
4889                Self::UnknownValue(u) => u.0.name(),
4890            }
4891        }
4892    }
4893
4894    impl std::default::Default for Importance {
4895        fn default() -> Self {
4896            use std::convert::From;
4897            Self::from(0)
4898        }
4899    }
4900
4901    impl std::fmt::Display for Importance {
4902        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4903            wkt::internal::display_enum(f, self.name(), self.value())
4904        }
4905    }
4906
4907    impl std::convert::From<i32> for Importance {
4908        fn from(value: i32) -> Self {
4909            match value {
4910                0 => Self::Low,
4911                1 => Self::High,
4912                _ => Self::UnknownValue(importance::UnknownValue(
4913                    wkt::internal::UnknownEnumValue::Integer(value),
4914                )),
4915            }
4916        }
4917    }
4918
4919    impl std::convert::From<&str> for Importance {
4920        fn from(value: &str) -> Self {
4921            use std::string::ToString;
4922            match value {
4923                "LOW" => Self::Low,
4924                "HIGH" => Self::High,
4925                _ => Self::UnknownValue(importance::UnknownValue(
4926                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4927                )),
4928            }
4929        }
4930    }
4931
4932    impl serde::ser::Serialize for Importance {
4933        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4934        where
4935            S: serde::Serializer,
4936        {
4937            match self {
4938                Self::Low => serializer.serialize_i32(0),
4939                Self::High => serializer.serialize_i32(1),
4940                Self::UnknownValue(u) => u.0.serialize(serializer),
4941            }
4942        }
4943    }
4944
4945    impl<'de> serde::de::Deserialize<'de> for Importance {
4946        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4947        where
4948            D: serde::Deserializer<'de>,
4949        {
4950            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Importance>::new(
4951                ".google.api.servicecontrol.v1.Operation.Importance",
4952            ))
4953        }
4954    }
4955}
4956
4957/// Request message for the AllocateQuota method.
4958#[derive(Clone, Default, PartialEq)]
4959#[non_exhaustive]
4960pub struct AllocateQuotaRequest {
4961    /// Name of the service as specified in the service configuration. For example,
4962    /// `"pubsub.googleapis.com"`.
4963    ///
4964    /// See [google.api.Service][google.api.Service] for the definition of a service name.
4965    pub service_name: std::string::String,
4966
4967    /// Operation that describes the quota allocation.
4968    pub allocate_operation: std::option::Option<crate::model::QuotaOperation>,
4969
4970    /// Specifies which version of service configuration should be used to process
4971    /// the request. If unspecified or no matching version can be found, the latest
4972    /// one will be used.
4973    pub service_config_id: std::string::String,
4974
4975    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4976}
4977
4978impl AllocateQuotaRequest {
4979    pub fn new() -> Self {
4980        std::default::Default::default()
4981    }
4982
4983    /// Sets the value of [service_name][crate::model::AllocateQuotaRequest::service_name].
4984    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4985        self.service_name = v.into();
4986        self
4987    }
4988
4989    /// Sets the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
4990    pub fn set_allocate_operation<T>(mut self, v: T) -> Self
4991    where
4992        T: std::convert::Into<crate::model::QuotaOperation>,
4993    {
4994        self.allocate_operation = std::option::Option::Some(v.into());
4995        self
4996    }
4997
4998    /// Sets or clears the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
4999    pub fn set_or_clear_allocate_operation<T>(mut self, v: std::option::Option<T>) -> Self
5000    where
5001        T: std::convert::Into<crate::model::QuotaOperation>,
5002    {
5003        self.allocate_operation = v.map(|x| x.into());
5004        self
5005    }
5006
5007    /// Sets the value of [service_config_id][crate::model::AllocateQuotaRequest::service_config_id].
5008    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
5009        mut self,
5010        v: T,
5011    ) -> Self {
5012        self.service_config_id = v.into();
5013        self
5014    }
5015}
5016
5017impl wkt::message::Message for AllocateQuotaRequest {
5018    fn typename() -> &'static str {
5019        "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaRequest"
5020    }
5021}
5022
5023#[doc(hidden)]
5024impl<'de> serde::de::Deserialize<'de> for AllocateQuotaRequest {
5025    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5026    where
5027        D: serde::Deserializer<'de>,
5028    {
5029        #[allow(non_camel_case_types)]
5030        #[doc(hidden)]
5031        #[derive(PartialEq, Eq, Hash)]
5032        enum __FieldTag {
5033            __service_name,
5034            __allocate_operation,
5035            __service_config_id,
5036            Unknown(std::string::String),
5037        }
5038        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5039            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5040            where
5041                D: serde::Deserializer<'de>,
5042            {
5043                struct Visitor;
5044                impl<'de> serde::de::Visitor<'de> for Visitor {
5045                    type Value = __FieldTag;
5046                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5047                        formatter.write_str("a field name for AllocateQuotaRequest")
5048                    }
5049                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5050                    where
5051                        E: serde::de::Error,
5052                    {
5053                        use std::result::Result::Ok;
5054                        use std::string::ToString;
5055                        match value {
5056                            "serviceName" => Ok(__FieldTag::__service_name),
5057                            "service_name" => Ok(__FieldTag::__service_name),
5058                            "allocateOperation" => Ok(__FieldTag::__allocate_operation),
5059                            "allocate_operation" => Ok(__FieldTag::__allocate_operation),
5060                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
5061                            "service_config_id" => Ok(__FieldTag::__service_config_id),
5062                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5063                        }
5064                    }
5065                }
5066                deserializer.deserialize_identifier(Visitor)
5067            }
5068        }
5069        struct Visitor;
5070        impl<'de> serde::de::Visitor<'de> for Visitor {
5071            type Value = AllocateQuotaRequest;
5072            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5073                formatter.write_str("struct AllocateQuotaRequest")
5074            }
5075            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5076            where
5077                A: serde::de::MapAccess<'de>,
5078            {
5079                #[allow(unused_imports)]
5080                use serde::de::Error;
5081                use std::option::Option::Some;
5082                let mut fields = std::collections::HashSet::new();
5083                let mut result = Self::Value::new();
5084                while let Some(tag) = map.next_key::<__FieldTag>()? {
5085                    #[allow(clippy::match_single_binding)]
5086                    match tag {
5087                        __FieldTag::__service_name => {
5088                            if !fields.insert(__FieldTag::__service_name) {
5089                                return std::result::Result::Err(A::Error::duplicate_field(
5090                                    "multiple values for service_name",
5091                                ));
5092                            }
5093                            result.service_name = map
5094                                .next_value::<std::option::Option<std::string::String>>()?
5095                                .unwrap_or_default();
5096                        }
5097                        __FieldTag::__allocate_operation => {
5098                            if !fields.insert(__FieldTag::__allocate_operation) {
5099                                return std::result::Result::Err(A::Error::duplicate_field(
5100                                    "multiple values for allocate_operation",
5101                                ));
5102                            }
5103                            result.allocate_operation = map
5104                                .next_value::<std::option::Option<crate::model::QuotaOperation>>(
5105                                )?;
5106                        }
5107                        __FieldTag::__service_config_id => {
5108                            if !fields.insert(__FieldTag::__service_config_id) {
5109                                return std::result::Result::Err(A::Error::duplicate_field(
5110                                    "multiple values for service_config_id",
5111                                ));
5112                            }
5113                            result.service_config_id = map
5114                                .next_value::<std::option::Option<std::string::String>>()?
5115                                .unwrap_or_default();
5116                        }
5117                        __FieldTag::Unknown(key) => {
5118                            let value = map.next_value::<serde_json::Value>()?;
5119                            result._unknown_fields.insert(key, value);
5120                        }
5121                    }
5122                }
5123                std::result::Result::Ok(result)
5124            }
5125        }
5126        deserializer.deserialize_any(Visitor)
5127    }
5128}
5129
5130#[doc(hidden)]
5131impl serde::ser::Serialize for AllocateQuotaRequest {
5132    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5133    where
5134        S: serde::ser::Serializer,
5135    {
5136        use serde::ser::SerializeMap;
5137        #[allow(unused_imports)]
5138        use std::option::Option::Some;
5139        let mut state = serializer.serialize_map(std::option::Option::None)?;
5140        if !self.service_name.is_empty() {
5141            state.serialize_entry("serviceName", &self.service_name)?;
5142        }
5143        if self.allocate_operation.is_some() {
5144            state.serialize_entry("allocateOperation", &self.allocate_operation)?;
5145        }
5146        if !self.service_config_id.is_empty() {
5147            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
5148        }
5149        if !self._unknown_fields.is_empty() {
5150            for (key, value) in self._unknown_fields.iter() {
5151                state.serialize_entry(key, &value)?;
5152            }
5153        }
5154        state.end()
5155    }
5156}
5157
5158impl std::fmt::Debug for AllocateQuotaRequest {
5159    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5160        let mut debug_struct = f.debug_struct("AllocateQuotaRequest");
5161        debug_struct.field("service_name", &self.service_name);
5162        debug_struct.field("allocate_operation", &self.allocate_operation);
5163        debug_struct.field("service_config_id", &self.service_config_id);
5164        if !self._unknown_fields.is_empty() {
5165            debug_struct.field("_unknown_fields", &self._unknown_fields);
5166        }
5167        debug_struct.finish()
5168    }
5169}
5170
5171/// Represents information regarding a quota operation.
5172#[derive(Clone, Default, PartialEq)]
5173#[non_exhaustive]
5174pub struct QuotaOperation {
5175    /// Identity of the operation. This is expected to be unique within the scope
5176    /// of the service that generated the operation, and guarantees idempotency in
5177    /// case of retries.
5178    ///
5179    /// In order to ensure best performance and latency in the Quota backends,
5180    /// operation_ids are optimally associated with time, so that related
5181    /// operations can be accessed fast in storage. For this reason, the
5182    /// recommended token for services that intend to operate at a high QPS is
5183    /// Unix time in nanos + UUID
5184    pub operation_id: std::string::String,
5185
5186    /// Fully qualified name of the API method for which this quota operation is
5187    /// requested. This name is used for matching quota rules or metric rules and
5188    /// billing status rules defined in service configuration.
5189    ///
5190    /// This field should not be set if any of the following is true:
5191    /// (1) the quota operation is performed on non-API resources.
5192    /// (2) quota_metrics is set because the caller is doing quota override.
5193    ///
5194    /// Example of an RPC method name:
5195    /// google.example.library.v1.LibraryService.CreateShelf
5196    pub method_name: std::string::String,
5197
5198    /// Identity of the consumer for whom this quota operation is being performed.
5199    ///
5200    /// This can be in one of the following formats:
5201    /// project:<project_id>,
5202    /// project_number:<project_number>,
5203    /// api_key:<api_key>.
5204    pub consumer_id: std::string::String,
5205
5206    /// Labels describing the operation.
5207    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
5208
5209    /// Represents information about this operation. Each MetricValueSet
5210    /// corresponds to a metric defined in the service configuration.
5211    /// The data type used in the MetricValueSet must agree with
5212    /// the data type specified in the metric definition.
5213    ///
5214    /// Within a single operation, it is not allowed to have more than one
5215    /// MetricValue instances that have the same metric names and identical
5216    /// label value combinations. If a request has such duplicated MetricValue
5217    /// instances, the entire request is rejected with
5218    /// an invalid argument error.
5219    ///
5220    /// This field is mutually exclusive with method_name.
5221    pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
5222
5223    /// Quota mode for this operation.
5224    pub quota_mode: crate::model::quota_operation::QuotaMode,
5225
5226    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5227}
5228
5229impl QuotaOperation {
5230    pub fn new() -> Self {
5231        std::default::Default::default()
5232    }
5233
5234    /// Sets the value of [operation_id][crate::model::QuotaOperation::operation_id].
5235    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5236        self.operation_id = v.into();
5237        self
5238    }
5239
5240    /// Sets the value of [method_name][crate::model::QuotaOperation::method_name].
5241    pub fn set_method_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5242        self.method_name = v.into();
5243        self
5244    }
5245
5246    /// Sets the value of [consumer_id][crate::model::QuotaOperation::consumer_id].
5247    pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5248        self.consumer_id = v.into();
5249        self
5250    }
5251
5252    /// Sets the value of [labels][crate::model::QuotaOperation::labels].
5253    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
5254    where
5255        T: std::iter::IntoIterator<Item = (K, V)>,
5256        K: std::convert::Into<std::string::String>,
5257        V: std::convert::Into<std::string::String>,
5258    {
5259        use std::iter::Iterator;
5260        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5261        self
5262    }
5263
5264    /// Sets the value of [quota_metrics][crate::model::QuotaOperation::quota_metrics].
5265    pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
5266    where
5267        T: std::iter::IntoIterator<Item = V>,
5268        V: std::convert::Into<crate::model::MetricValueSet>,
5269    {
5270        use std::iter::Iterator;
5271        self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
5272        self
5273    }
5274
5275    /// Sets the value of [quota_mode][crate::model::QuotaOperation::quota_mode].
5276    pub fn set_quota_mode<T: std::convert::Into<crate::model::quota_operation::QuotaMode>>(
5277        mut self,
5278        v: T,
5279    ) -> Self {
5280        self.quota_mode = v.into();
5281        self
5282    }
5283}
5284
5285impl wkt::message::Message for QuotaOperation {
5286    fn typename() -> &'static str {
5287        "type.googleapis.com/google.api.servicecontrol.v1.QuotaOperation"
5288    }
5289}
5290
5291#[doc(hidden)]
5292impl<'de> serde::de::Deserialize<'de> for QuotaOperation {
5293    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5294    where
5295        D: serde::Deserializer<'de>,
5296    {
5297        #[allow(non_camel_case_types)]
5298        #[doc(hidden)]
5299        #[derive(PartialEq, Eq, Hash)]
5300        enum __FieldTag {
5301            __operation_id,
5302            __method_name,
5303            __consumer_id,
5304            __labels,
5305            __quota_metrics,
5306            __quota_mode,
5307            Unknown(std::string::String),
5308        }
5309        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5310            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5311            where
5312                D: serde::Deserializer<'de>,
5313            {
5314                struct Visitor;
5315                impl<'de> serde::de::Visitor<'de> for Visitor {
5316                    type Value = __FieldTag;
5317                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5318                        formatter.write_str("a field name for QuotaOperation")
5319                    }
5320                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5321                    where
5322                        E: serde::de::Error,
5323                    {
5324                        use std::result::Result::Ok;
5325                        use std::string::ToString;
5326                        match value {
5327                            "operationId" => Ok(__FieldTag::__operation_id),
5328                            "operation_id" => Ok(__FieldTag::__operation_id),
5329                            "methodName" => Ok(__FieldTag::__method_name),
5330                            "method_name" => Ok(__FieldTag::__method_name),
5331                            "consumerId" => Ok(__FieldTag::__consumer_id),
5332                            "consumer_id" => Ok(__FieldTag::__consumer_id),
5333                            "labels" => Ok(__FieldTag::__labels),
5334                            "quotaMetrics" => Ok(__FieldTag::__quota_metrics),
5335                            "quota_metrics" => Ok(__FieldTag::__quota_metrics),
5336                            "quotaMode" => Ok(__FieldTag::__quota_mode),
5337                            "quota_mode" => Ok(__FieldTag::__quota_mode),
5338                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5339                        }
5340                    }
5341                }
5342                deserializer.deserialize_identifier(Visitor)
5343            }
5344        }
5345        struct Visitor;
5346        impl<'de> serde::de::Visitor<'de> for Visitor {
5347            type Value = QuotaOperation;
5348            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5349                formatter.write_str("struct QuotaOperation")
5350            }
5351            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5352            where
5353                A: serde::de::MapAccess<'de>,
5354            {
5355                #[allow(unused_imports)]
5356                use serde::de::Error;
5357                use std::option::Option::Some;
5358                let mut fields = std::collections::HashSet::new();
5359                let mut result = Self::Value::new();
5360                while let Some(tag) = map.next_key::<__FieldTag>()? {
5361                    #[allow(clippy::match_single_binding)]
5362                    match tag {
5363                        __FieldTag::__operation_id => {
5364                            if !fields.insert(__FieldTag::__operation_id) {
5365                                return std::result::Result::Err(A::Error::duplicate_field(
5366                                    "multiple values for operation_id",
5367                                ));
5368                            }
5369                            result.operation_id = map
5370                                .next_value::<std::option::Option<std::string::String>>()?
5371                                .unwrap_or_default();
5372                        }
5373                        __FieldTag::__method_name => {
5374                            if !fields.insert(__FieldTag::__method_name) {
5375                                return std::result::Result::Err(A::Error::duplicate_field(
5376                                    "multiple values for method_name",
5377                                ));
5378                            }
5379                            result.method_name = map
5380                                .next_value::<std::option::Option<std::string::String>>()?
5381                                .unwrap_or_default();
5382                        }
5383                        __FieldTag::__consumer_id => {
5384                            if !fields.insert(__FieldTag::__consumer_id) {
5385                                return std::result::Result::Err(A::Error::duplicate_field(
5386                                    "multiple values for consumer_id",
5387                                ));
5388                            }
5389                            result.consumer_id = map
5390                                .next_value::<std::option::Option<std::string::String>>()?
5391                                .unwrap_or_default();
5392                        }
5393                        __FieldTag::__labels => {
5394                            if !fields.insert(__FieldTag::__labels) {
5395                                return std::result::Result::Err(A::Error::duplicate_field(
5396                                    "multiple values for labels",
5397                                ));
5398                            }
5399                            result.labels = map
5400                                .next_value::<std::option::Option<
5401                                    std::collections::HashMap<
5402                                        std::string::String,
5403                                        std::string::String,
5404                                    >,
5405                                >>()?
5406                                .unwrap_or_default();
5407                        }
5408                        __FieldTag::__quota_metrics => {
5409                            if !fields.insert(__FieldTag::__quota_metrics) {
5410                                return std::result::Result::Err(A::Error::duplicate_field(
5411                                    "multiple values for quota_metrics",
5412                                ));
5413                            }
5414                            result.quota_metrics =
5415                                map.next_value::<std::option::Option<
5416                                    std::vec::Vec<crate::model::MetricValueSet>,
5417                                >>()?
5418                                .unwrap_or_default();
5419                        }
5420                        __FieldTag::__quota_mode => {
5421                            if !fields.insert(__FieldTag::__quota_mode) {
5422                                return std::result::Result::Err(A::Error::duplicate_field(
5423                                    "multiple values for quota_mode",
5424                                ));
5425                            }
5426                            result.quota_mode = map.next_value::<std::option::Option<crate::model::quota_operation::QuotaMode>>()?.unwrap_or_default();
5427                        }
5428                        __FieldTag::Unknown(key) => {
5429                            let value = map.next_value::<serde_json::Value>()?;
5430                            result._unknown_fields.insert(key, value);
5431                        }
5432                    }
5433                }
5434                std::result::Result::Ok(result)
5435            }
5436        }
5437        deserializer.deserialize_any(Visitor)
5438    }
5439}
5440
5441#[doc(hidden)]
5442impl serde::ser::Serialize for QuotaOperation {
5443    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5444    where
5445        S: serde::ser::Serializer,
5446    {
5447        use serde::ser::SerializeMap;
5448        #[allow(unused_imports)]
5449        use std::option::Option::Some;
5450        let mut state = serializer.serialize_map(std::option::Option::None)?;
5451        if !self.operation_id.is_empty() {
5452            state.serialize_entry("operationId", &self.operation_id)?;
5453        }
5454        if !self.method_name.is_empty() {
5455            state.serialize_entry("methodName", &self.method_name)?;
5456        }
5457        if !self.consumer_id.is_empty() {
5458            state.serialize_entry("consumerId", &self.consumer_id)?;
5459        }
5460        if !self.labels.is_empty() {
5461            state.serialize_entry("labels", &self.labels)?;
5462        }
5463        if !self.quota_metrics.is_empty() {
5464            state.serialize_entry("quotaMetrics", &self.quota_metrics)?;
5465        }
5466        if !wkt::internal::is_default(&self.quota_mode) {
5467            state.serialize_entry("quotaMode", &self.quota_mode)?;
5468        }
5469        if !self._unknown_fields.is_empty() {
5470            for (key, value) in self._unknown_fields.iter() {
5471                state.serialize_entry(key, &value)?;
5472            }
5473        }
5474        state.end()
5475    }
5476}
5477
5478impl std::fmt::Debug for QuotaOperation {
5479    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5480        let mut debug_struct = f.debug_struct("QuotaOperation");
5481        debug_struct.field("operation_id", &self.operation_id);
5482        debug_struct.field("method_name", &self.method_name);
5483        debug_struct.field("consumer_id", &self.consumer_id);
5484        debug_struct.field("labels", &self.labels);
5485        debug_struct.field("quota_metrics", &self.quota_metrics);
5486        debug_struct.field("quota_mode", &self.quota_mode);
5487        if !self._unknown_fields.is_empty() {
5488            debug_struct.field("_unknown_fields", &self._unknown_fields);
5489        }
5490        debug_struct.finish()
5491    }
5492}
5493
5494/// Defines additional types related to [QuotaOperation].
5495pub mod quota_operation {
5496    #[allow(unused_imports)]
5497    use super::*;
5498
5499    /// Supported quota modes.
5500    ///
5501    /// # Working with unknown values
5502    ///
5503    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5504    /// additional enum variants at any time. Adding new variants is not considered
5505    /// a breaking change. Applications should write their code in anticipation of:
5506    ///
5507    /// - New values appearing in future releases of the client library, **and**
5508    /// - New values received dynamically, without application changes.
5509    ///
5510    /// Please consult the [Working with enums] section in the user guide for some
5511    /// guidelines.
5512    ///
5513    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
5514    #[derive(Clone, Debug, PartialEq)]
5515    #[non_exhaustive]
5516    pub enum QuotaMode {
5517        /// Guard against implicit default. Must not be used.
5518        Unspecified,
5519        /// For AllocateQuota request, allocates quota for the amount specified in
5520        /// the service configuration or specified using the quota metrics. If the
5521        /// amount is higher than the available quota, allocation error will be
5522        /// returned and no quota will be allocated.
5523        /// If multiple quotas are part of the request, and one fails, none of the
5524        /// quotas are allocated or released.
5525        Normal,
5526        /// The operation allocates quota for the amount specified in the service
5527        /// configuration or specified using the quota metrics. If the amount is
5528        /// higher than the available quota, request does not fail but all available
5529        /// quota will be allocated.
5530        /// For rate quota, BEST_EFFORT will continue to deduct from other groups
5531        /// even if one does not have enough quota. For allocation, it will find the
5532        /// minimum available amount across all groups and deduct that amount from
5533        /// all the affected groups.
5534        BestEffort,
5535        /// For AllocateQuota request, only checks if there is enough quota
5536        /// available and does not change the available quota. No lock is placed on
5537        /// the available quota either.
5538        CheckOnly,
5539        /// Unimplemented. When used in AllocateQuotaRequest, this returns the
5540        /// effective quota limit(s) in the response, and no quota check will be
5541        /// performed. Not supported for other requests, and even for
5542        /// AllocateQuotaRequest, this is currently supported only for allowlisted
5543        /// services.
5544        QueryOnly,
5545        /// The operation allocates quota for the amount specified in the service
5546        /// configuration or specified using the quota metrics. If the requested
5547        /// amount is higher than the available quota, request does not fail and
5548        /// remaining quota would become negative (going over the limit).
5549        /// Not supported for Rate Quota.
5550        AdjustOnly,
5551        /// If set, the enum was initialized with an unknown value.
5552        ///
5553        /// Applications can examine the value using [QuotaMode::value] or
5554        /// [QuotaMode::name].
5555        UnknownValue(quota_mode::UnknownValue),
5556    }
5557
5558    #[doc(hidden)]
5559    pub mod quota_mode {
5560        #[allow(unused_imports)]
5561        use super::*;
5562        #[derive(Clone, Debug, PartialEq)]
5563        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5564    }
5565
5566    impl QuotaMode {
5567        /// Gets the enum value.
5568        ///
5569        /// Returns `None` if the enum contains an unknown value deserialized from
5570        /// the string representation of enums.
5571        pub fn value(&self) -> std::option::Option<i32> {
5572            match self {
5573                Self::Unspecified => std::option::Option::Some(0),
5574                Self::Normal => std::option::Option::Some(1),
5575                Self::BestEffort => std::option::Option::Some(2),
5576                Self::CheckOnly => std::option::Option::Some(3),
5577                Self::QueryOnly => std::option::Option::Some(4),
5578                Self::AdjustOnly => std::option::Option::Some(5),
5579                Self::UnknownValue(u) => u.0.value(),
5580            }
5581        }
5582
5583        /// Gets the enum value as a string.
5584        ///
5585        /// Returns `None` if the enum contains an unknown value deserialized from
5586        /// the integer representation of enums.
5587        pub fn name(&self) -> std::option::Option<&str> {
5588            match self {
5589                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
5590                Self::Normal => std::option::Option::Some("NORMAL"),
5591                Self::BestEffort => std::option::Option::Some("BEST_EFFORT"),
5592                Self::CheckOnly => std::option::Option::Some("CHECK_ONLY"),
5593                Self::QueryOnly => std::option::Option::Some("QUERY_ONLY"),
5594                Self::AdjustOnly => std::option::Option::Some("ADJUST_ONLY"),
5595                Self::UnknownValue(u) => u.0.name(),
5596            }
5597        }
5598    }
5599
5600    impl std::default::Default for QuotaMode {
5601        fn default() -> Self {
5602            use std::convert::From;
5603            Self::from(0)
5604        }
5605    }
5606
5607    impl std::fmt::Display for QuotaMode {
5608        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5609            wkt::internal::display_enum(f, self.name(), self.value())
5610        }
5611    }
5612
5613    impl std::convert::From<i32> for QuotaMode {
5614        fn from(value: i32) -> Self {
5615            match value {
5616                0 => Self::Unspecified,
5617                1 => Self::Normal,
5618                2 => Self::BestEffort,
5619                3 => Self::CheckOnly,
5620                4 => Self::QueryOnly,
5621                5 => Self::AdjustOnly,
5622                _ => Self::UnknownValue(quota_mode::UnknownValue(
5623                    wkt::internal::UnknownEnumValue::Integer(value),
5624                )),
5625            }
5626        }
5627    }
5628
5629    impl std::convert::From<&str> for QuotaMode {
5630        fn from(value: &str) -> Self {
5631            use std::string::ToString;
5632            match value {
5633                "UNSPECIFIED" => Self::Unspecified,
5634                "NORMAL" => Self::Normal,
5635                "BEST_EFFORT" => Self::BestEffort,
5636                "CHECK_ONLY" => Self::CheckOnly,
5637                "QUERY_ONLY" => Self::QueryOnly,
5638                "ADJUST_ONLY" => Self::AdjustOnly,
5639                _ => Self::UnknownValue(quota_mode::UnknownValue(
5640                    wkt::internal::UnknownEnumValue::String(value.to_string()),
5641                )),
5642            }
5643        }
5644    }
5645
5646    impl serde::ser::Serialize for QuotaMode {
5647        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5648        where
5649            S: serde::Serializer,
5650        {
5651            match self {
5652                Self::Unspecified => serializer.serialize_i32(0),
5653                Self::Normal => serializer.serialize_i32(1),
5654                Self::BestEffort => serializer.serialize_i32(2),
5655                Self::CheckOnly => serializer.serialize_i32(3),
5656                Self::QueryOnly => serializer.serialize_i32(4),
5657                Self::AdjustOnly => serializer.serialize_i32(5),
5658                Self::UnknownValue(u) => u.0.serialize(serializer),
5659            }
5660        }
5661    }
5662
5663    impl<'de> serde::de::Deserialize<'de> for QuotaMode {
5664        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5665        where
5666            D: serde::Deserializer<'de>,
5667        {
5668            deserializer.deserialize_any(wkt::internal::EnumVisitor::<QuotaMode>::new(
5669                ".google.api.servicecontrol.v1.QuotaOperation.QuotaMode",
5670            ))
5671        }
5672    }
5673}
5674
5675/// Response message for the AllocateQuota method.
5676#[derive(Clone, Default, PartialEq)]
5677#[non_exhaustive]
5678pub struct AllocateQuotaResponse {
5679    /// The same operation_id value used in the AllocateQuotaRequest. Used for
5680    /// logging and diagnostics purposes.
5681    pub operation_id: std::string::String,
5682
5683    /// Indicates the decision of the allocate.
5684    pub allocate_errors: std::vec::Vec<crate::model::QuotaError>,
5685
5686    /// Quota metrics to indicate the result of allocation. Depending on the
5687    /// request, one or more of the following metrics will be included:
5688    ///
5689    /// 1. Per quota group or per quota metric incremental usage will be specified
5690    ///    using the following delta metric :
5691    ///    "serviceruntime.googleapis.com/api/consumer/quota_used_count"
5692    ///
5693    /// 1. The quota limit reached condition will be specified using the following
5694    ///    boolean metric :
5695    ///    "serviceruntime.googleapis.com/quota/exceeded"
5696    ///
5697    pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
5698
5699    /// ID of the actual config used to process the request.
5700    pub service_config_id: std::string::String,
5701
5702    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5703}
5704
5705impl AllocateQuotaResponse {
5706    pub fn new() -> Self {
5707        std::default::Default::default()
5708    }
5709
5710    /// Sets the value of [operation_id][crate::model::AllocateQuotaResponse::operation_id].
5711    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5712        self.operation_id = v.into();
5713        self
5714    }
5715
5716    /// Sets the value of [allocate_errors][crate::model::AllocateQuotaResponse::allocate_errors].
5717    pub fn set_allocate_errors<T, V>(mut self, v: T) -> Self
5718    where
5719        T: std::iter::IntoIterator<Item = V>,
5720        V: std::convert::Into<crate::model::QuotaError>,
5721    {
5722        use std::iter::Iterator;
5723        self.allocate_errors = v.into_iter().map(|i| i.into()).collect();
5724        self
5725    }
5726
5727    /// Sets the value of [quota_metrics][crate::model::AllocateQuotaResponse::quota_metrics].
5728    pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
5729    where
5730        T: std::iter::IntoIterator<Item = V>,
5731        V: std::convert::Into<crate::model::MetricValueSet>,
5732    {
5733        use std::iter::Iterator;
5734        self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
5735        self
5736    }
5737
5738    /// Sets the value of [service_config_id][crate::model::AllocateQuotaResponse::service_config_id].
5739    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
5740        mut self,
5741        v: T,
5742    ) -> Self {
5743        self.service_config_id = v.into();
5744        self
5745    }
5746}
5747
5748impl wkt::message::Message for AllocateQuotaResponse {
5749    fn typename() -> &'static str {
5750        "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaResponse"
5751    }
5752}
5753
5754#[doc(hidden)]
5755impl<'de> serde::de::Deserialize<'de> for AllocateQuotaResponse {
5756    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5757    where
5758        D: serde::Deserializer<'de>,
5759    {
5760        #[allow(non_camel_case_types)]
5761        #[doc(hidden)]
5762        #[derive(PartialEq, Eq, Hash)]
5763        enum __FieldTag {
5764            __operation_id,
5765            __allocate_errors,
5766            __quota_metrics,
5767            __service_config_id,
5768            Unknown(std::string::String),
5769        }
5770        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5771            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5772            where
5773                D: serde::Deserializer<'de>,
5774            {
5775                struct Visitor;
5776                impl<'de> serde::de::Visitor<'de> for Visitor {
5777                    type Value = __FieldTag;
5778                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5779                        formatter.write_str("a field name for AllocateQuotaResponse")
5780                    }
5781                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5782                    where
5783                        E: serde::de::Error,
5784                    {
5785                        use std::result::Result::Ok;
5786                        use std::string::ToString;
5787                        match value {
5788                            "operationId" => Ok(__FieldTag::__operation_id),
5789                            "operation_id" => Ok(__FieldTag::__operation_id),
5790                            "allocateErrors" => Ok(__FieldTag::__allocate_errors),
5791                            "allocate_errors" => Ok(__FieldTag::__allocate_errors),
5792                            "quotaMetrics" => Ok(__FieldTag::__quota_metrics),
5793                            "quota_metrics" => Ok(__FieldTag::__quota_metrics),
5794                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
5795                            "service_config_id" => Ok(__FieldTag::__service_config_id),
5796                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5797                        }
5798                    }
5799                }
5800                deserializer.deserialize_identifier(Visitor)
5801            }
5802        }
5803        struct Visitor;
5804        impl<'de> serde::de::Visitor<'de> for Visitor {
5805            type Value = AllocateQuotaResponse;
5806            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5807                formatter.write_str("struct AllocateQuotaResponse")
5808            }
5809            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5810            where
5811                A: serde::de::MapAccess<'de>,
5812            {
5813                #[allow(unused_imports)]
5814                use serde::de::Error;
5815                use std::option::Option::Some;
5816                let mut fields = std::collections::HashSet::new();
5817                let mut result = Self::Value::new();
5818                while let Some(tag) = map.next_key::<__FieldTag>()? {
5819                    #[allow(clippy::match_single_binding)]
5820                    match tag {
5821                        __FieldTag::__operation_id => {
5822                            if !fields.insert(__FieldTag::__operation_id) {
5823                                return std::result::Result::Err(A::Error::duplicate_field(
5824                                    "multiple values for operation_id",
5825                                ));
5826                            }
5827                            result.operation_id = map
5828                                .next_value::<std::option::Option<std::string::String>>()?
5829                                .unwrap_or_default();
5830                        }
5831                        __FieldTag::__allocate_errors => {
5832                            if !fields.insert(__FieldTag::__allocate_errors) {
5833                                return std::result::Result::Err(A::Error::duplicate_field(
5834                                    "multiple values for allocate_errors",
5835                                ));
5836                            }
5837                            result.allocate_errors = map.next_value::<std::option::Option<std::vec::Vec<crate::model::QuotaError>>>()?.unwrap_or_default();
5838                        }
5839                        __FieldTag::__quota_metrics => {
5840                            if !fields.insert(__FieldTag::__quota_metrics) {
5841                                return std::result::Result::Err(A::Error::duplicate_field(
5842                                    "multiple values for quota_metrics",
5843                                ));
5844                            }
5845                            result.quota_metrics =
5846                                map.next_value::<std::option::Option<
5847                                    std::vec::Vec<crate::model::MetricValueSet>,
5848                                >>()?
5849                                .unwrap_or_default();
5850                        }
5851                        __FieldTag::__service_config_id => {
5852                            if !fields.insert(__FieldTag::__service_config_id) {
5853                                return std::result::Result::Err(A::Error::duplicate_field(
5854                                    "multiple values for service_config_id",
5855                                ));
5856                            }
5857                            result.service_config_id = map
5858                                .next_value::<std::option::Option<std::string::String>>()?
5859                                .unwrap_or_default();
5860                        }
5861                        __FieldTag::Unknown(key) => {
5862                            let value = map.next_value::<serde_json::Value>()?;
5863                            result._unknown_fields.insert(key, value);
5864                        }
5865                    }
5866                }
5867                std::result::Result::Ok(result)
5868            }
5869        }
5870        deserializer.deserialize_any(Visitor)
5871    }
5872}
5873
5874#[doc(hidden)]
5875impl serde::ser::Serialize for AllocateQuotaResponse {
5876    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5877    where
5878        S: serde::ser::Serializer,
5879    {
5880        use serde::ser::SerializeMap;
5881        #[allow(unused_imports)]
5882        use std::option::Option::Some;
5883        let mut state = serializer.serialize_map(std::option::Option::None)?;
5884        if !self.operation_id.is_empty() {
5885            state.serialize_entry("operationId", &self.operation_id)?;
5886        }
5887        if !self.allocate_errors.is_empty() {
5888            state.serialize_entry("allocateErrors", &self.allocate_errors)?;
5889        }
5890        if !self.quota_metrics.is_empty() {
5891            state.serialize_entry("quotaMetrics", &self.quota_metrics)?;
5892        }
5893        if !self.service_config_id.is_empty() {
5894            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
5895        }
5896        if !self._unknown_fields.is_empty() {
5897            for (key, value) in self._unknown_fields.iter() {
5898                state.serialize_entry(key, &value)?;
5899            }
5900        }
5901        state.end()
5902    }
5903}
5904
5905impl std::fmt::Debug for AllocateQuotaResponse {
5906    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5907        let mut debug_struct = f.debug_struct("AllocateQuotaResponse");
5908        debug_struct.field("operation_id", &self.operation_id);
5909        debug_struct.field("allocate_errors", &self.allocate_errors);
5910        debug_struct.field("quota_metrics", &self.quota_metrics);
5911        debug_struct.field("service_config_id", &self.service_config_id);
5912        if !self._unknown_fields.is_empty() {
5913            debug_struct.field("_unknown_fields", &self._unknown_fields);
5914        }
5915        debug_struct.finish()
5916    }
5917}
5918
5919/// Represents error information for [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation].
5920///
5921/// [google.api.servicecontrol.v1.QuotaOperation]: crate::model::QuotaOperation
5922#[derive(Clone, Default, PartialEq)]
5923#[non_exhaustive]
5924pub struct QuotaError {
5925    /// Error code.
5926    pub code: crate::model::quota_error::Code,
5927
5928    /// Subject to whom this error applies. See the specific enum for more details
5929    /// on this field. For example, "clientip:\<ip address of client\>" or
5930    /// "project:\<Google developer project id\>".
5931    pub subject: std::string::String,
5932
5933    /// Free-form text that provides details on the cause of the error.
5934    pub description: std::string::String,
5935
5936    /// Contains additional information about the quota error.
5937    /// If available, `status.code` will be non zero.
5938    pub status: std::option::Option<rpc::model::Status>,
5939
5940    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5941}
5942
5943impl QuotaError {
5944    pub fn new() -> Self {
5945        std::default::Default::default()
5946    }
5947
5948    /// Sets the value of [code][crate::model::QuotaError::code].
5949    pub fn set_code<T: std::convert::Into<crate::model::quota_error::Code>>(
5950        mut self,
5951        v: T,
5952    ) -> Self {
5953        self.code = v.into();
5954        self
5955    }
5956
5957    /// Sets the value of [subject][crate::model::QuotaError::subject].
5958    pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5959        self.subject = v.into();
5960        self
5961    }
5962
5963    /// Sets the value of [description][crate::model::QuotaError::description].
5964    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5965        self.description = v.into();
5966        self
5967    }
5968
5969    /// Sets the value of [status][crate::model::QuotaError::status].
5970    pub fn set_status<T>(mut self, v: T) -> Self
5971    where
5972        T: std::convert::Into<rpc::model::Status>,
5973    {
5974        self.status = std::option::Option::Some(v.into());
5975        self
5976    }
5977
5978    /// Sets or clears the value of [status][crate::model::QuotaError::status].
5979    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
5980    where
5981        T: std::convert::Into<rpc::model::Status>,
5982    {
5983        self.status = v.map(|x| x.into());
5984        self
5985    }
5986}
5987
5988impl wkt::message::Message for QuotaError {
5989    fn typename() -> &'static str {
5990        "type.googleapis.com/google.api.servicecontrol.v1.QuotaError"
5991    }
5992}
5993
5994#[doc(hidden)]
5995impl<'de> serde::de::Deserialize<'de> for QuotaError {
5996    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5997    where
5998        D: serde::Deserializer<'de>,
5999    {
6000        #[allow(non_camel_case_types)]
6001        #[doc(hidden)]
6002        #[derive(PartialEq, Eq, Hash)]
6003        enum __FieldTag {
6004            __code,
6005            __subject,
6006            __description,
6007            __status,
6008            Unknown(std::string::String),
6009        }
6010        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6011            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6012            where
6013                D: serde::Deserializer<'de>,
6014            {
6015                struct Visitor;
6016                impl<'de> serde::de::Visitor<'de> for Visitor {
6017                    type Value = __FieldTag;
6018                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6019                        formatter.write_str("a field name for QuotaError")
6020                    }
6021                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6022                    where
6023                        E: serde::de::Error,
6024                    {
6025                        use std::result::Result::Ok;
6026                        use std::string::ToString;
6027                        match value {
6028                            "code" => Ok(__FieldTag::__code),
6029                            "subject" => Ok(__FieldTag::__subject),
6030                            "description" => Ok(__FieldTag::__description),
6031                            "status" => Ok(__FieldTag::__status),
6032                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6033                        }
6034                    }
6035                }
6036                deserializer.deserialize_identifier(Visitor)
6037            }
6038        }
6039        struct Visitor;
6040        impl<'de> serde::de::Visitor<'de> for Visitor {
6041            type Value = QuotaError;
6042            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6043                formatter.write_str("struct QuotaError")
6044            }
6045            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6046            where
6047                A: serde::de::MapAccess<'de>,
6048            {
6049                #[allow(unused_imports)]
6050                use serde::de::Error;
6051                use std::option::Option::Some;
6052                let mut fields = std::collections::HashSet::new();
6053                let mut result = Self::Value::new();
6054                while let Some(tag) = map.next_key::<__FieldTag>()? {
6055                    #[allow(clippy::match_single_binding)]
6056                    match tag {
6057                        __FieldTag::__code => {
6058                            if !fields.insert(__FieldTag::__code) {
6059                                return std::result::Result::Err(A::Error::duplicate_field(
6060                                    "multiple values for code",
6061                                ));
6062                            }
6063                            result.code = map
6064                                .next_value::<std::option::Option<crate::model::quota_error::Code>>(
6065                                )?
6066                                .unwrap_or_default();
6067                        }
6068                        __FieldTag::__subject => {
6069                            if !fields.insert(__FieldTag::__subject) {
6070                                return std::result::Result::Err(A::Error::duplicate_field(
6071                                    "multiple values for subject",
6072                                ));
6073                            }
6074                            result.subject = map
6075                                .next_value::<std::option::Option<std::string::String>>()?
6076                                .unwrap_or_default();
6077                        }
6078                        __FieldTag::__description => {
6079                            if !fields.insert(__FieldTag::__description) {
6080                                return std::result::Result::Err(A::Error::duplicate_field(
6081                                    "multiple values for description",
6082                                ));
6083                            }
6084                            result.description = map
6085                                .next_value::<std::option::Option<std::string::String>>()?
6086                                .unwrap_or_default();
6087                        }
6088                        __FieldTag::__status => {
6089                            if !fields.insert(__FieldTag::__status) {
6090                                return std::result::Result::Err(A::Error::duplicate_field(
6091                                    "multiple values for status",
6092                                ));
6093                            }
6094                            result.status =
6095                                map.next_value::<std::option::Option<rpc::model::Status>>()?;
6096                        }
6097                        __FieldTag::Unknown(key) => {
6098                            let value = map.next_value::<serde_json::Value>()?;
6099                            result._unknown_fields.insert(key, value);
6100                        }
6101                    }
6102                }
6103                std::result::Result::Ok(result)
6104            }
6105        }
6106        deserializer.deserialize_any(Visitor)
6107    }
6108}
6109
6110#[doc(hidden)]
6111impl serde::ser::Serialize for QuotaError {
6112    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6113    where
6114        S: serde::ser::Serializer,
6115    {
6116        use serde::ser::SerializeMap;
6117        #[allow(unused_imports)]
6118        use std::option::Option::Some;
6119        let mut state = serializer.serialize_map(std::option::Option::None)?;
6120        if !wkt::internal::is_default(&self.code) {
6121            state.serialize_entry("code", &self.code)?;
6122        }
6123        if !self.subject.is_empty() {
6124            state.serialize_entry("subject", &self.subject)?;
6125        }
6126        if !self.description.is_empty() {
6127            state.serialize_entry("description", &self.description)?;
6128        }
6129        if self.status.is_some() {
6130            state.serialize_entry("status", &self.status)?;
6131        }
6132        if !self._unknown_fields.is_empty() {
6133            for (key, value) in self._unknown_fields.iter() {
6134                state.serialize_entry(key, &value)?;
6135            }
6136        }
6137        state.end()
6138    }
6139}
6140
6141impl std::fmt::Debug for QuotaError {
6142    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6143        let mut debug_struct = f.debug_struct("QuotaError");
6144        debug_struct.field("code", &self.code);
6145        debug_struct.field("subject", &self.subject);
6146        debug_struct.field("description", &self.description);
6147        debug_struct.field("status", &self.status);
6148        if !self._unknown_fields.is_empty() {
6149            debug_struct.field("_unknown_fields", &self._unknown_fields);
6150        }
6151        debug_struct.finish()
6152    }
6153}
6154
6155/// Defines additional types related to [QuotaError].
6156pub mod quota_error {
6157    #[allow(unused_imports)]
6158    use super::*;
6159
6160    /// Error codes related to project config validations are deprecated since the
6161    /// quota controller methods do not perform these validations. Instead services
6162    /// have to call the Check method, without quota_properties field, to perform
6163    /// these validations before calling the quota controller methods. These
6164    /// methods check only for project deletion to be wipe out compliant.
6165    ///
6166    /// # Working with unknown values
6167    ///
6168    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6169    /// additional enum variants at any time. Adding new variants is not considered
6170    /// a breaking change. Applications should write their code in anticipation of:
6171    ///
6172    /// - New values appearing in future releases of the client library, **and**
6173    /// - New values received dynamically, without application changes.
6174    ///
6175    /// Please consult the [Working with enums] section in the user guide for some
6176    /// guidelines.
6177    ///
6178    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6179    #[derive(Clone, Debug, PartialEq)]
6180    #[non_exhaustive]
6181    pub enum Code {
6182        /// This is never used.
6183        Unspecified,
6184        /// Quota allocation failed.
6185        /// Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
6186        ResourceExhausted,
6187        /// Consumer cannot access the service because the service requires active
6188        /// billing.
6189        BillingNotActive,
6190        /// Consumer's project has been marked as deleted (soft deletion).
6191        ProjectDeleted,
6192        /// Specified API key is invalid.
6193        ApiKeyInvalid,
6194        /// Specified API Key has expired.
6195        ApiKeyExpired,
6196        /// If set, the enum was initialized with an unknown value.
6197        ///
6198        /// Applications can examine the value using [Code::value] or
6199        /// [Code::name].
6200        UnknownValue(code::UnknownValue),
6201    }
6202
6203    #[doc(hidden)]
6204    pub mod code {
6205        #[allow(unused_imports)]
6206        use super::*;
6207        #[derive(Clone, Debug, PartialEq)]
6208        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6209    }
6210
6211    impl Code {
6212        /// Gets the enum value.
6213        ///
6214        /// Returns `None` if the enum contains an unknown value deserialized from
6215        /// the string representation of enums.
6216        pub fn value(&self) -> std::option::Option<i32> {
6217            match self {
6218                Self::Unspecified => std::option::Option::Some(0),
6219                Self::ResourceExhausted => std::option::Option::Some(8),
6220                Self::BillingNotActive => std::option::Option::Some(107),
6221                Self::ProjectDeleted => std::option::Option::Some(108),
6222                Self::ApiKeyInvalid => std::option::Option::Some(105),
6223                Self::ApiKeyExpired => std::option::Option::Some(112),
6224                Self::UnknownValue(u) => u.0.value(),
6225            }
6226        }
6227
6228        /// Gets the enum value as a string.
6229        ///
6230        /// Returns `None` if the enum contains an unknown value deserialized from
6231        /// the integer representation of enums.
6232        pub fn name(&self) -> std::option::Option<&str> {
6233            match self {
6234                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
6235                Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
6236                Self::BillingNotActive => std::option::Option::Some("BILLING_NOT_ACTIVE"),
6237                Self::ProjectDeleted => std::option::Option::Some("PROJECT_DELETED"),
6238                Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
6239                Self::ApiKeyExpired => std::option::Option::Some("API_KEY_EXPIRED"),
6240                Self::UnknownValue(u) => u.0.name(),
6241            }
6242        }
6243    }
6244
6245    impl std::default::Default for Code {
6246        fn default() -> Self {
6247            use std::convert::From;
6248            Self::from(0)
6249        }
6250    }
6251
6252    impl std::fmt::Display for Code {
6253        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6254            wkt::internal::display_enum(f, self.name(), self.value())
6255        }
6256    }
6257
6258    impl std::convert::From<i32> for Code {
6259        fn from(value: i32) -> Self {
6260            match value {
6261                0 => Self::Unspecified,
6262                8 => Self::ResourceExhausted,
6263                105 => Self::ApiKeyInvalid,
6264                107 => Self::BillingNotActive,
6265                108 => Self::ProjectDeleted,
6266                112 => Self::ApiKeyExpired,
6267                _ => Self::UnknownValue(code::UnknownValue(
6268                    wkt::internal::UnknownEnumValue::Integer(value),
6269                )),
6270            }
6271        }
6272    }
6273
6274    impl std::convert::From<&str> for Code {
6275        fn from(value: &str) -> Self {
6276            use std::string::ToString;
6277            match value {
6278                "UNSPECIFIED" => Self::Unspecified,
6279                "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
6280                "BILLING_NOT_ACTIVE" => Self::BillingNotActive,
6281                "PROJECT_DELETED" => Self::ProjectDeleted,
6282                "API_KEY_INVALID" => Self::ApiKeyInvalid,
6283                "API_KEY_EXPIRED" => Self::ApiKeyExpired,
6284                _ => Self::UnknownValue(code::UnknownValue(
6285                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6286                )),
6287            }
6288        }
6289    }
6290
6291    impl serde::ser::Serialize for Code {
6292        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6293        where
6294            S: serde::Serializer,
6295        {
6296            match self {
6297                Self::Unspecified => serializer.serialize_i32(0),
6298                Self::ResourceExhausted => serializer.serialize_i32(8),
6299                Self::BillingNotActive => serializer.serialize_i32(107),
6300                Self::ProjectDeleted => serializer.serialize_i32(108),
6301                Self::ApiKeyInvalid => serializer.serialize_i32(105),
6302                Self::ApiKeyExpired => serializer.serialize_i32(112),
6303                Self::UnknownValue(u) => u.0.serialize(serializer),
6304            }
6305        }
6306    }
6307
6308    impl<'de> serde::de::Deserialize<'de> for Code {
6309        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6310        where
6311            D: serde::Deserializer<'de>,
6312        {
6313            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
6314                ".google.api.servicecontrol.v1.QuotaError.Code",
6315            ))
6316        }
6317    }
6318}
6319
6320/// Request message for the Check method.
6321#[derive(Clone, Default, PartialEq)]
6322#[non_exhaustive]
6323pub struct CheckRequest {
6324    /// The service name as specified in its service configuration. For example,
6325    /// `"pubsub.googleapis.com"`.
6326    ///
6327    /// See
6328    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
6329    /// for the definition of a service name.
6330    pub service_name: std::string::String,
6331
6332    /// The operation to be checked.
6333    pub operation: std::option::Option<crate::model::Operation>,
6334
6335    /// Specifies which version of service configuration should be used to process
6336    /// the request.
6337    ///
6338    /// If unspecified or no matching version can be found, the
6339    /// latest one will be used.
6340    pub service_config_id: std::string::String,
6341
6342    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6343}
6344
6345impl CheckRequest {
6346    pub fn new() -> Self {
6347        std::default::Default::default()
6348    }
6349
6350    /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
6351    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6352        self.service_name = v.into();
6353        self
6354    }
6355
6356    /// Sets the value of [operation][crate::model::CheckRequest::operation].
6357    pub fn set_operation<T>(mut self, v: T) -> Self
6358    where
6359        T: std::convert::Into<crate::model::Operation>,
6360    {
6361        self.operation = std::option::Option::Some(v.into());
6362        self
6363    }
6364
6365    /// Sets or clears the value of [operation][crate::model::CheckRequest::operation].
6366    pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
6367    where
6368        T: std::convert::Into<crate::model::Operation>,
6369    {
6370        self.operation = v.map(|x| x.into());
6371        self
6372    }
6373
6374    /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
6375    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
6376        mut self,
6377        v: T,
6378    ) -> Self {
6379        self.service_config_id = v.into();
6380        self
6381    }
6382}
6383
6384impl wkt::message::Message for CheckRequest {
6385    fn typename() -> &'static str {
6386        "type.googleapis.com/google.api.servicecontrol.v1.CheckRequest"
6387    }
6388}
6389
6390#[doc(hidden)]
6391impl<'de> serde::de::Deserialize<'de> for CheckRequest {
6392    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6393    where
6394        D: serde::Deserializer<'de>,
6395    {
6396        #[allow(non_camel_case_types)]
6397        #[doc(hidden)]
6398        #[derive(PartialEq, Eq, Hash)]
6399        enum __FieldTag {
6400            __service_name,
6401            __operation,
6402            __service_config_id,
6403            Unknown(std::string::String),
6404        }
6405        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6406            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6407            where
6408                D: serde::Deserializer<'de>,
6409            {
6410                struct Visitor;
6411                impl<'de> serde::de::Visitor<'de> for Visitor {
6412                    type Value = __FieldTag;
6413                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6414                        formatter.write_str("a field name for CheckRequest")
6415                    }
6416                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6417                    where
6418                        E: serde::de::Error,
6419                    {
6420                        use std::result::Result::Ok;
6421                        use std::string::ToString;
6422                        match value {
6423                            "serviceName" => Ok(__FieldTag::__service_name),
6424                            "service_name" => Ok(__FieldTag::__service_name),
6425                            "operation" => Ok(__FieldTag::__operation),
6426                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
6427                            "service_config_id" => Ok(__FieldTag::__service_config_id),
6428                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6429                        }
6430                    }
6431                }
6432                deserializer.deserialize_identifier(Visitor)
6433            }
6434        }
6435        struct Visitor;
6436        impl<'de> serde::de::Visitor<'de> for Visitor {
6437            type Value = CheckRequest;
6438            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6439                formatter.write_str("struct CheckRequest")
6440            }
6441            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6442            where
6443                A: serde::de::MapAccess<'de>,
6444            {
6445                #[allow(unused_imports)]
6446                use serde::de::Error;
6447                use std::option::Option::Some;
6448                let mut fields = std::collections::HashSet::new();
6449                let mut result = Self::Value::new();
6450                while let Some(tag) = map.next_key::<__FieldTag>()? {
6451                    #[allow(clippy::match_single_binding)]
6452                    match tag {
6453                        __FieldTag::__service_name => {
6454                            if !fields.insert(__FieldTag::__service_name) {
6455                                return std::result::Result::Err(A::Error::duplicate_field(
6456                                    "multiple values for service_name",
6457                                ));
6458                            }
6459                            result.service_name = map
6460                                .next_value::<std::option::Option<std::string::String>>()?
6461                                .unwrap_or_default();
6462                        }
6463                        __FieldTag::__operation => {
6464                            if !fields.insert(__FieldTag::__operation) {
6465                                return std::result::Result::Err(A::Error::duplicate_field(
6466                                    "multiple values for operation",
6467                                ));
6468                            }
6469                            result.operation =
6470                                map.next_value::<std::option::Option<crate::model::Operation>>()?;
6471                        }
6472                        __FieldTag::__service_config_id => {
6473                            if !fields.insert(__FieldTag::__service_config_id) {
6474                                return std::result::Result::Err(A::Error::duplicate_field(
6475                                    "multiple values for service_config_id",
6476                                ));
6477                            }
6478                            result.service_config_id = map
6479                                .next_value::<std::option::Option<std::string::String>>()?
6480                                .unwrap_or_default();
6481                        }
6482                        __FieldTag::Unknown(key) => {
6483                            let value = map.next_value::<serde_json::Value>()?;
6484                            result._unknown_fields.insert(key, value);
6485                        }
6486                    }
6487                }
6488                std::result::Result::Ok(result)
6489            }
6490        }
6491        deserializer.deserialize_any(Visitor)
6492    }
6493}
6494
6495#[doc(hidden)]
6496impl serde::ser::Serialize for CheckRequest {
6497    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6498    where
6499        S: serde::ser::Serializer,
6500    {
6501        use serde::ser::SerializeMap;
6502        #[allow(unused_imports)]
6503        use std::option::Option::Some;
6504        let mut state = serializer.serialize_map(std::option::Option::None)?;
6505        if !self.service_name.is_empty() {
6506            state.serialize_entry("serviceName", &self.service_name)?;
6507        }
6508        if self.operation.is_some() {
6509            state.serialize_entry("operation", &self.operation)?;
6510        }
6511        if !self.service_config_id.is_empty() {
6512            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
6513        }
6514        if !self._unknown_fields.is_empty() {
6515            for (key, value) in self._unknown_fields.iter() {
6516                state.serialize_entry(key, &value)?;
6517            }
6518        }
6519        state.end()
6520    }
6521}
6522
6523impl std::fmt::Debug for CheckRequest {
6524    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6525        let mut debug_struct = f.debug_struct("CheckRequest");
6526        debug_struct.field("service_name", &self.service_name);
6527        debug_struct.field("operation", &self.operation);
6528        debug_struct.field("service_config_id", &self.service_config_id);
6529        if !self._unknown_fields.is_empty() {
6530            debug_struct.field("_unknown_fields", &self._unknown_fields);
6531        }
6532        debug_struct.finish()
6533    }
6534}
6535
6536/// Response message for the Check method.
6537#[derive(Clone, Default, PartialEq)]
6538#[non_exhaustive]
6539pub struct CheckResponse {
6540    /// The same operation_id value used in the
6541    /// [CheckRequest][google.api.servicecontrol.v1.CheckRequest]. Used for logging
6542    /// and diagnostics purposes.
6543    ///
6544    /// [google.api.servicecontrol.v1.CheckRequest]: crate::model::CheckRequest
6545    pub operation_id: std::string::String,
6546
6547    /// Indicate the decision of the check.
6548    ///
6549    /// If no check errors are present, the service should process the operation.
6550    /// Otherwise the service should use the list of errors to determine the
6551    /// appropriate action.
6552    pub check_errors: std::vec::Vec<crate::model::CheckError>,
6553
6554    /// The actual config id used to process the request.
6555    pub service_config_id: std::string::String,
6556
6557    /// The current service rollout id used to process the request.
6558    pub service_rollout_id: std::string::String,
6559
6560    /// Feedback data returned from the server during processing a Check request.
6561    pub check_info: std::option::Option<crate::model::check_response::CheckInfo>,
6562
6563    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6564}
6565
6566impl CheckResponse {
6567    pub fn new() -> Self {
6568        std::default::Default::default()
6569    }
6570
6571    /// Sets the value of [operation_id][crate::model::CheckResponse::operation_id].
6572    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6573        self.operation_id = v.into();
6574        self
6575    }
6576
6577    /// Sets the value of [check_errors][crate::model::CheckResponse::check_errors].
6578    pub fn set_check_errors<T, V>(mut self, v: T) -> Self
6579    where
6580        T: std::iter::IntoIterator<Item = V>,
6581        V: std::convert::Into<crate::model::CheckError>,
6582    {
6583        use std::iter::Iterator;
6584        self.check_errors = v.into_iter().map(|i| i.into()).collect();
6585        self
6586    }
6587
6588    /// Sets the value of [service_config_id][crate::model::CheckResponse::service_config_id].
6589    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
6590        mut self,
6591        v: T,
6592    ) -> Self {
6593        self.service_config_id = v.into();
6594        self
6595    }
6596
6597    /// Sets the value of [service_rollout_id][crate::model::CheckResponse::service_rollout_id].
6598    pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
6599        mut self,
6600        v: T,
6601    ) -> Self {
6602        self.service_rollout_id = v.into();
6603        self
6604    }
6605
6606    /// Sets the value of [check_info][crate::model::CheckResponse::check_info].
6607    pub fn set_check_info<T>(mut self, v: T) -> Self
6608    where
6609        T: std::convert::Into<crate::model::check_response::CheckInfo>,
6610    {
6611        self.check_info = std::option::Option::Some(v.into());
6612        self
6613    }
6614
6615    /// Sets or clears the value of [check_info][crate::model::CheckResponse::check_info].
6616    pub fn set_or_clear_check_info<T>(mut self, v: std::option::Option<T>) -> Self
6617    where
6618        T: std::convert::Into<crate::model::check_response::CheckInfo>,
6619    {
6620        self.check_info = v.map(|x| x.into());
6621        self
6622    }
6623}
6624
6625impl wkt::message::Message for CheckResponse {
6626    fn typename() -> &'static str {
6627        "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse"
6628    }
6629}
6630
6631#[doc(hidden)]
6632impl<'de> serde::de::Deserialize<'de> for CheckResponse {
6633    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6634    where
6635        D: serde::Deserializer<'de>,
6636    {
6637        #[allow(non_camel_case_types)]
6638        #[doc(hidden)]
6639        #[derive(PartialEq, Eq, Hash)]
6640        enum __FieldTag {
6641            __operation_id,
6642            __check_errors,
6643            __service_config_id,
6644            __service_rollout_id,
6645            __check_info,
6646            Unknown(std::string::String),
6647        }
6648        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6649            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6650            where
6651                D: serde::Deserializer<'de>,
6652            {
6653                struct Visitor;
6654                impl<'de> serde::de::Visitor<'de> for Visitor {
6655                    type Value = __FieldTag;
6656                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6657                        formatter.write_str("a field name for CheckResponse")
6658                    }
6659                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6660                    where
6661                        E: serde::de::Error,
6662                    {
6663                        use std::result::Result::Ok;
6664                        use std::string::ToString;
6665                        match value {
6666                            "operationId" => Ok(__FieldTag::__operation_id),
6667                            "operation_id" => Ok(__FieldTag::__operation_id),
6668                            "checkErrors" => Ok(__FieldTag::__check_errors),
6669                            "check_errors" => Ok(__FieldTag::__check_errors),
6670                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
6671                            "service_config_id" => Ok(__FieldTag::__service_config_id),
6672                            "serviceRolloutId" => Ok(__FieldTag::__service_rollout_id),
6673                            "service_rollout_id" => Ok(__FieldTag::__service_rollout_id),
6674                            "checkInfo" => Ok(__FieldTag::__check_info),
6675                            "check_info" => Ok(__FieldTag::__check_info),
6676                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6677                        }
6678                    }
6679                }
6680                deserializer.deserialize_identifier(Visitor)
6681            }
6682        }
6683        struct Visitor;
6684        impl<'de> serde::de::Visitor<'de> for Visitor {
6685            type Value = CheckResponse;
6686            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6687                formatter.write_str("struct CheckResponse")
6688            }
6689            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6690            where
6691                A: serde::de::MapAccess<'de>,
6692            {
6693                #[allow(unused_imports)]
6694                use serde::de::Error;
6695                use std::option::Option::Some;
6696                let mut fields = std::collections::HashSet::new();
6697                let mut result = Self::Value::new();
6698                while let Some(tag) = map.next_key::<__FieldTag>()? {
6699                    #[allow(clippy::match_single_binding)]
6700                    match tag {
6701                        __FieldTag::__operation_id => {
6702                            if !fields.insert(__FieldTag::__operation_id) {
6703                                return std::result::Result::Err(A::Error::duplicate_field(
6704                                    "multiple values for operation_id",
6705                                ));
6706                            }
6707                            result.operation_id = map
6708                                .next_value::<std::option::Option<std::string::String>>()?
6709                                .unwrap_or_default();
6710                        }
6711                        __FieldTag::__check_errors => {
6712                            if !fields.insert(__FieldTag::__check_errors) {
6713                                return std::result::Result::Err(A::Error::duplicate_field(
6714                                    "multiple values for check_errors",
6715                                ));
6716                            }
6717                            result.check_errors = map.next_value::<std::option::Option<std::vec::Vec<crate::model::CheckError>>>()?.unwrap_or_default();
6718                        }
6719                        __FieldTag::__service_config_id => {
6720                            if !fields.insert(__FieldTag::__service_config_id) {
6721                                return std::result::Result::Err(A::Error::duplicate_field(
6722                                    "multiple values for service_config_id",
6723                                ));
6724                            }
6725                            result.service_config_id = map
6726                                .next_value::<std::option::Option<std::string::String>>()?
6727                                .unwrap_or_default();
6728                        }
6729                        __FieldTag::__service_rollout_id => {
6730                            if !fields.insert(__FieldTag::__service_rollout_id) {
6731                                return std::result::Result::Err(A::Error::duplicate_field(
6732                                    "multiple values for service_rollout_id",
6733                                ));
6734                            }
6735                            result.service_rollout_id = map
6736                                .next_value::<std::option::Option<std::string::String>>()?
6737                                .unwrap_or_default();
6738                        }
6739                        __FieldTag::__check_info => {
6740                            if !fields.insert(__FieldTag::__check_info) {
6741                                return std::result::Result::Err(A::Error::duplicate_field(
6742                                    "multiple values for check_info",
6743                                ));
6744                            }
6745                            result.check_info = map.next_value::<std::option::Option<crate::model::check_response::CheckInfo>>()?
6746                                ;
6747                        }
6748                        __FieldTag::Unknown(key) => {
6749                            let value = map.next_value::<serde_json::Value>()?;
6750                            result._unknown_fields.insert(key, value);
6751                        }
6752                    }
6753                }
6754                std::result::Result::Ok(result)
6755            }
6756        }
6757        deserializer.deserialize_any(Visitor)
6758    }
6759}
6760
6761#[doc(hidden)]
6762impl serde::ser::Serialize for CheckResponse {
6763    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6764    where
6765        S: serde::ser::Serializer,
6766    {
6767        use serde::ser::SerializeMap;
6768        #[allow(unused_imports)]
6769        use std::option::Option::Some;
6770        let mut state = serializer.serialize_map(std::option::Option::None)?;
6771        if !self.operation_id.is_empty() {
6772            state.serialize_entry("operationId", &self.operation_id)?;
6773        }
6774        if !self.check_errors.is_empty() {
6775            state.serialize_entry("checkErrors", &self.check_errors)?;
6776        }
6777        if !self.service_config_id.is_empty() {
6778            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
6779        }
6780        if !self.service_rollout_id.is_empty() {
6781            state.serialize_entry("serviceRolloutId", &self.service_rollout_id)?;
6782        }
6783        if self.check_info.is_some() {
6784            state.serialize_entry("checkInfo", &self.check_info)?;
6785        }
6786        if !self._unknown_fields.is_empty() {
6787            for (key, value) in self._unknown_fields.iter() {
6788                state.serialize_entry(key, &value)?;
6789            }
6790        }
6791        state.end()
6792    }
6793}
6794
6795impl std::fmt::Debug for CheckResponse {
6796    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6797        let mut debug_struct = f.debug_struct("CheckResponse");
6798        debug_struct.field("operation_id", &self.operation_id);
6799        debug_struct.field("check_errors", &self.check_errors);
6800        debug_struct.field("service_config_id", &self.service_config_id);
6801        debug_struct.field("service_rollout_id", &self.service_rollout_id);
6802        debug_struct.field("check_info", &self.check_info);
6803        if !self._unknown_fields.is_empty() {
6804            debug_struct.field("_unknown_fields", &self._unknown_fields);
6805        }
6806        debug_struct.finish()
6807    }
6808}
6809
6810/// Defines additional types related to [CheckResponse].
6811pub mod check_response {
6812    #[allow(unused_imports)]
6813    use super::*;
6814
6815    /// Contains additional information about the check operation.
6816    #[derive(Clone, Default, PartialEq)]
6817    #[non_exhaustive]
6818    pub struct CheckInfo {
6819        /// A list of fields and label keys that are ignored by the server.
6820        /// The client doesn't need to send them for following requests to improve
6821        /// performance and allow better aggregation.
6822        pub unused_arguments: std::vec::Vec<std::string::String>,
6823
6824        /// Consumer info of this check.
6825        pub consumer_info: std::option::Option<crate::model::check_response::ConsumerInfo>,
6826
6827        /// The unique id of the api key in the format of "apikey:\<UID\>".
6828        /// This field will be populated when the consumer passed to Service Control
6829        /// is an API key and all the API key related validations are successful.
6830        pub api_key_uid: std::string::String,
6831
6832        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6833    }
6834
6835    impl CheckInfo {
6836        pub fn new() -> Self {
6837            std::default::Default::default()
6838        }
6839
6840        /// Sets the value of [unused_arguments][crate::model::check_response::CheckInfo::unused_arguments].
6841        pub fn set_unused_arguments<T, V>(mut self, v: T) -> Self
6842        where
6843            T: std::iter::IntoIterator<Item = V>,
6844            V: std::convert::Into<std::string::String>,
6845        {
6846            use std::iter::Iterator;
6847            self.unused_arguments = v.into_iter().map(|i| i.into()).collect();
6848            self
6849        }
6850
6851        /// Sets the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
6852        pub fn set_consumer_info<T>(mut self, v: T) -> Self
6853        where
6854            T: std::convert::Into<crate::model::check_response::ConsumerInfo>,
6855        {
6856            self.consumer_info = std::option::Option::Some(v.into());
6857            self
6858        }
6859
6860        /// Sets or clears the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
6861        pub fn set_or_clear_consumer_info<T>(mut self, v: std::option::Option<T>) -> Self
6862        where
6863            T: std::convert::Into<crate::model::check_response::ConsumerInfo>,
6864        {
6865            self.consumer_info = v.map(|x| x.into());
6866            self
6867        }
6868
6869        /// Sets the value of [api_key_uid][crate::model::check_response::CheckInfo::api_key_uid].
6870        pub fn set_api_key_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6871            self.api_key_uid = v.into();
6872            self
6873        }
6874    }
6875
6876    impl wkt::message::Message for CheckInfo {
6877        fn typename() -> &'static str {
6878            "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.CheckInfo"
6879        }
6880    }
6881
6882    #[doc(hidden)]
6883    impl<'de> serde::de::Deserialize<'de> for CheckInfo {
6884        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6885        where
6886            D: serde::Deserializer<'de>,
6887        {
6888            #[allow(non_camel_case_types)]
6889            #[doc(hidden)]
6890            #[derive(PartialEq, Eq, Hash)]
6891            enum __FieldTag {
6892                __unused_arguments,
6893                __consumer_info,
6894                __api_key_uid,
6895                Unknown(std::string::String),
6896            }
6897            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6898                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6899                where
6900                    D: serde::Deserializer<'de>,
6901                {
6902                    struct Visitor;
6903                    impl<'de> serde::de::Visitor<'de> for Visitor {
6904                        type Value = __FieldTag;
6905                        fn expecting(
6906                            &self,
6907                            formatter: &mut std::fmt::Formatter,
6908                        ) -> std::fmt::Result {
6909                            formatter.write_str("a field name for CheckInfo")
6910                        }
6911                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6912                        where
6913                            E: serde::de::Error,
6914                        {
6915                            use std::result::Result::Ok;
6916                            use std::string::ToString;
6917                            match value {
6918                                "unusedArguments" => Ok(__FieldTag::__unused_arguments),
6919                                "unused_arguments" => Ok(__FieldTag::__unused_arguments),
6920                                "consumerInfo" => Ok(__FieldTag::__consumer_info),
6921                                "consumer_info" => Ok(__FieldTag::__consumer_info),
6922                                "apiKeyUid" => Ok(__FieldTag::__api_key_uid),
6923                                "api_key_uid" => Ok(__FieldTag::__api_key_uid),
6924                                _ => Ok(__FieldTag::Unknown(value.to_string())),
6925                            }
6926                        }
6927                    }
6928                    deserializer.deserialize_identifier(Visitor)
6929                }
6930            }
6931            struct Visitor;
6932            impl<'de> serde::de::Visitor<'de> for Visitor {
6933                type Value = CheckInfo;
6934                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6935                    formatter.write_str("struct CheckInfo")
6936                }
6937                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6938                where
6939                    A: serde::de::MapAccess<'de>,
6940                {
6941                    #[allow(unused_imports)]
6942                    use serde::de::Error;
6943                    use std::option::Option::Some;
6944                    let mut fields = std::collections::HashSet::new();
6945                    let mut result = Self::Value::new();
6946                    while let Some(tag) = map.next_key::<__FieldTag>()? {
6947                        #[allow(clippy::match_single_binding)]
6948                        match tag {
6949                            __FieldTag::__unused_arguments => {
6950                                if !fields.insert(__FieldTag::__unused_arguments) {
6951                                    return std::result::Result::Err(A::Error::duplicate_field(
6952                                        "multiple values for unused_arguments",
6953                                    ));
6954                                }
6955                                result.unused_arguments = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
6956                            }
6957                            __FieldTag::__consumer_info => {
6958                                if !fields.insert(__FieldTag::__consumer_info) {
6959                                    return std::result::Result::Err(A::Error::duplicate_field(
6960                                        "multiple values for consumer_info",
6961                                    ));
6962                                }
6963                                result.consumer_info = map.next_value::<std::option::Option<
6964                                    crate::model::check_response::ConsumerInfo,
6965                                >>()?;
6966                            }
6967                            __FieldTag::__api_key_uid => {
6968                                if !fields.insert(__FieldTag::__api_key_uid) {
6969                                    return std::result::Result::Err(A::Error::duplicate_field(
6970                                        "multiple values for api_key_uid",
6971                                    ));
6972                                }
6973                                result.api_key_uid = map
6974                                    .next_value::<std::option::Option<std::string::String>>()?
6975                                    .unwrap_or_default();
6976                            }
6977                            __FieldTag::Unknown(key) => {
6978                                let value = map.next_value::<serde_json::Value>()?;
6979                                result._unknown_fields.insert(key, value);
6980                            }
6981                        }
6982                    }
6983                    std::result::Result::Ok(result)
6984                }
6985            }
6986            deserializer.deserialize_any(Visitor)
6987        }
6988    }
6989
6990    #[doc(hidden)]
6991    impl serde::ser::Serialize for CheckInfo {
6992        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6993        where
6994            S: serde::ser::Serializer,
6995        {
6996            use serde::ser::SerializeMap;
6997            #[allow(unused_imports)]
6998            use std::option::Option::Some;
6999            let mut state = serializer.serialize_map(std::option::Option::None)?;
7000            if !self.unused_arguments.is_empty() {
7001                state.serialize_entry("unusedArguments", &self.unused_arguments)?;
7002            }
7003            if self.consumer_info.is_some() {
7004                state.serialize_entry("consumerInfo", &self.consumer_info)?;
7005            }
7006            if !self.api_key_uid.is_empty() {
7007                state.serialize_entry("apiKeyUid", &self.api_key_uid)?;
7008            }
7009            if !self._unknown_fields.is_empty() {
7010                for (key, value) in self._unknown_fields.iter() {
7011                    state.serialize_entry(key, &value)?;
7012                }
7013            }
7014            state.end()
7015        }
7016    }
7017
7018    impl std::fmt::Debug for CheckInfo {
7019        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7020            let mut debug_struct = f.debug_struct("CheckInfo");
7021            debug_struct.field("unused_arguments", &self.unused_arguments);
7022            debug_struct.field("consumer_info", &self.consumer_info);
7023            debug_struct.field("api_key_uid", &self.api_key_uid);
7024            if !self._unknown_fields.is_empty() {
7025                debug_struct.field("_unknown_fields", &self._unknown_fields);
7026            }
7027            debug_struct.finish()
7028        }
7029    }
7030
7031    /// `ConsumerInfo` provides information about the consumer.
7032    #[derive(Clone, Default, PartialEq)]
7033    #[non_exhaustive]
7034    pub struct ConsumerInfo {
7035        /// The Google cloud project number, e.g. 1234567890. A value of 0 indicates
7036        /// no project number is found.
7037        ///
7038        /// NOTE: This field is deprecated after we support flexible consumer
7039        /// id. New code should not depend on this field anymore.
7040        pub project_number: i64,
7041
7042        /// The type of the consumer which should have been defined in
7043        /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
7044        pub r#type: crate::model::check_response::consumer_info::ConsumerType,
7045
7046        /// The consumer identity number, can be Google cloud project number, folder
7047        /// number or organization number e.g. 1234567890. A value of 0 indicates no
7048        /// consumer number is found.
7049        pub consumer_number: i64,
7050
7051        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7052    }
7053
7054    impl ConsumerInfo {
7055        pub fn new() -> Self {
7056            std::default::Default::default()
7057        }
7058
7059        /// Sets the value of [project_number][crate::model::check_response::ConsumerInfo::project_number].
7060        pub fn set_project_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7061            self.project_number = v.into();
7062            self
7063        }
7064
7065        /// Sets the value of [r#type][crate::model::check_response::ConsumerInfo::type].
7066        pub fn set_type<
7067            T: std::convert::Into<crate::model::check_response::consumer_info::ConsumerType>,
7068        >(
7069            mut self,
7070            v: T,
7071        ) -> Self {
7072            self.r#type = v.into();
7073            self
7074        }
7075
7076        /// Sets the value of [consumer_number][crate::model::check_response::ConsumerInfo::consumer_number].
7077        pub fn set_consumer_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7078            self.consumer_number = v.into();
7079            self
7080        }
7081    }
7082
7083    impl wkt::message::Message for ConsumerInfo {
7084        fn typename() -> &'static str {
7085            "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.ConsumerInfo"
7086        }
7087    }
7088
7089    #[doc(hidden)]
7090    impl<'de> serde::de::Deserialize<'de> for ConsumerInfo {
7091        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7092        where
7093            D: serde::Deserializer<'de>,
7094        {
7095            #[allow(non_camel_case_types)]
7096            #[doc(hidden)]
7097            #[derive(PartialEq, Eq, Hash)]
7098            enum __FieldTag {
7099                __project_number,
7100                __type,
7101                __consumer_number,
7102                Unknown(std::string::String),
7103            }
7104            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7105                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7106                where
7107                    D: serde::Deserializer<'de>,
7108                {
7109                    struct Visitor;
7110                    impl<'de> serde::de::Visitor<'de> for Visitor {
7111                        type Value = __FieldTag;
7112                        fn expecting(
7113                            &self,
7114                            formatter: &mut std::fmt::Formatter,
7115                        ) -> std::fmt::Result {
7116                            formatter.write_str("a field name for ConsumerInfo")
7117                        }
7118                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7119                        where
7120                            E: serde::de::Error,
7121                        {
7122                            use std::result::Result::Ok;
7123                            use std::string::ToString;
7124                            match value {
7125                                "projectNumber" => Ok(__FieldTag::__project_number),
7126                                "project_number" => Ok(__FieldTag::__project_number),
7127                                "type" => Ok(__FieldTag::__type),
7128                                "consumerNumber" => Ok(__FieldTag::__consumer_number),
7129                                "consumer_number" => Ok(__FieldTag::__consumer_number),
7130                                _ => Ok(__FieldTag::Unknown(value.to_string())),
7131                            }
7132                        }
7133                    }
7134                    deserializer.deserialize_identifier(Visitor)
7135                }
7136            }
7137            struct Visitor;
7138            impl<'de> serde::de::Visitor<'de> for Visitor {
7139                type Value = ConsumerInfo;
7140                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7141                    formatter.write_str("struct ConsumerInfo")
7142                }
7143                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7144                where
7145                    A: serde::de::MapAccess<'de>,
7146                {
7147                    #[allow(unused_imports)]
7148                    use serde::de::Error;
7149                    use std::option::Option::Some;
7150                    let mut fields = std::collections::HashSet::new();
7151                    let mut result = Self::Value::new();
7152                    while let Some(tag) = map.next_key::<__FieldTag>()? {
7153                        #[allow(clippy::match_single_binding)]
7154                        match tag {
7155                            __FieldTag::__project_number => {
7156                                if !fields.insert(__FieldTag::__project_number) {
7157                                    return std::result::Result::Err(A::Error::duplicate_field(
7158                                        "multiple values for project_number",
7159                                    ));
7160                                }
7161                                struct __With(std::option::Option<i64>);
7162                                impl<'de> serde::de::Deserialize<'de> for __With {
7163                                    fn deserialize<D>(
7164                                        deserializer: D,
7165                                    ) -> std::result::Result<Self, D::Error>
7166                                    where
7167                                        D: serde::de::Deserializer<'de>,
7168                                    {
7169                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
7170                                    }
7171                                }
7172                                result.project_number =
7173                                    map.next_value::<__With>()?.0.unwrap_or_default();
7174                            }
7175                            __FieldTag::__type => {
7176                                if !fields.insert(__FieldTag::__type) {
7177                                    return std::result::Result::Err(A::Error::duplicate_field(
7178                                        "multiple values for type",
7179                                    ));
7180                                }
7181                                result.r#type = map
7182                                    .next_value::<std::option::Option<
7183                                        crate::model::check_response::consumer_info::ConsumerType,
7184                                    >>()?
7185                                    .unwrap_or_default();
7186                            }
7187                            __FieldTag::__consumer_number => {
7188                                if !fields.insert(__FieldTag::__consumer_number) {
7189                                    return std::result::Result::Err(A::Error::duplicate_field(
7190                                        "multiple values for consumer_number",
7191                                    ));
7192                                }
7193                                struct __With(std::option::Option<i64>);
7194                                impl<'de> serde::de::Deserialize<'de> for __With {
7195                                    fn deserialize<D>(
7196                                        deserializer: D,
7197                                    ) -> std::result::Result<Self, D::Error>
7198                                    where
7199                                        D: serde::de::Deserializer<'de>,
7200                                    {
7201                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
7202                                    }
7203                                }
7204                                result.consumer_number =
7205                                    map.next_value::<__With>()?.0.unwrap_or_default();
7206                            }
7207                            __FieldTag::Unknown(key) => {
7208                                let value = map.next_value::<serde_json::Value>()?;
7209                                result._unknown_fields.insert(key, value);
7210                            }
7211                        }
7212                    }
7213                    std::result::Result::Ok(result)
7214                }
7215            }
7216            deserializer.deserialize_any(Visitor)
7217        }
7218    }
7219
7220    #[doc(hidden)]
7221    impl serde::ser::Serialize for ConsumerInfo {
7222        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7223        where
7224            S: serde::ser::Serializer,
7225        {
7226            use serde::ser::SerializeMap;
7227            #[allow(unused_imports)]
7228            use std::option::Option::Some;
7229            let mut state = serializer.serialize_map(std::option::Option::None)?;
7230            if !wkt::internal::is_default(&self.project_number) {
7231                struct __With<'a>(&'a i64);
7232                impl<'a> serde::ser::Serialize for __With<'a> {
7233                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7234                    where
7235                        S: serde::ser::Serializer,
7236                    {
7237                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
7238                    }
7239                }
7240                state.serialize_entry("projectNumber", &__With(&self.project_number))?;
7241            }
7242            if !wkt::internal::is_default(&self.r#type) {
7243                state.serialize_entry("type", &self.r#type)?;
7244            }
7245            if !wkt::internal::is_default(&self.consumer_number) {
7246                struct __With<'a>(&'a i64);
7247                impl<'a> serde::ser::Serialize for __With<'a> {
7248                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7249                    where
7250                        S: serde::ser::Serializer,
7251                    {
7252                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
7253                    }
7254                }
7255                state.serialize_entry("consumerNumber", &__With(&self.consumer_number))?;
7256            }
7257            if !self._unknown_fields.is_empty() {
7258                for (key, value) in self._unknown_fields.iter() {
7259                    state.serialize_entry(key, &value)?;
7260                }
7261            }
7262            state.end()
7263        }
7264    }
7265
7266    impl std::fmt::Debug for ConsumerInfo {
7267        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7268            let mut debug_struct = f.debug_struct("ConsumerInfo");
7269            debug_struct.field("project_number", &self.project_number);
7270            debug_struct.field("r#type", &self.r#type);
7271            debug_struct.field("consumer_number", &self.consumer_number);
7272            if !self._unknown_fields.is_empty() {
7273                debug_struct.field("_unknown_fields", &self._unknown_fields);
7274            }
7275            debug_struct.finish()
7276        }
7277    }
7278
7279    /// Defines additional types related to [ConsumerInfo].
7280    pub mod consumer_info {
7281        #[allow(unused_imports)]
7282        use super::*;
7283
7284        /// The type of the consumer as defined in
7285        /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
7286        ///
7287        /// # Working with unknown values
7288        ///
7289        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7290        /// additional enum variants at any time. Adding new variants is not considered
7291        /// a breaking change. Applications should write their code in anticipation of:
7292        ///
7293        /// - New values appearing in future releases of the client library, **and**
7294        /// - New values received dynamically, without application changes.
7295        ///
7296        /// Please consult the [Working with enums] section in the user guide for some
7297        /// guidelines.
7298        ///
7299        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
7300        #[derive(Clone, Debug, PartialEq)]
7301        #[non_exhaustive]
7302        pub enum ConsumerType {
7303            /// This is never used.
7304            Unspecified,
7305            /// The consumer is a Google Cloud Project.
7306            Project,
7307            /// The consumer is a Google Cloud Folder.
7308            Folder,
7309            /// The consumer is a Google Cloud Organization.
7310            Organization,
7311            /// Service-specific resource container which is defined by the service
7312            /// producer to offer their users the ability to manage service control
7313            /// functionalities at a finer level of granularity than the PROJECT.
7314            ServiceSpecific,
7315            /// If set, the enum was initialized with an unknown value.
7316            ///
7317            /// Applications can examine the value using [ConsumerType::value] or
7318            /// [ConsumerType::name].
7319            UnknownValue(consumer_type::UnknownValue),
7320        }
7321
7322        #[doc(hidden)]
7323        pub mod consumer_type {
7324            #[allow(unused_imports)]
7325            use super::*;
7326            #[derive(Clone, Debug, PartialEq)]
7327            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7328        }
7329
7330        impl ConsumerType {
7331            /// Gets the enum value.
7332            ///
7333            /// Returns `None` if the enum contains an unknown value deserialized from
7334            /// the string representation of enums.
7335            pub fn value(&self) -> std::option::Option<i32> {
7336                match self {
7337                    Self::Unspecified => std::option::Option::Some(0),
7338                    Self::Project => std::option::Option::Some(1),
7339                    Self::Folder => std::option::Option::Some(2),
7340                    Self::Organization => std::option::Option::Some(3),
7341                    Self::ServiceSpecific => std::option::Option::Some(4),
7342                    Self::UnknownValue(u) => u.0.value(),
7343                }
7344            }
7345
7346            /// Gets the enum value as a string.
7347            ///
7348            /// Returns `None` if the enum contains an unknown value deserialized from
7349            /// the integer representation of enums.
7350            pub fn name(&self) -> std::option::Option<&str> {
7351                match self {
7352                    Self::Unspecified => std::option::Option::Some("CONSUMER_TYPE_UNSPECIFIED"),
7353                    Self::Project => std::option::Option::Some("PROJECT"),
7354                    Self::Folder => std::option::Option::Some("FOLDER"),
7355                    Self::Organization => std::option::Option::Some("ORGANIZATION"),
7356                    Self::ServiceSpecific => std::option::Option::Some("SERVICE_SPECIFIC"),
7357                    Self::UnknownValue(u) => u.0.name(),
7358                }
7359            }
7360        }
7361
7362        impl std::default::Default for ConsumerType {
7363            fn default() -> Self {
7364                use std::convert::From;
7365                Self::from(0)
7366            }
7367        }
7368
7369        impl std::fmt::Display for ConsumerType {
7370            fn fmt(
7371                &self,
7372                f: &mut std::fmt::Formatter<'_>,
7373            ) -> std::result::Result<(), std::fmt::Error> {
7374                wkt::internal::display_enum(f, self.name(), self.value())
7375            }
7376        }
7377
7378        impl std::convert::From<i32> for ConsumerType {
7379            fn from(value: i32) -> Self {
7380                match value {
7381                    0 => Self::Unspecified,
7382                    1 => Self::Project,
7383                    2 => Self::Folder,
7384                    3 => Self::Organization,
7385                    4 => Self::ServiceSpecific,
7386                    _ => Self::UnknownValue(consumer_type::UnknownValue(
7387                        wkt::internal::UnknownEnumValue::Integer(value),
7388                    )),
7389                }
7390            }
7391        }
7392
7393        impl std::convert::From<&str> for ConsumerType {
7394            fn from(value: &str) -> Self {
7395                use std::string::ToString;
7396                match value {
7397                    "CONSUMER_TYPE_UNSPECIFIED" => Self::Unspecified,
7398                    "PROJECT" => Self::Project,
7399                    "FOLDER" => Self::Folder,
7400                    "ORGANIZATION" => Self::Organization,
7401                    "SERVICE_SPECIFIC" => Self::ServiceSpecific,
7402                    _ => Self::UnknownValue(consumer_type::UnknownValue(
7403                        wkt::internal::UnknownEnumValue::String(value.to_string()),
7404                    )),
7405                }
7406            }
7407        }
7408
7409        impl serde::ser::Serialize for ConsumerType {
7410            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7411            where
7412                S: serde::Serializer,
7413            {
7414                match self {
7415                    Self::Unspecified => serializer.serialize_i32(0),
7416                    Self::Project => serializer.serialize_i32(1),
7417                    Self::Folder => serializer.serialize_i32(2),
7418                    Self::Organization => serializer.serialize_i32(3),
7419                    Self::ServiceSpecific => serializer.serialize_i32(4),
7420                    Self::UnknownValue(u) => u.0.serialize(serializer),
7421                }
7422            }
7423        }
7424
7425        impl<'de> serde::de::Deserialize<'de> for ConsumerType {
7426            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7427            where
7428                D: serde::Deserializer<'de>,
7429            {
7430                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ConsumerType>::new(
7431                    ".google.api.servicecontrol.v1.CheckResponse.ConsumerInfo.ConsumerType",
7432                ))
7433            }
7434        }
7435    }
7436}
7437
7438/// Request message for the Report method.
7439#[derive(Clone, Default, PartialEq)]
7440#[non_exhaustive]
7441pub struct ReportRequest {
7442    /// The service name as specified in its service configuration. For example,
7443    /// `"pubsub.googleapis.com"`.
7444    ///
7445    /// See
7446    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
7447    /// for the definition of a service name.
7448    pub service_name: std::string::String,
7449
7450    /// Operations to be reported.
7451    ///
7452    /// Typically the service should report one operation per request.
7453    /// Putting multiple operations into a single request is allowed, but should
7454    /// be used only when multiple operations are natually available at the time
7455    /// of the report.
7456    ///
7457    /// There is no limit on the number of operations in the same ReportRequest,
7458    /// however the ReportRequest size should be no larger than 1MB. See
7459    /// [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors]
7460    /// for partial failure behavior.
7461    ///
7462    /// [google.api.servicecontrol.v1.ReportResponse.report_errors]: crate::model::ReportResponse::report_errors
7463    pub operations: std::vec::Vec<crate::model::Operation>,
7464
7465    /// Specifies which version of service config should be used to process the
7466    /// request.
7467    ///
7468    /// If unspecified or no matching version can be found, the
7469    /// latest one will be used.
7470    pub service_config_id: std::string::String,
7471
7472    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7473}
7474
7475impl ReportRequest {
7476    pub fn new() -> Self {
7477        std::default::Default::default()
7478    }
7479
7480    /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
7481    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7482        self.service_name = v.into();
7483        self
7484    }
7485
7486    /// Sets the value of [operations][crate::model::ReportRequest::operations].
7487    pub fn set_operations<T, V>(mut self, v: T) -> Self
7488    where
7489        T: std::iter::IntoIterator<Item = V>,
7490        V: std::convert::Into<crate::model::Operation>,
7491    {
7492        use std::iter::Iterator;
7493        self.operations = v.into_iter().map(|i| i.into()).collect();
7494        self
7495    }
7496
7497    /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
7498    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
7499        mut self,
7500        v: T,
7501    ) -> Self {
7502        self.service_config_id = v.into();
7503        self
7504    }
7505}
7506
7507impl wkt::message::Message for ReportRequest {
7508    fn typename() -> &'static str {
7509        "type.googleapis.com/google.api.servicecontrol.v1.ReportRequest"
7510    }
7511}
7512
7513#[doc(hidden)]
7514impl<'de> serde::de::Deserialize<'de> for ReportRequest {
7515    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7516    where
7517        D: serde::Deserializer<'de>,
7518    {
7519        #[allow(non_camel_case_types)]
7520        #[doc(hidden)]
7521        #[derive(PartialEq, Eq, Hash)]
7522        enum __FieldTag {
7523            __service_name,
7524            __operations,
7525            __service_config_id,
7526            Unknown(std::string::String),
7527        }
7528        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7529            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7530            where
7531                D: serde::Deserializer<'de>,
7532            {
7533                struct Visitor;
7534                impl<'de> serde::de::Visitor<'de> for Visitor {
7535                    type Value = __FieldTag;
7536                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7537                        formatter.write_str("a field name for ReportRequest")
7538                    }
7539                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7540                    where
7541                        E: serde::de::Error,
7542                    {
7543                        use std::result::Result::Ok;
7544                        use std::string::ToString;
7545                        match value {
7546                            "serviceName" => Ok(__FieldTag::__service_name),
7547                            "service_name" => Ok(__FieldTag::__service_name),
7548                            "operations" => Ok(__FieldTag::__operations),
7549                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
7550                            "service_config_id" => Ok(__FieldTag::__service_config_id),
7551                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7552                        }
7553                    }
7554                }
7555                deserializer.deserialize_identifier(Visitor)
7556            }
7557        }
7558        struct Visitor;
7559        impl<'de> serde::de::Visitor<'de> for Visitor {
7560            type Value = ReportRequest;
7561            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7562                formatter.write_str("struct ReportRequest")
7563            }
7564            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7565            where
7566                A: serde::de::MapAccess<'de>,
7567            {
7568                #[allow(unused_imports)]
7569                use serde::de::Error;
7570                use std::option::Option::Some;
7571                let mut fields = std::collections::HashSet::new();
7572                let mut result = Self::Value::new();
7573                while let Some(tag) = map.next_key::<__FieldTag>()? {
7574                    #[allow(clippy::match_single_binding)]
7575                    match tag {
7576                        __FieldTag::__service_name => {
7577                            if !fields.insert(__FieldTag::__service_name) {
7578                                return std::result::Result::Err(A::Error::duplicate_field(
7579                                    "multiple values for service_name",
7580                                ));
7581                            }
7582                            result.service_name = map
7583                                .next_value::<std::option::Option<std::string::String>>()?
7584                                .unwrap_or_default();
7585                        }
7586                        __FieldTag::__operations => {
7587                            if !fields.insert(__FieldTag::__operations) {
7588                                return std::result::Result::Err(A::Error::duplicate_field(
7589                                    "multiple values for operations",
7590                                ));
7591                            }
7592                            result.operations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Operation>>>()?.unwrap_or_default();
7593                        }
7594                        __FieldTag::__service_config_id => {
7595                            if !fields.insert(__FieldTag::__service_config_id) {
7596                                return std::result::Result::Err(A::Error::duplicate_field(
7597                                    "multiple values for service_config_id",
7598                                ));
7599                            }
7600                            result.service_config_id = map
7601                                .next_value::<std::option::Option<std::string::String>>()?
7602                                .unwrap_or_default();
7603                        }
7604                        __FieldTag::Unknown(key) => {
7605                            let value = map.next_value::<serde_json::Value>()?;
7606                            result._unknown_fields.insert(key, value);
7607                        }
7608                    }
7609                }
7610                std::result::Result::Ok(result)
7611            }
7612        }
7613        deserializer.deserialize_any(Visitor)
7614    }
7615}
7616
7617#[doc(hidden)]
7618impl serde::ser::Serialize for ReportRequest {
7619    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7620    where
7621        S: serde::ser::Serializer,
7622    {
7623        use serde::ser::SerializeMap;
7624        #[allow(unused_imports)]
7625        use std::option::Option::Some;
7626        let mut state = serializer.serialize_map(std::option::Option::None)?;
7627        if !self.service_name.is_empty() {
7628            state.serialize_entry("serviceName", &self.service_name)?;
7629        }
7630        if !self.operations.is_empty() {
7631            state.serialize_entry("operations", &self.operations)?;
7632        }
7633        if !self.service_config_id.is_empty() {
7634            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
7635        }
7636        if !self._unknown_fields.is_empty() {
7637            for (key, value) in self._unknown_fields.iter() {
7638                state.serialize_entry(key, &value)?;
7639            }
7640        }
7641        state.end()
7642    }
7643}
7644
7645impl std::fmt::Debug for ReportRequest {
7646    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7647        let mut debug_struct = f.debug_struct("ReportRequest");
7648        debug_struct.field("service_name", &self.service_name);
7649        debug_struct.field("operations", &self.operations);
7650        debug_struct.field("service_config_id", &self.service_config_id);
7651        if !self._unknown_fields.is_empty() {
7652            debug_struct.field("_unknown_fields", &self._unknown_fields);
7653        }
7654        debug_struct.finish()
7655    }
7656}
7657
7658/// Response message for the Report method.
7659#[derive(Clone, Default, PartialEq)]
7660#[non_exhaustive]
7661pub struct ReportResponse {
7662    /// Partial failures, one for each `Operation` in the request that failed
7663    /// processing. There are three possible combinations of the RPC status:
7664    ///
7665    /// 1. The combination of a successful RPC status and an empty `report_errors`
7666    ///    list indicates a complete success where all `Operations` in the
7667    ///    request are processed successfully.
7668    /// 1. The combination of a successful RPC status and a non-empty
7669    ///    `report_errors` list indicates a partial success where some
7670    ///    `Operations` in the request succeeded. Each
7671    ///    `Operation` that failed processing has a corresponding item
7672    ///    in this list.
7673    /// 1. A failed RPC status indicates a general non-deterministic failure.
7674    ///    When this happens, it's impossible to know which of the
7675    ///    'Operations' in the request succeeded or failed.
7676    pub report_errors: std::vec::Vec<crate::model::report_response::ReportError>,
7677
7678    /// The actual config id used to process the request.
7679    pub service_config_id: std::string::String,
7680
7681    /// The current service rollout id used to process the request.
7682    pub service_rollout_id: std::string::String,
7683
7684    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7685}
7686
7687impl ReportResponse {
7688    pub fn new() -> Self {
7689        std::default::Default::default()
7690    }
7691
7692    /// Sets the value of [report_errors][crate::model::ReportResponse::report_errors].
7693    pub fn set_report_errors<T, V>(mut self, v: T) -> Self
7694    where
7695        T: std::iter::IntoIterator<Item = V>,
7696        V: std::convert::Into<crate::model::report_response::ReportError>,
7697    {
7698        use std::iter::Iterator;
7699        self.report_errors = v.into_iter().map(|i| i.into()).collect();
7700        self
7701    }
7702
7703    /// Sets the value of [service_config_id][crate::model::ReportResponse::service_config_id].
7704    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
7705        mut self,
7706        v: T,
7707    ) -> Self {
7708        self.service_config_id = v.into();
7709        self
7710    }
7711
7712    /// Sets the value of [service_rollout_id][crate::model::ReportResponse::service_rollout_id].
7713    pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
7714        mut self,
7715        v: T,
7716    ) -> Self {
7717        self.service_rollout_id = v.into();
7718        self
7719    }
7720}
7721
7722impl wkt::message::Message for ReportResponse {
7723    fn typename() -> &'static str {
7724        "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse"
7725    }
7726}
7727
7728#[doc(hidden)]
7729impl<'de> serde::de::Deserialize<'de> for ReportResponse {
7730    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7731    where
7732        D: serde::Deserializer<'de>,
7733    {
7734        #[allow(non_camel_case_types)]
7735        #[doc(hidden)]
7736        #[derive(PartialEq, Eq, Hash)]
7737        enum __FieldTag {
7738            __report_errors,
7739            __service_config_id,
7740            __service_rollout_id,
7741            Unknown(std::string::String),
7742        }
7743        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7744            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7745            where
7746                D: serde::Deserializer<'de>,
7747            {
7748                struct Visitor;
7749                impl<'de> serde::de::Visitor<'de> for Visitor {
7750                    type Value = __FieldTag;
7751                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7752                        formatter.write_str("a field name for ReportResponse")
7753                    }
7754                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7755                    where
7756                        E: serde::de::Error,
7757                    {
7758                        use std::result::Result::Ok;
7759                        use std::string::ToString;
7760                        match value {
7761                            "reportErrors" => Ok(__FieldTag::__report_errors),
7762                            "report_errors" => Ok(__FieldTag::__report_errors),
7763                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
7764                            "service_config_id" => Ok(__FieldTag::__service_config_id),
7765                            "serviceRolloutId" => Ok(__FieldTag::__service_rollout_id),
7766                            "service_rollout_id" => Ok(__FieldTag::__service_rollout_id),
7767                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7768                        }
7769                    }
7770                }
7771                deserializer.deserialize_identifier(Visitor)
7772            }
7773        }
7774        struct Visitor;
7775        impl<'de> serde::de::Visitor<'de> for Visitor {
7776            type Value = ReportResponse;
7777            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7778                formatter.write_str("struct ReportResponse")
7779            }
7780            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7781            where
7782                A: serde::de::MapAccess<'de>,
7783            {
7784                #[allow(unused_imports)]
7785                use serde::de::Error;
7786                use std::option::Option::Some;
7787                let mut fields = std::collections::HashSet::new();
7788                let mut result = Self::Value::new();
7789                while let Some(tag) = map.next_key::<__FieldTag>()? {
7790                    #[allow(clippy::match_single_binding)]
7791                    match tag {
7792                        __FieldTag::__report_errors => {
7793                            if !fields.insert(__FieldTag::__report_errors) {
7794                                return std::result::Result::Err(A::Error::duplicate_field(
7795                                    "multiple values for report_errors",
7796                                ));
7797                            }
7798                            result.report_errors = map
7799                                .next_value::<std::option::Option<
7800                                    std::vec::Vec<crate::model::report_response::ReportError>,
7801                                >>()?
7802                                .unwrap_or_default();
7803                        }
7804                        __FieldTag::__service_config_id => {
7805                            if !fields.insert(__FieldTag::__service_config_id) {
7806                                return std::result::Result::Err(A::Error::duplicate_field(
7807                                    "multiple values for service_config_id",
7808                                ));
7809                            }
7810                            result.service_config_id = map
7811                                .next_value::<std::option::Option<std::string::String>>()?
7812                                .unwrap_or_default();
7813                        }
7814                        __FieldTag::__service_rollout_id => {
7815                            if !fields.insert(__FieldTag::__service_rollout_id) {
7816                                return std::result::Result::Err(A::Error::duplicate_field(
7817                                    "multiple values for service_rollout_id",
7818                                ));
7819                            }
7820                            result.service_rollout_id = map
7821                                .next_value::<std::option::Option<std::string::String>>()?
7822                                .unwrap_or_default();
7823                        }
7824                        __FieldTag::Unknown(key) => {
7825                            let value = map.next_value::<serde_json::Value>()?;
7826                            result._unknown_fields.insert(key, value);
7827                        }
7828                    }
7829                }
7830                std::result::Result::Ok(result)
7831            }
7832        }
7833        deserializer.deserialize_any(Visitor)
7834    }
7835}
7836
7837#[doc(hidden)]
7838impl serde::ser::Serialize for ReportResponse {
7839    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7840    where
7841        S: serde::ser::Serializer,
7842    {
7843        use serde::ser::SerializeMap;
7844        #[allow(unused_imports)]
7845        use std::option::Option::Some;
7846        let mut state = serializer.serialize_map(std::option::Option::None)?;
7847        if !self.report_errors.is_empty() {
7848            state.serialize_entry("reportErrors", &self.report_errors)?;
7849        }
7850        if !self.service_config_id.is_empty() {
7851            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
7852        }
7853        if !self.service_rollout_id.is_empty() {
7854            state.serialize_entry("serviceRolloutId", &self.service_rollout_id)?;
7855        }
7856        if !self._unknown_fields.is_empty() {
7857            for (key, value) in self._unknown_fields.iter() {
7858                state.serialize_entry(key, &value)?;
7859            }
7860        }
7861        state.end()
7862    }
7863}
7864
7865impl std::fmt::Debug for ReportResponse {
7866    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7867        let mut debug_struct = f.debug_struct("ReportResponse");
7868        debug_struct.field("report_errors", &self.report_errors);
7869        debug_struct.field("service_config_id", &self.service_config_id);
7870        debug_struct.field("service_rollout_id", &self.service_rollout_id);
7871        if !self._unknown_fields.is_empty() {
7872            debug_struct.field("_unknown_fields", &self._unknown_fields);
7873        }
7874        debug_struct.finish()
7875    }
7876}
7877
7878/// Defines additional types related to [ReportResponse].
7879pub mod report_response {
7880    #[allow(unused_imports)]
7881    use super::*;
7882
7883    /// Represents the processing error of one
7884    /// [Operation][google.api.servicecontrol.v1.Operation] in the request.
7885    ///
7886    /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
7887    #[derive(Clone, Default, PartialEq)]
7888    #[non_exhaustive]
7889    pub struct ReportError {
7890        /// The
7891        /// [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id]
7892        /// value from the request.
7893        ///
7894        /// [google.api.servicecontrol.v1.Operation.operation_id]: crate::model::Operation::operation_id
7895        pub operation_id: std::string::String,
7896
7897        /// Details of the error when processing the
7898        /// [Operation][google.api.servicecontrol.v1.Operation].
7899        ///
7900        /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
7901        pub status: std::option::Option<rpc::model::Status>,
7902
7903        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7904    }
7905
7906    impl ReportError {
7907        pub fn new() -> Self {
7908            std::default::Default::default()
7909        }
7910
7911        /// Sets the value of [operation_id][crate::model::report_response::ReportError::operation_id].
7912        pub fn set_operation_id<T: std::convert::Into<std::string::String>>(
7913            mut self,
7914            v: T,
7915        ) -> Self {
7916            self.operation_id = v.into();
7917            self
7918        }
7919
7920        /// Sets the value of [status][crate::model::report_response::ReportError::status].
7921        pub fn set_status<T>(mut self, v: T) -> Self
7922        where
7923            T: std::convert::Into<rpc::model::Status>,
7924        {
7925            self.status = std::option::Option::Some(v.into());
7926            self
7927        }
7928
7929        /// Sets or clears the value of [status][crate::model::report_response::ReportError::status].
7930        pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
7931        where
7932            T: std::convert::Into<rpc::model::Status>,
7933        {
7934            self.status = v.map(|x| x.into());
7935            self
7936        }
7937    }
7938
7939    impl wkt::message::Message for ReportError {
7940        fn typename() -> &'static str {
7941            "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse.ReportError"
7942        }
7943    }
7944
7945    #[doc(hidden)]
7946    impl<'de> serde::de::Deserialize<'de> for ReportError {
7947        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7948        where
7949            D: serde::Deserializer<'de>,
7950        {
7951            #[allow(non_camel_case_types)]
7952            #[doc(hidden)]
7953            #[derive(PartialEq, Eq, Hash)]
7954            enum __FieldTag {
7955                __operation_id,
7956                __status,
7957                Unknown(std::string::String),
7958            }
7959            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7960                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7961                where
7962                    D: serde::Deserializer<'de>,
7963                {
7964                    struct Visitor;
7965                    impl<'de> serde::de::Visitor<'de> for Visitor {
7966                        type Value = __FieldTag;
7967                        fn expecting(
7968                            &self,
7969                            formatter: &mut std::fmt::Formatter,
7970                        ) -> std::fmt::Result {
7971                            formatter.write_str("a field name for ReportError")
7972                        }
7973                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7974                        where
7975                            E: serde::de::Error,
7976                        {
7977                            use std::result::Result::Ok;
7978                            use std::string::ToString;
7979                            match value {
7980                                "operationId" => Ok(__FieldTag::__operation_id),
7981                                "operation_id" => Ok(__FieldTag::__operation_id),
7982                                "status" => Ok(__FieldTag::__status),
7983                                _ => Ok(__FieldTag::Unknown(value.to_string())),
7984                            }
7985                        }
7986                    }
7987                    deserializer.deserialize_identifier(Visitor)
7988                }
7989            }
7990            struct Visitor;
7991            impl<'de> serde::de::Visitor<'de> for Visitor {
7992                type Value = ReportError;
7993                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7994                    formatter.write_str("struct ReportError")
7995                }
7996                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7997                where
7998                    A: serde::de::MapAccess<'de>,
7999                {
8000                    #[allow(unused_imports)]
8001                    use serde::de::Error;
8002                    use std::option::Option::Some;
8003                    let mut fields = std::collections::HashSet::new();
8004                    let mut result = Self::Value::new();
8005                    while let Some(tag) = map.next_key::<__FieldTag>()? {
8006                        #[allow(clippy::match_single_binding)]
8007                        match tag {
8008                            __FieldTag::__operation_id => {
8009                                if !fields.insert(__FieldTag::__operation_id) {
8010                                    return std::result::Result::Err(A::Error::duplicate_field(
8011                                        "multiple values for operation_id",
8012                                    ));
8013                                }
8014                                result.operation_id = map
8015                                    .next_value::<std::option::Option<std::string::String>>()?
8016                                    .unwrap_or_default();
8017                            }
8018                            __FieldTag::__status => {
8019                                if !fields.insert(__FieldTag::__status) {
8020                                    return std::result::Result::Err(A::Error::duplicate_field(
8021                                        "multiple values for status",
8022                                    ));
8023                                }
8024                                result.status =
8025                                    map.next_value::<std::option::Option<rpc::model::Status>>()?;
8026                            }
8027                            __FieldTag::Unknown(key) => {
8028                                let value = map.next_value::<serde_json::Value>()?;
8029                                result._unknown_fields.insert(key, value);
8030                            }
8031                        }
8032                    }
8033                    std::result::Result::Ok(result)
8034                }
8035            }
8036            deserializer.deserialize_any(Visitor)
8037        }
8038    }
8039
8040    #[doc(hidden)]
8041    impl serde::ser::Serialize for ReportError {
8042        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8043        where
8044            S: serde::ser::Serializer,
8045        {
8046            use serde::ser::SerializeMap;
8047            #[allow(unused_imports)]
8048            use std::option::Option::Some;
8049            let mut state = serializer.serialize_map(std::option::Option::None)?;
8050            if !self.operation_id.is_empty() {
8051                state.serialize_entry("operationId", &self.operation_id)?;
8052            }
8053            if self.status.is_some() {
8054                state.serialize_entry("status", &self.status)?;
8055            }
8056            if !self._unknown_fields.is_empty() {
8057                for (key, value) in self._unknown_fields.iter() {
8058                    state.serialize_entry(key, &value)?;
8059                }
8060            }
8061            state.end()
8062        }
8063    }
8064
8065    impl std::fmt::Debug for ReportError {
8066        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8067            let mut debug_struct = f.debug_struct("ReportError");
8068            debug_struct.field("operation_id", &self.operation_id);
8069            debug_struct.field("status", &self.status);
8070            if !self._unknown_fields.is_empty() {
8071                debug_struct.field("_unknown_fields", &self._unknown_fields);
8072            }
8073            debug_struct.finish()
8074        }
8075    }
8076}