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
36mod debug;
37mod deserialize;
38mod serialize;
39
40/// Defines the errors to be returned in
41/// [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors].
42///
43/// [google.api.servicecontrol.v1.CheckResponse.check_errors]: crate::model::CheckResponse::check_errors
44#[derive(Clone, Default, PartialEq)]
45#[non_exhaustive]
46pub struct CheckError {
47 /// The error code.
48 pub code: crate::model::check_error::Code,
49
50 /// Subject to whom this error applies. See the specific code enum for more
51 /// details on this field. For example:
52 ///
53 /// - "project:\<project-id or project-number\>"
54 /// - "folder:\<folder-id\>"
55 /// - "organization:\<organization-id\>"
56 pub subject: std::string::String,
57
58 /// Free-form text providing details on the error cause of the error.
59 pub detail: std::string::String,
60
61 /// Contains public information about the check error. If available,
62 /// `status.code` will be non zero and client can propagate it out as public
63 /// error.
64 pub status: std::option::Option<rpc::model::Status>,
65
66 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
67}
68
69impl CheckError {
70 pub fn new() -> Self {
71 std::default::Default::default()
72 }
73
74 /// Sets the value of [code][crate::model::CheckError::code].
75 ///
76 /// # Example
77 /// ```ignore,no_run
78 /// # use google_cloud_api_servicecontrol_v1::model::CheckError;
79 /// use google_cloud_api_servicecontrol_v1::model::check_error::Code;
80 /// let x0 = CheckError::new().set_code(Code::NotFound);
81 /// let x1 = CheckError::new().set_code(Code::PermissionDenied);
82 /// let x2 = CheckError::new().set_code(Code::ResourceExhausted);
83 /// ```
84 pub fn set_code<T: std::convert::Into<crate::model::check_error::Code>>(
85 mut self,
86 v: T,
87 ) -> Self {
88 self.code = v.into();
89 self
90 }
91
92 /// Sets the value of [subject][crate::model::CheckError::subject].
93 ///
94 /// # Example
95 /// ```ignore,no_run
96 /// # use google_cloud_api_servicecontrol_v1::model::CheckError;
97 /// let x = CheckError::new().set_subject("example");
98 /// ```
99 pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
100 self.subject = v.into();
101 self
102 }
103
104 /// Sets the value of [detail][crate::model::CheckError::detail].
105 ///
106 /// # Example
107 /// ```ignore,no_run
108 /// # use google_cloud_api_servicecontrol_v1::model::CheckError;
109 /// let x = CheckError::new().set_detail("example");
110 /// ```
111 pub fn set_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
112 self.detail = v.into();
113 self
114 }
115
116 /// Sets the value of [status][crate::model::CheckError::status].
117 ///
118 /// # Example
119 /// ```ignore,no_run
120 /// # use google_cloud_api_servicecontrol_v1::model::CheckError;
121 /// use rpc::model::Status;
122 /// let x = CheckError::new().set_status(Status::default()/* use setters */);
123 /// ```
124 pub fn set_status<T>(mut self, v: T) -> Self
125 where
126 T: std::convert::Into<rpc::model::Status>,
127 {
128 self.status = std::option::Option::Some(v.into());
129 self
130 }
131
132 /// Sets or clears the value of [status][crate::model::CheckError::status].
133 ///
134 /// # Example
135 /// ```ignore,no_run
136 /// # use google_cloud_api_servicecontrol_v1::model::CheckError;
137 /// use rpc::model::Status;
138 /// let x = CheckError::new().set_or_clear_status(Some(Status::default()/* use setters */));
139 /// let x = CheckError::new().set_or_clear_status(None::<Status>);
140 /// ```
141 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
142 where
143 T: std::convert::Into<rpc::model::Status>,
144 {
145 self.status = v.map(|x| x.into());
146 self
147 }
148}
149
150impl wkt::message::Message for CheckError {
151 fn typename() -> &'static str {
152 "type.googleapis.com/google.api.servicecontrol.v1.CheckError"
153 }
154}
155
156/// Defines additional types related to [CheckError].
157pub mod check_error {
158 #[allow(unused_imports)]
159 use super::*;
160
161 /// Error codes for Check responses.
162 ///
163 /// # Working with unknown values
164 ///
165 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
166 /// additional enum variants at any time. Adding new variants is not considered
167 /// a breaking change. Applications should write their code in anticipation of:
168 ///
169 /// - New values appearing in future releases of the client library, **and**
170 /// - New values received dynamically, without application changes.
171 ///
172 /// Please consult the [Working with enums] section in the user guide for some
173 /// guidelines.
174 ///
175 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
176 #[derive(Clone, Debug, PartialEq)]
177 #[non_exhaustive]
178 pub enum Code {
179 /// This is never used in `CheckResponse`.
180 ErrorCodeUnspecified,
181 /// The consumer's project id, network container, or resource container was
182 /// not found. Same as [google.rpc.Code.NOT_FOUND][google.rpc.Code.NOT_FOUND].
183 NotFound,
184 /// The consumer doesn't have access to the specified resource.
185 /// Same as [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
186 PermissionDenied,
187 /// Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
188 ResourceExhausted,
189 /// The consumer hasn't activated the service.
190 ServiceNotActivated,
191 /// The consumer cannot access the service because billing is disabled.
192 BillingDisabled,
193 /// The consumer's project has been marked as deleted (soft deletion).
194 ProjectDeleted,
195 /// The consumer's project number or id does not represent a valid project.
196 ProjectInvalid,
197 /// The input consumer info does not represent a valid consumer folder or
198 /// organization.
199 ConsumerInvalid,
200 /// The IP address of the consumer is invalid for the specific consumer
201 /// project.
202 IpAddressBlocked,
203 /// The referer address of the consumer request is invalid for the specific
204 /// consumer project.
205 RefererBlocked,
206 /// The client application of the consumer request is invalid for the
207 /// specific consumer project.
208 ClientAppBlocked,
209 /// The API targeted by this request is invalid for the specified consumer
210 /// project.
211 ApiTargetBlocked,
212 /// The consumer's API key is invalid.
213 ApiKeyInvalid,
214 /// The consumer's API Key has expired.
215 ApiKeyExpired,
216 /// The consumer's API Key was not found in config record.
217 ApiKeyNotFound,
218 /// The credential in the request can not be verified.
219 InvalidCredential,
220 /// The backend server for looking up project id/number is unavailable.
221 NamespaceLookupUnavailable,
222 /// The backend server for checking service status is unavailable.
223 ServiceStatusUnavailable,
224 /// The backend server for checking billing status is unavailable.
225 BillingStatusUnavailable,
226 /// Cloud Resource Manager backend server is unavailable.
227 CloudResourceManagerBackendUnavailable,
228 /// If set, the enum was initialized with an unknown value.
229 ///
230 /// Applications can examine the value using [Code::value] or
231 /// [Code::name].
232 UnknownValue(code::UnknownValue),
233 }
234
235 #[doc(hidden)]
236 pub mod code {
237 #[allow(unused_imports)]
238 use super::*;
239 #[derive(Clone, Debug, PartialEq)]
240 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
241 }
242
243 impl Code {
244 /// Gets the enum value.
245 ///
246 /// Returns `None` if the enum contains an unknown value deserialized from
247 /// the string representation of enums.
248 pub fn value(&self) -> std::option::Option<i32> {
249 match self {
250 Self::ErrorCodeUnspecified => std::option::Option::Some(0),
251 Self::NotFound => std::option::Option::Some(5),
252 Self::PermissionDenied => std::option::Option::Some(7),
253 Self::ResourceExhausted => std::option::Option::Some(8),
254 Self::ServiceNotActivated => std::option::Option::Some(104),
255 Self::BillingDisabled => std::option::Option::Some(107),
256 Self::ProjectDeleted => std::option::Option::Some(108),
257 Self::ProjectInvalid => std::option::Option::Some(114),
258 Self::ConsumerInvalid => std::option::Option::Some(125),
259 Self::IpAddressBlocked => std::option::Option::Some(109),
260 Self::RefererBlocked => std::option::Option::Some(110),
261 Self::ClientAppBlocked => std::option::Option::Some(111),
262 Self::ApiTargetBlocked => std::option::Option::Some(122),
263 Self::ApiKeyInvalid => std::option::Option::Some(105),
264 Self::ApiKeyExpired => std::option::Option::Some(112),
265 Self::ApiKeyNotFound => std::option::Option::Some(113),
266 Self::InvalidCredential => std::option::Option::Some(123),
267 Self::NamespaceLookupUnavailable => std::option::Option::Some(300),
268 Self::ServiceStatusUnavailable => std::option::Option::Some(301),
269 Self::BillingStatusUnavailable => std::option::Option::Some(302),
270 Self::CloudResourceManagerBackendUnavailable => std::option::Option::Some(305),
271 Self::UnknownValue(u) => u.0.value(),
272 }
273 }
274
275 /// Gets the enum value as a string.
276 ///
277 /// Returns `None` if the enum contains an unknown value deserialized from
278 /// the integer representation of enums.
279 pub fn name(&self) -> std::option::Option<&str> {
280 match self {
281 Self::ErrorCodeUnspecified => std::option::Option::Some("ERROR_CODE_UNSPECIFIED"),
282 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
283 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
284 Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
285 Self::ServiceNotActivated => std::option::Option::Some("SERVICE_NOT_ACTIVATED"),
286 Self::BillingDisabled => std::option::Option::Some("BILLING_DISABLED"),
287 Self::ProjectDeleted => std::option::Option::Some("PROJECT_DELETED"),
288 Self::ProjectInvalid => std::option::Option::Some("PROJECT_INVALID"),
289 Self::ConsumerInvalid => std::option::Option::Some("CONSUMER_INVALID"),
290 Self::IpAddressBlocked => std::option::Option::Some("IP_ADDRESS_BLOCKED"),
291 Self::RefererBlocked => std::option::Option::Some("REFERER_BLOCKED"),
292 Self::ClientAppBlocked => std::option::Option::Some("CLIENT_APP_BLOCKED"),
293 Self::ApiTargetBlocked => std::option::Option::Some("API_TARGET_BLOCKED"),
294 Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
295 Self::ApiKeyExpired => std::option::Option::Some("API_KEY_EXPIRED"),
296 Self::ApiKeyNotFound => std::option::Option::Some("API_KEY_NOT_FOUND"),
297 Self::InvalidCredential => std::option::Option::Some("INVALID_CREDENTIAL"),
298 Self::NamespaceLookupUnavailable => {
299 std::option::Option::Some("NAMESPACE_LOOKUP_UNAVAILABLE")
300 }
301 Self::ServiceStatusUnavailable => {
302 std::option::Option::Some("SERVICE_STATUS_UNAVAILABLE")
303 }
304 Self::BillingStatusUnavailable => {
305 std::option::Option::Some("BILLING_STATUS_UNAVAILABLE")
306 }
307 Self::CloudResourceManagerBackendUnavailable => {
308 std::option::Option::Some("CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE")
309 }
310 Self::UnknownValue(u) => u.0.name(),
311 }
312 }
313 }
314
315 impl std::default::Default for Code {
316 fn default() -> Self {
317 use std::convert::From;
318 Self::from(0)
319 }
320 }
321
322 impl std::fmt::Display for Code {
323 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
324 wkt::internal::display_enum(f, self.name(), self.value())
325 }
326 }
327
328 impl std::convert::From<i32> for Code {
329 fn from(value: i32) -> Self {
330 match value {
331 0 => Self::ErrorCodeUnspecified,
332 5 => Self::NotFound,
333 7 => Self::PermissionDenied,
334 8 => Self::ResourceExhausted,
335 104 => Self::ServiceNotActivated,
336 105 => Self::ApiKeyInvalid,
337 107 => Self::BillingDisabled,
338 108 => Self::ProjectDeleted,
339 109 => Self::IpAddressBlocked,
340 110 => Self::RefererBlocked,
341 111 => Self::ClientAppBlocked,
342 112 => Self::ApiKeyExpired,
343 113 => Self::ApiKeyNotFound,
344 114 => Self::ProjectInvalid,
345 122 => Self::ApiTargetBlocked,
346 123 => Self::InvalidCredential,
347 125 => Self::ConsumerInvalid,
348 300 => Self::NamespaceLookupUnavailable,
349 301 => Self::ServiceStatusUnavailable,
350 302 => Self::BillingStatusUnavailable,
351 305 => Self::CloudResourceManagerBackendUnavailable,
352 _ => Self::UnknownValue(code::UnknownValue(
353 wkt::internal::UnknownEnumValue::Integer(value),
354 )),
355 }
356 }
357 }
358
359 impl std::convert::From<&str> for Code {
360 fn from(value: &str) -> Self {
361 use std::string::ToString;
362 match value {
363 "ERROR_CODE_UNSPECIFIED" => Self::ErrorCodeUnspecified,
364 "NOT_FOUND" => Self::NotFound,
365 "PERMISSION_DENIED" => Self::PermissionDenied,
366 "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
367 "SERVICE_NOT_ACTIVATED" => Self::ServiceNotActivated,
368 "BILLING_DISABLED" => Self::BillingDisabled,
369 "PROJECT_DELETED" => Self::ProjectDeleted,
370 "PROJECT_INVALID" => Self::ProjectInvalid,
371 "CONSUMER_INVALID" => Self::ConsumerInvalid,
372 "IP_ADDRESS_BLOCKED" => Self::IpAddressBlocked,
373 "REFERER_BLOCKED" => Self::RefererBlocked,
374 "CLIENT_APP_BLOCKED" => Self::ClientAppBlocked,
375 "API_TARGET_BLOCKED" => Self::ApiTargetBlocked,
376 "API_KEY_INVALID" => Self::ApiKeyInvalid,
377 "API_KEY_EXPIRED" => Self::ApiKeyExpired,
378 "API_KEY_NOT_FOUND" => Self::ApiKeyNotFound,
379 "INVALID_CREDENTIAL" => Self::InvalidCredential,
380 "NAMESPACE_LOOKUP_UNAVAILABLE" => Self::NamespaceLookupUnavailable,
381 "SERVICE_STATUS_UNAVAILABLE" => Self::ServiceStatusUnavailable,
382 "BILLING_STATUS_UNAVAILABLE" => Self::BillingStatusUnavailable,
383 "CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE" => {
384 Self::CloudResourceManagerBackendUnavailable
385 }
386 _ => Self::UnknownValue(code::UnknownValue(
387 wkt::internal::UnknownEnumValue::String(value.to_string()),
388 )),
389 }
390 }
391 }
392
393 impl serde::ser::Serialize for Code {
394 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
395 where
396 S: serde::Serializer,
397 {
398 match self {
399 Self::ErrorCodeUnspecified => serializer.serialize_i32(0),
400 Self::NotFound => serializer.serialize_i32(5),
401 Self::PermissionDenied => serializer.serialize_i32(7),
402 Self::ResourceExhausted => serializer.serialize_i32(8),
403 Self::ServiceNotActivated => serializer.serialize_i32(104),
404 Self::BillingDisabled => serializer.serialize_i32(107),
405 Self::ProjectDeleted => serializer.serialize_i32(108),
406 Self::ProjectInvalid => serializer.serialize_i32(114),
407 Self::ConsumerInvalid => serializer.serialize_i32(125),
408 Self::IpAddressBlocked => serializer.serialize_i32(109),
409 Self::RefererBlocked => serializer.serialize_i32(110),
410 Self::ClientAppBlocked => serializer.serialize_i32(111),
411 Self::ApiTargetBlocked => serializer.serialize_i32(122),
412 Self::ApiKeyInvalid => serializer.serialize_i32(105),
413 Self::ApiKeyExpired => serializer.serialize_i32(112),
414 Self::ApiKeyNotFound => serializer.serialize_i32(113),
415 Self::InvalidCredential => serializer.serialize_i32(123),
416 Self::NamespaceLookupUnavailable => serializer.serialize_i32(300),
417 Self::ServiceStatusUnavailable => serializer.serialize_i32(301),
418 Self::BillingStatusUnavailable => serializer.serialize_i32(302),
419 Self::CloudResourceManagerBackendUnavailable => serializer.serialize_i32(305),
420 Self::UnknownValue(u) => u.0.serialize(serializer),
421 }
422 }
423 }
424
425 impl<'de> serde::de::Deserialize<'de> for Code {
426 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
427 where
428 D: serde::Deserializer<'de>,
429 {
430 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
431 ".google.api.servicecontrol.v1.CheckError.Code",
432 ))
433 }
434 }
435}
436
437/// Distribution represents a frequency distribution of double-valued sample
438/// points. It contains the size of the population of sample points plus
439/// additional optional information:
440///
441/// * the arithmetic mean of the samples
442/// * the minimum and maximum of the samples
443/// * the sum-squared-deviation of the samples, used to compute variance
444/// * a histogram of the values of the sample points
445#[derive(Clone, Default, PartialEq)]
446#[non_exhaustive]
447pub struct Distribution {
448 /// The total number of samples in the distribution. Must be >= 0.
449 pub count: i64,
450
451 /// The arithmetic mean of the samples in the distribution. If `count` is
452 /// zero then this field must be zero.
453 pub mean: f64,
454
455 /// The minimum of the population of values. Ignored if `count` is zero.
456 pub minimum: f64,
457
458 /// The maximum of the population of values. Ignored if `count` is zero.
459 pub maximum: f64,
460
461 /// The sum of squared deviations from the mean:
462 /// Sum[i=1..count]((x_i - mean)^2)
463 /// where each x_i is a sample values. If `count` is zero then this field
464 /// must be zero, otherwise validation of the request fails.
465 pub sum_of_squared_deviation: f64,
466
467 /// The number of samples in each histogram bucket. `bucket_counts` are
468 /// optional. If present, they must sum to the `count` value.
469 ///
470 /// The buckets are defined below in `bucket_option`. There are N buckets.
471 /// `bucket_counts[0]` is the number of samples in the underflow bucket.
472 /// `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples
473 /// in each of the finite buckets. And `bucket_counts[N] is the number
474 /// of samples in the overflow bucket. See the comments of `bucket_option`
475 /// below for more details.
476 ///
477 /// Any suffix of trailing zeros may be omitted.
478 pub bucket_counts: std::vec::Vec<i64>,
479
480 /// Example points. Must be in increasing order of `value` field.
481 pub exemplars: std::vec::Vec<api::model::distribution::Exemplar>,
482
483 /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
484 /// must be both set, or both unset.
485 ///
486 /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
487 /// There must be at least two buckets (a single-bucket histogram gives
488 /// no information that isn't already provided by `count`).
489 ///
490 /// The first bucket is the underflow bucket which has a lower bound
491 /// of -inf. The last bucket is the overflow bucket which has an
492 /// upper bound of +inf. All other buckets (if any) are called "finite"
493 /// buckets because they have finite lower and upper bounds. As described
494 /// below, there are three ways to define the finite buckets.
495 ///
496 /// (1) Buckets with constant width.
497 /// (2) Buckets with exponentially growing widths.
498 /// (3) Buckets with arbitrary user-provided widths.
499 ///
500 /// In all cases, the buckets cover the entire real number line (-inf,
501 /// +inf). Bucket upper bounds are exclusive and lower bounds are
502 /// inclusive. The upper bound of the underflow bucket is equal to the
503 /// lower bound of the smallest finite bucket; the lower bound of the
504 /// overflow bucket is equal to the upper bound of the largest finite
505 /// bucket.
506 pub bucket_option: std::option::Option<crate::model::distribution::BucketOption>,
507
508 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
509}
510
511impl Distribution {
512 pub fn new() -> Self {
513 std::default::Default::default()
514 }
515
516 /// Sets the value of [count][crate::model::Distribution::count].
517 ///
518 /// # Example
519 /// ```ignore,no_run
520 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
521 /// let x = Distribution::new().set_count(42);
522 /// ```
523 pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
524 self.count = v.into();
525 self
526 }
527
528 /// Sets the value of [mean][crate::model::Distribution::mean].
529 ///
530 /// # Example
531 /// ```ignore,no_run
532 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
533 /// let x = Distribution::new().set_mean(42.0);
534 /// ```
535 pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
536 self.mean = v.into();
537 self
538 }
539
540 /// Sets the value of [minimum][crate::model::Distribution::minimum].
541 ///
542 /// # Example
543 /// ```ignore,no_run
544 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
545 /// let x = Distribution::new().set_minimum(42.0);
546 /// ```
547 pub fn set_minimum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
548 self.minimum = v.into();
549 self
550 }
551
552 /// Sets the value of [maximum][crate::model::Distribution::maximum].
553 ///
554 /// # Example
555 /// ```ignore,no_run
556 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
557 /// let x = Distribution::new().set_maximum(42.0);
558 /// ```
559 pub fn set_maximum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
560 self.maximum = v.into();
561 self
562 }
563
564 /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
565 ///
566 /// # Example
567 /// ```ignore,no_run
568 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
569 /// let x = Distribution::new().set_sum_of_squared_deviation(42.0);
570 /// ```
571 pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
572 self.sum_of_squared_deviation = v.into();
573 self
574 }
575
576 /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
577 ///
578 /// # Example
579 /// ```ignore,no_run
580 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
581 /// let x = Distribution::new().set_bucket_counts([1, 2, 3]);
582 /// ```
583 pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
584 where
585 T: std::iter::IntoIterator<Item = V>,
586 V: std::convert::Into<i64>,
587 {
588 use std::iter::Iterator;
589 self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
590 self
591 }
592
593 /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
594 ///
595 /// # Example
596 /// ```ignore,no_run
597 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
598 /// use api::model::distribution::Exemplar;
599 /// let x = Distribution::new()
600 /// .set_exemplars([
601 /// Exemplar::default()/* use setters */,
602 /// Exemplar::default()/* use (different) setters */,
603 /// ]);
604 /// ```
605 pub fn set_exemplars<T, V>(mut self, v: T) -> Self
606 where
607 T: std::iter::IntoIterator<Item = V>,
608 V: std::convert::Into<api::model::distribution::Exemplar>,
609 {
610 use std::iter::Iterator;
611 self.exemplars = v.into_iter().map(|i| i.into()).collect();
612 self
613 }
614
615 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option].
616 ///
617 /// Note that all the setters affecting `bucket_option` are mutually
618 /// exclusive.
619 ///
620 /// # Example
621 /// ```ignore,no_run
622 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
623 /// use google_cloud_api_servicecontrol_v1::model::distribution::LinearBuckets;
624 /// let x = Distribution::new().set_bucket_option(Some(
625 /// google_cloud_api_servicecontrol_v1::model::distribution::BucketOption::LinearBuckets(LinearBuckets::default().into())));
626 /// ```
627 pub fn set_bucket_option<
628 T: std::convert::Into<std::option::Option<crate::model::distribution::BucketOption>>,
629 >(
630 mut self,
631 v: T,
632 ) -> Self {
633 self.bucket_option = v.into();
634 self
635 }
636
637 /// The value of [bucket_option][crate::model::Distribution::bucket_option]
638 /// if it holds a `LinearBuckets`, `None` if the field is not set or
639 /// holds a different branch.
640 pub fn linear_buckets(
641 &self,
642 ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::LinearBuckets>> {
643 #[allow(unreachable_patterns)]
644 self.bucket_option.as_ref().and_then(|v| match v {
645 crate::model::distribution::BucketOption::LinearBuckets(v) => {
646 std::option::Option::Some(v)
647 }
648 _ => std::option::Option::None,
649 })
650 }
651
652 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
653 /// to hold a `LinearBuckets`.
654 ///
655 /// Note that all the setters affecting `bucket_option` are
656 /// mutually exclusive.
657 ///
658 /// # Example
659 /// ```ignore,no_run
660 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
661 /// use google_cloud_api_servicecontrol_v1::model::distribution::LinearBuckets;
662 /// let x = Distribution::new().set_linear_buckets(LinearBuckets::default()/* use setters */);
663 /// assert!(x.linear_buckets().is_some());
664 /// assert!(x.exponential_buckets().is_none());
665 /// assert!(x.explicit_buckets().is_none());
666 /// ```
667 pub fn set_linear_buckets<
668 T: std::convert::Into<std::boxed::Box<crate::model::distribution::LinearBuckets>>,
669 >(
670 mut self,
671 v: T,
672 ) -> Self {
673 self.bucket_option = std::option::Option::Some(
674 crate::model::distribution::BucketOption::LinearBuckets(v.into()),
675 );
676 self
677 }
678
679 /// The value of [bucket_option][crate::model::Distribution::bucket_option]
680 /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
681 /// holds a different branch.
682 pub fn exponential_buckets(
683 &self,
684 ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExponentialBuckets>> {
685 #[allow(unreachable_patterns)]
686 self.bucket_option.as_ref().and_then(|v| match v {
687 crate::model::distribution::BucketOption::ExponentialBuckets(v) => {
688 std::option::Option::Some(v)
689 }
690 _ => std::option::Option::None,
691 })
692 }
693
694 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
695 /// to hold a `ExponentialBuckets`.
696 ///
697 /// Note that all the setters affecting `bucket_option` are
698 /// mutually exclusive.
699 ///
700 /// # Example
701 /// ```ignore,no_run
702 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
703 /// use google_cloud_api_servicecontrol_v1::model::distribution::ExponentialBuckets;
704 /// let x = Distribution::new().set_exponential_buckets(ExponentialBuckets::default()/* use setters */);
705 /// assert!(x.exponential_buckets().is_some());
706 /// assert!(x.linear_buckets().is_none());
707 /// assert!(x.explicit_buckets().is_none());
708 /// ```
709 pub fn set_exponential_buckets<
710 T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExponentialBuckets>>,
711 >(
712 mut self,
713 v: T,
714 ) -> Self {
715 self.bucket_option = std::option::Option::Some(
716 crate::model::distribution::BucketOption::ExponentialBuckets(v.into()),
717 );
718 self
719 }
720
721 /// The value of [bucket_option][crate::model::Distribution::bucket_option]
722 /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
723 /// holds a different branch.
724 pub fn explicit_buckets(
725 &self,
726 ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExplicitBuckets>> {
727 #[allow(unreachable_patterns)]
728 self.bucket_option.as_ref().and_then(|v| match v {
729 crate::model::distribution::BucketOption::ExplicitBuckets(v) => {
730 std::option::Option::Some(v)
731 }
732 _ => std::option::Option::None,
733 })
734 }
735
736 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
737 /// to hold a `ExplicitBuckets`.
738 ///
739 /// Note that all the setters affecting `bucket_option` are
740 /// mutually exclusive.
741 ///
742 /// # Example
743 /// ```ignore,no_run
744 /// # use google_cloud_api_servicecontrol_v1::model::Distribution;
745 /// use google_cloud_api_servicecontrol_v1::model::distribution::ExplicitBuckets;
746 /// let x = Distribution::new().set_explicit_buckets(ExplicitBuckets::default()/* use setters */);
747 /// assert!(x.explicit_buckets().is_some());
748 /// assert!(x.linear_buckets().is_none());
749 /// assert!(x.exponential_buckets().is_none());
750 /// ```
751 pub fn set_explicit_buckets<
752 T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExplicitBuckets>>,
753 >(
754 mut self,
755 v: T,
756 ) -> Self {
757 self.bucket_option = std::option::Option::Some(
758 crate::model::distribution::BucketOption::ExplicitBuckets(v.into()),
759 );
760 self
761 }
762}
763
764impl wkt::message::Message for Distribution {
765 fn typename() -> &'static str {
766 "type.googleapis.com/google.api.servicecontrol.v1.Distribution"
767 }
768}
769
770/// Defines additional types related to [Distribution].
771pub mod distribution {
772 #[allow(unused_imports)]
773 use super::*;
774
775 /// Describing buckets with constant width.
776 #[derive(Clone, Default, PartialEq)]
777 #[non_exhaustive]
778 pub struct LinearBuckets {
779 /// The number of finite buckets. With the underflow and overflow buckets,
780 /// the total number of buckets is `num_finite_buckets` + 2.
781 /// See comments on `bucket_options` for details.
782 pub num_finite_buckets: i32,
783
784 /// The i'th linear bucket covers the interval
785 /// [offset + (i-1) * width, offset + i * width)
786 /// where i ranges from 1 to num_finite_buckets, inclusive.
787 /// Must be strictly positive.
788 pub width: f64,
789
790 /// The i'th linear bucket covers the interval
791 /// [offset + (i-1) * width, offset + i * width)
792 /// where i ranges from 1 to num_finite_buckets, inclusive.
793 pub offset: f64,
794
795 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
796 }
797
798 impl LinearBuckets {
799 pub fn new() -> Self {
800 std::default::Default::default()
801 }
802
803 /// Sets the value of [num_finite_buckets][crate::model::distribution::LinearBuckets::num_finite_buckets].
804 ///
805 /// # Example
806 /// ```ignore,no_run
807 /// # use google_cloud_api_servicecontrol_v1::model::distribution::LinearBuckets;
808 /// let x = LinearBuckets::new().set_num_finite_buckets(42);
809 /// ```
810 pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
811 self.num_finite_buckets = v.into();
812 self
813 }
814
815 /// Sets the value of [width][crate::model::distribution::LinearBuckets::width].
816 ///
817 /// # Example
818 /// ```ignore,no_run
819 /// # use google_cloud_api_servicecontrol_v1::model::distribution::LinearBuckets;
820 /// let x = LinearBuckets::new().set_width(42.0);
821 /// ```
822 pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
823 self.width = v.into();
824 self
825 }
826
827 /// Sets the value of [offset][crate::model::distribution::LinearBuckets::offset].
828 ///
829 /// # Example
830 /// ```ignore,no_run
831 /// # use google_cloud_api_servicecontrol_v1::model::distribution::LinearBuckets;
832 /// let x = LinearBuckets::new().set_offset(42.0);
833 /// ```
834 pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
835 self.offset = v.into();
836 self
837 }
838 }
839
840 impl wkt::message::Message for LinearBuckets {
841 fn typename() -> &'static str {
842 "type.googleapis.com/google.api.servicecontrol.v1.Distribution.LinearBuckets"
843 }
844 }
845
846 /// Describing buckets with exponentially growing width.
847 #[derive(Clone, Default, PartialEq)]
848 #[non_exhaustive]
849 pub struct ExponentialBuckets {
850 /// The number of finite buckets. With the underflow and overflow buckets,
851 /// the total number of buckets is `num_finite_buckets` + 2.
852 /// See comments on `bucket_options` for details.
853 pub num_finite_buckets: i32,
854
855 /// The i'th exponential bucket covers the interval
856 /// [scale * growth_factor^(i-1), scale * growth_factor^i)
857 /// where i ranges from 1 to num_finite_buckets inclusive.
858 /// Must be larger than 1.0.
859 pub growth_factor: f64,
860
861 /// The i'th exponential bucket covers the interval
862 /// [scale * growth_factor^(i-1), scale * growth_factor^i)
863 /// where i ranges from 1 to num_finite_buckets inclusive.
864 /// Must be > 0.
865 pub scale: f64,
866
867 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
868 }
869
870 impl ExponentialBuckets {
871 pub fn new() -> Self {
872 std::default::Default::default()
873 }
874
875 /// Sets the value of [num_finite_buckets][crate::model::distribution::ExponentialBuckets::num_finite_buckets].
876 ///
877 /// # Example
878 /// ```ignore,no_run
879 /// # use google_cloud_api_servicecontrol_v1::model::distribution::ExponentialBuckets;
880 /// let x = ExponentialBuckets::new().set_num_finite_buckets(42);
881 /// ```
882 pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
883 self.num_finite_buckets = v.into();
884 self
885 }
886
887 /// Sets the value of [growth_factor][crate::model::distribution::ExponentialBuckets::growth_factor].
888 ///
889 /// # Example
890 /// ```ignore,no_run
891 /// # use google_cloud_api_servicecontrol_v1::model::distribution::ExponentialBuckets;
892 /// let x = ExponentialBuckets::new().set_growth_factor(42.0);
893 /// ```
894 pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
895 self.growth_factor = v.into();
896 self
897 }
898
899 /// Sets the value of [scale][crate::model::distribution::ExponentialBuckets::scale].
900 ///
901 /// # Example
902 /// ```ignore,no_run
903 /// # use google_cloud_api_servicecontrol_v1::model::distribution::ExponentialBuckets;
904 /// let x = ExponentialBuckets::new().set_scale(42.0);
905 /// ```
906 pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
907 self.scale = v.into();
908 self
909 }
910 }
911
912 impl wkt::message::Message for ExponentialBuckets {
913 fn typename() -> &'static str {
914 "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExponentialBuckets"
915 }
916 }
917
918 /// Describing buckets with arbitrary user-provided width.
919 #[derive(Clone, Default, PartialEq)]
920 #[non_exhaustive]
921 pub struct ExplicitBuckets {
922 /// 'bound' is a list of strictly increasing boundaries between
923 /// buckets. Note that a list of length N-1 defines N buckets because
924 /// of fenceposting. See comments on `bucket_options` for details.
925 ///
926 /// The i'th finite bucket covers the interval
927 /// [bound[i-1], bound[i])
928 /// where i ranges from 1 to bound_size() - 1. Note that there are no
929 /// finite buckets at all if 'bound' only contains a single element; in
930 /// that special case the single bound defines the boundary between the
931 /// underflow and overflow buckets.
932 ///
933 /// bucket number lower bound upper bound
934 /// i == 0 (underflow) -inf bound[i]
935 /// 0 < i < bound_size() bound[i-1] bound[i]
936 /// i == bound_size() (overflow) bound[i-1] +inf
937 pub bounds: std::vec::Vec<f64>,
938
939 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
940 }
941
942 impl ExplicitBuckets {
943 pub fn new() -> Self {
944 std::default::Default::default()
945 }
946
947 /// Sets the value of [bounds][crate::model::distribution::ExplicitBuckets::bounds].
948 ///
949 /// # Example
950 /// ```ignore,no_run
951 /// # use google_cloud_api_servicecontrol_v1::model::distribution::ExplicitBuckets;
952 /// let x = ExplicitBuckets::new().set_bounds([1.0, 2.0, 3.0]);
953 /// ```
954 pub fn set_bounds<T, V>(mut self, v: T) -> Self
955 where
956 T: std::iter::IntoIterator<Item = V>,
957 V: std::convert::Into<f64>,
958 {
959 use std::iter::Iterator;
960 self.bounds = v.into_iter().map(|i| i.into()).collect();
961 self
962 }
963 }
964
965 impl wkt::message::Message for ExplicitBuckets {
966 fn typename() -> &'static str {
967 "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExplicitBuckets"
968 }
969 }
970
971 /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
972 /// must be both set, or both unset.
973 ///
974 /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
975 /// There must be at least two buckets (a single-bucket histogram gives
976 /// no information that isn't already provided by `count`).
977 ///
978 /// The first bucket is the underflow bucket which has a lower bound
979 /// of -inf. The last bucket is the overflow bucket which has an
980 /// upper bound of +inf. All other buckets (if any) are called "finite"
981 /// buckets because they have finite lower and upper bounds. As described
982 /// below, there are three ways to define the finite buckets.
983 ///
984 /// (1) Buckets with constant width.
985 /// (2) Buckets with exponentially growing widths.
986 /// (3) Buckets with arbitrary user-provided widths.
987 ///
988 /// In all cases, the buckets cover the entire real number line (-inf,
989 /// +inf). Bucket upper bounds are exclusive and lower bounds are
990 /// inclusive. The upper bound of the underflow bucket is equal to the
991 /// lower bound of the smallest finite bucket; the lower bound of the
992 /// overflow bucket is equal to the upper bound of the largest finite
993 /// bucket.
994 #[derive(Clone, Debug, PartialEq)]
995 #[non_exhaustive]
996 pub enum BucketOption {
997 /// Buckets with constant width.
998 LinearBuckets(std::boxed::Box<crate::model::distribution::LinearBuckets>),
999 /// Buckets with exponentially growing width.
1000 ExponentialBuckets(std::boxed::Box<crate::model::distribution::ExponentialBuckets>),
1001 /// Buckets with arbitrary user-provided width.
1002 ExplicitBuckets(std::boxed::Box<crate::model::distribution::ExplicitBuckets>),
1003 }
1004}
1005
1006/// A common proto for logging HTTP requests. Only contains semantics
1007/// defined by the HTTP specification. Product-specific logging
1008/// information MUST be defined in a separate message.
1009#[derive(Clone, Default, PartialEq)]
1010#[non_exhaustive]
1011pub struct HttpRequest {
1012 /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
1013 pub request_method: std::string::String,
1014
1015 /// The scheme (http, https), the host name, the path, and the query
1016 /// portion of the URL that was requested.
1017 /// Example: ``http://example.com/some/info?color=red``.
1018 pub request_url: std::string::String,
1019
1020 /// The size of the HTTP request message in bytes, including the request
1021 /// headers and the request body.
1022 pub request_size: i64,
1023
1024 /// The response code indicating the status of the response.
1025 /// Examples: 200, 404.
1026 pub status: i32,
1027
1028 /// The size of the HTTP response message sent back to the client, in bytes,
1029 /// including the response headers and the response body.
1030 pub response_size: i64,
1031
1032 /// The user agent sent by the client. Example:
1033 /// `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
1034 /// CLR 1.0.3705)"`.
1035 pub user_agent: std::string::String,
1036
1037 /// The IP address (IPv4 or IPv6) of the client that issued the HTTP
1038 /// request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
1039 pub remote_ip: std::string::String,
1040
1041 /// The IP address (IPv4 or IPv6) of the origin server that the request was
1042 /// sent to.
1043 pub server_ip: std::string::String,
1044
1045 /// The referer URL of the request, as defined in
1046 /// [HTTP/1.1 Header Field
1047 /// Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
1048 pub referer: std::string::String,
1049
1050 /// The request processing latency on the server, from the time the request was
1051 /// received until the response was sent.
1052 pub latency: std::option::Option<wkt::Duration>,
1053
1054 /// Whether or not a cache lookup was attempted.
1055 pub cache_lookup: bool,
1056
1057 /// Whether or not an entity was served from cache
1058 /// (with or without validation).
1059 pub cache_hit: bool,
1060
1061 /// Whether or not the response was validated with the origin server before
1062 /// being served from cache. This field is only meaningful if `cache_hit` is
1063 /// True.
1064 pub cache_validated_with_origin_server: bool,
1065
1066 /// The number of HTTP response bytes inserted into cache. Set only when a
1067 /// cache fill was attempted.
1068 pub cache_fill_bytes: i64,
1069
1070 /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
1071 pub protocol: std::string::String,
1072
1073 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1074}
1075
1076impl HttpRequest {
1077 pub fn new() -> Self {
1078 std::default::Default::default()
1079 }
1080
1081 /// Sets the value of [request_method][crate::model::HttpRequest::request_method].
1082 ///
1083 /// # Example
1084 /// ```ignore,no_run
1085 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1086 /// let x = HttpRequest::new().set_request_method("example");
1087 /// ```
1088 pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1089 self.request_method = v.into();
1090 self
1091 }
1092
1093 /// Sets the value of [request_url][crate::model::HttpRequest::request_url].
1094 ///
1095 /// # Example
1096 /// ```ignore,no_run
1097 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1098 /// let x = HttpRequest::new().set_request_url("example");
1099 /// ```
1100 pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1101 self.request_url = v.into();
1102 self
1103 }
1104
1105 /// Sets the value of [request_size][crate::model::HttpRequest::request_size].
1106 ///
1107 /// # Example
1108 /// ```ignore,no_run
1109 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1110 /// let x = HttpRequest::new().set_request_size(42);
1111 /// ```
1112 pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1113 self.request_size = v.into();
1114 self
1115 }
1116
1117 /// Sets the value of [status][crate::model::HttpRequest::status].
1118 ///
1119 /// # Example
1120 /// ```ignore,no_run
1121 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1122 /// let x = HttpRequest::new().set_status(42);
1123 /// ```
1124 pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1125 self.status = v.into();
1126 self
1127 }
1128
1129 /// Sets the value of [response_size][crate::model::HttpRequest::response_size].
1130 ///
1131 /// # Example
1132 /// ```ignore,no_run
1133 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1134 /// let x = HttpRequest::new().set_response_size(42);
1135 /// ```
1136 pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1137 self.response_size = v.into();
1138 self
1139 }
1140
1141 /// Sets the value of [user_agent][crate::model::HttpRequest::user_agent].
1142 ///
1143 /// # Example
1144 /// ```ignore,no_run
1145 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1146 /// let x = HttpRequest::new().set_user_agent("example");
1147 /// ```
1148 pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1149 self.user_agent = v.into();
1150 self
1151 }
1152
1153 /// Sets the value of [remote_ip][crate::model::HttpRequest::remote_ip].
1154 ///
1155 /// # Example
1156 /// ```ignore,no_run
1157 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1158 /// let x = HttpRequest::new().set_remote_ip("example");
1159 /// ```
1160 pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1161 self.remote_ip = v.into();
1162 self
1163 }
1164
1165 /// Sets the value of [server_ip][crate::model::HttpRequest::server_ip].
1166 ///
1167 /// # Example
1168 /// ```ignore,no_run
1169 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1170 /// let x = HttpRequest::new().set_server_ip("example");
1171 /// ```
1172 pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1173 self.server_ip = v.into();
1174 self
1175 }
1176
1177 /// Sets the value of [referer][crate::model::HttpRequest::referer].
1178 ///
1179 /// # Example
1180 /// ```ignore,no_run
1181 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1182 /// let x = HttpRequest::new().set_referer("example");
1183 /// ```
1184 pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1185 self.referer = v.into();
1186 self
1187 }
1188
1189 /// Sets the value of [latency][crate::model::HttpRequest::latency].
1190 ///
1191 /// # Example
1192 /// ```ignore,no_run
1193 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1194 /// use wkt::Duration;
1195 /// let x = HttpRequest::new().set_latency(Duration::default()/* use setters */);
1196 /// ```
1197 pub fn set_latency<T>(mut self, v: T) -> Self
1198 where
1199 T: std::convert::Into<wkt::Duration>,
1200 {
1201 self.latency = std::option::Option::Some(v.into());
1202 self
1203 }
1204
1205 /// Sets or clears the value of [latency][crate::model::HttpRequest::latency].
1206 ///
1207 /// # Example
1208 /// ```ignore,no_run
1209 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1210 /// use wkt::Duration;
1211 /// let x = HttpRequest::new().set_or_clear_latency(Some(Duration::default()/* use setters */));
1212 /// let x = HttpRequest::new().set_or_clear_latency(None::<Duration>);
1213 /// ```
1214 pub fn set_or_clear_latency<T>(mut self, v: std::option::Option<T>) -> Self
1215 where
1216 T: std::convert::Into<wkt::Duration>,
1217 {
1218 self.latency = v.map(|x| x.into());
1219 self
1220 }
1221
1222 /// Sets the value of [cache_lookup][crate::model::HttpRequest::cache_lookup].
1223 ///
1224 /// # Example
1225 /// ```ignore,no_run
1226 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1227 /// let x = HttpRequest::new().set_cache_lookup(true);
1228 /// ```
1229 pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1230 self.cache_lookup = v.into();
1231 self
1232 }
1233
1234 /// Sets the value of [cache_hit][crate::model::HttpRequest::cache_hit].
1235 ///
1236 /// # Example
1237 /// ```ignore,no_run
1238 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1239 /// let x = HttpRequest::new().set_cache_hit(true);
1240 /// ```
1241 pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1242 self.cache_hit = v.into();
1243 self
1244 }
1245
1246 /// Sets the value of [cache_validated_with_origin_server][crate::model::HttpRequest::cache_validated_with_origin_server].
1247 ///
1248 /// # Example
1249 /// ```ignore,no_run
1250 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1251 /// let x = HttpRequest::new().set_cache_validated_with_origin_server(true);
1252 /// ```
1253 pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
1254 mut self,
1255 v: T,
1256 ) -> Self {
1257 self.cache_validated_with_origin_server = v.into();
1258 self
1259 }
1260
1261 /// Sets the value of [cache_fill_bytes][crate::model::HttpRequest::cache_fill_bytes].
1262 ///
1263 /// # Example
1264 /// ```ignore,no_run
1265 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1266 /// let x = HttpRequest::new().set_cache_fill_bytes(42);
1267 /// ```
1268 pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1269 self.cache_fill_bytes = v.into();
1270 self
1271 }
1272
1273 /// Sets the value of [protocol][crate::model::HttpRequest::protocol].
1274 ///
1275 /// # Example
1276 /// ```ignore,no_run
1277 /// # use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1278 /// let x = HttpRequest::new().set_protocol("example");
1279 /// ```
1280 pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1281 self.protocol = v.into();
1282 self
1283 }
1284}
1285
1286impl wkt::message::Message for HttpRequest {
1287 fn typename() -> &'static str {
1288 "type.googleapis.com/google.api.servicecontrol.v1.HttpRequest"
1289 }
1290}
1291
1292/// An individual log entry.
1293#[derive(Clone, Default, PartialEq)]
1294#[non_exhaustive]
1295pub struct LogEntry {
1296 /// Required. The log to which this log entry belongs. Examples: `"syslog"`,
1297 /// `"book_log"`.
1298 pub name: std::string::String,
1299
1300 /// The time the event described by the log entry occurred. If
1301 /// omitted, defaults to operation start time.
1302 pub timestamp: std::option::Option<wkt::Timestamp>,
1303
1304 /// The severity of the log entry. The default value is
1305 /// `LogSeverity.DEFAULT`.
1306 pub severity: logging_type::model::LogSeverity,
1307
1308 /// Optional. Information about the HTTP request associated with this
1309 /// log entry, if applicable.
1310 pub http_request: std::option::Option<crate::model::HttpRequest>,
1311
1312 /// Optional. Resource name of the trace associated with the log entry, if any.
1313 /// If this field contains a relative resource name, you can assume the name is
1314 /// relative to `//tracing.googleapis.com`. Example:
1315 /// `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824`
1316 pub trace: std::string::String,
1317
1318 /// A unique ID for the log entry used for deduplication. If omitted,
1319 /// the implementation will generate one based on operation_id.
1320 pub insert_id: std::string::String,
1321
1322 /// A set of user-defined (key, value) data that provides additional
1323 /// information about the log entry.
1324 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
1325
1326 /// Optional. Information about an operation associated with the log entry, if
1327 /// applicable.
1328 pub operation: std::option::Option<crate::model::LogEntryOperation>,
1329
1330 /// Optional. Source code location information associated with the log entry,
1331 /// if any.
1332 pub source_location: std::option::Option<crate::model::LogEntrySourceLocation>,
1333
1334 /// The log entry payload, which can be one of multiple types.
1335 pub payload: std::option::Option<crate::model::log_entry::Payload>,
1336
1337 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1338}
1339
1340impl LogEntry {
1341 pub fn new() -> Self {
1342 std::default::Default::default()
1343 }
1344
1345 /// Sets the value of [name][crate::model::LogEntry::name].
1346 ///
1347 /// # Example
1348 /// ```ignore,no_run
1349 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1350 /// let x = LogEntry::new().set_name("example");
1351 /// ```
1352 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1353 self.name = v.into();
1354 self
1355 }
1356
1357 /// Sets the value of [timestamp][crate::model::LogEntry::timestamp].
1358 ///
1359 /// # Example
1360 /// ```ignore,no_run
1361 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1362 /// use wkt::Timestamp;
1363 /// let x = LogEntry::new().set_timestamp(Timestamp::default()/* use setters */);
1364 /// ```
1365 pub fn set_timestamp<T>(mut self, v: T) -> Self
1366 where
1367 T: std::convert::Into<wkt::Timestamp>,
1368 {
1369 self.timestamp = std::option::Option::Some(v.into());
1370 self
1371 }
1372
1373 /// Sets or clears the value of [timestamp][crate::model::LogEntry::timestamp].
1374 ///
1375 /// # Example
1376 /// ```ignore,no_run
1377 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1378 /// use wkt::Timestamp;
1379 /// let x = LogEntry::new().set_or_clear_timestamp(Some(Timestamp::default()/* use setters */));
1380 /// let x = LogEntry::new().set_or_clear_timestamp(None::<Timestamp>);
1381 /// ```
1382 pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1383 where
1384 T: std::convert::Into<wkt::Timestamp>,
1385 {
1386 self.timestamp = v.map(|x| x.into());
1387 self
1388 }
1389
1390 /// Sets the value of [severity][crate::model::LogEntry::severity].
1391 ///
1392 /// # Example
1393 /// ```ignore,no_run
1394 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1395 /// use logging_type::model::LogSeverity;
1396 /// let x0 = LogEntry::new().set_severity(LogSeverity::Debug);
1397 /// let x1 = LogEntry::new().set_severity(LogSeverity::Info);
1398 /// let x2 = LogEntry::new().set_severity(LogSeverity::Notice);
1399 /// ```
1400 pub fn set_severity<T: std::convert::Into<logging_type::model::LogSeverity>>(
1401 mut self,
1402 v: T,
1403 ) -> Self {
1404 self.severity = v.into();
1405 self
1406 }
1407
1408 /// Sets the value of [http_request][crate::model::LogEntry::http_request].
1409 ///
1410 /// # Example
1411 /// ```ignore,no_run
1412 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1413 /// use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1414 /// let x = LogEntry::new().set_http_request(HttpRequest::default()/* use setters */);
1415 /// ```
1416 pub fn set_http_request<T>(mut self, v: T) -> Self
1417 where
1418 T: std::convert::Into<crate::model::HttpRequest>,
1419 {
1420 self.http_request = std::option::Option::Some(v.into());
1421 self
1422 }
1423
1424 /// Sets or clears the value of [http_request][crate::model::LogEntry::http_request].
1425 ///
1426 /// # Example
1427 /// ```ignore,no_run
1428 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1429 /// use google_cloud_api_servicecontrol_v1::model::HttpRequest;
1430 /// let x = LogEntry::new().set_or_clear_http_request(Some(HttpRequest::default()/* use setters */));
1431 /// let x = LogEntry::new().set_or_clear_http_request(None::<HttpRequest>);
1432 /// ```
1433 pub fn set_or_clear_http_request<T>(mut self, v: std::option::Option<T>) -> Self
1434 where
1435 T: std::convert::Into<crate::model::HttpRequest>,
1436 {
1437 self.http_request = v.map(|x| x.into());
1438 self
1439 }
1440
1441 /// Sets the value of [trace][crate::model::LogEntry::trace].
1442 ///
1443 /// # Example
1444 /// ```ignore,no_run
1445 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1446 /// let x = LogEntry::new().set_trace("example");
1447 /// ```
1448 pub fn set_trace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1449 self.trace = v.into();
1450 self
1451 }
1452
1453 /// Sets the value of [insert_id][crate::model::LogEntry::insert_id].
1454 ///
1455 /// # Example
1456 /// ```ignore,no_run
1457 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1458 /// let x = LogEntry::new().set_insert_id("example");
1459 /// ```
1460 pub fn set_insert_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1461 self.insert_id = v.into();
1462 self
1463 }
1464
1465 /// Sets the value of [labels][crate::model::LogEntry::labels].
1466 ///
1467 /// # Example
1468 /// ```ignore,no_run
1469 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1470 /// let x = LogEntry::new().set_labels([
1471 /// ("key0", "abc"),
1472 /// ("key1", "xyz"),
1473 /// ]);
1474 /// ```
1475 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
1476 where
1477 T: std::iter::IntoIterator<Item = (K, V)>,
1478 K: std::convert::Into<std::string::String>,
1479 V: std::convert::Into<std::string::String>,
1480 {
1481 use std::iter::Iterator;
1482 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1483 self
1484 }
1485
1486 /// Sets the value of [operation][crate::model::LogEntry::operation].
1487 ///
1488 /// # Example
1489 /// ```ignore,no_run
1490 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1491 /// use google_cloud_api_servicecontrol_v1::model::LogEntryOperation;
1492 /// let x = LogEntry::new().set_operation(LogEntryOperation::default()/* use setters */);
1493 /// ```
1494 pub fn set_operation<T>(mut self, v: T) -> Self
1495 where
1496 T: std::convert::Into<crate::model::LogEntryOperation>,
1497 {
1498 self.operation = std::option::Option::Some(v.into());
1499 self
1500 }
1501
1502 /// Sets or clears the value of [operation][crate::model::LogEntry::operation].
1503 ///
1504 /// # Example
1505 /// ```ignore,no_run
1506 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1507 /// use google_cloud_api_servicecontrol_v1::model::LogEntryOperation;
1508 /// let x = LogEntry::new().set_or_clear_operation(Some(LogEntryOperation::default()/* use setters */));
1509 /// let x = LogEntry::new().set_or_clear_operation(None::<LogEntryOperation>);
1510 /// ```
1511 pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
1512 where
1513 T: std::convert::Into<crate::model::LogEntryOperation>,
1514 {
1515 self.operation = v.map(|x| x.into());
1516 self
1517 }
1518
1519 /// Sets the value of [source_location][crate::model::LogEntry::source_location].
1520 ///
1521 /// # Example
1522 /// ```ignore,no_run
1523 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1524 /// use google_cloud_api_servicecontrol_v1::model::LogEntrySourceLocation;
1525 /// let x = LogEntry::new().set_source_location(LogEntrySourceLocation::default()/* use setters */);
1526 /// ```
1527 pub fn set_source_location<T>(mut self, v: T) -> Self
1528 where
1529 T: std::convert::Into<crate::model::LogEntrySourceLocation>,
1530 {
1531 self.source_location = std::option::Option::Some(v.into());
1532 self
1533 }
1534
1535 /// Sets or clears the value of [source_location][crate::model::LogEntry::source_location].
1536 ///
1537 /// # Example
1538 /// ```ignore,no_run
1539 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1540 /// use google_cloud_api_servicecontrol_v1::model::LogEntrySourceLocation;
1541 /// let x = LogEntry::new().set_or_clear_source_location(Some(LogEntrySourceLocation::default()/* use setters */));
1542 /// let x = LogEntry::new().set_or_clear_source_location(None::<LogEntrySourceLocation>);
1543 /// ```
1544 pub fn set_or_clear_source_location<T>(mut self, v: std::option::Option<T>) -> Self
1545 where
1546 T: std::convert::Into<crate::model::LogEntrySourceLocation>,
1547 {
1548 self.source_location = v.map(|x| x.into());
1549 self
1550 }
1551
1552 /// Sets the value of [payload][crate::model::LogEntry::payload].
1553 ///
1554 /// Note that all the setters affecting `payload` are mutually
1555 /// exclusive.
1556 ///
1557 /// # Example
1558 /// ```ignore,no_run
1559 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1560 /// use google_cloud_api_servicecontrol_v1::model::log_entry::Payload;
1561 /// let x = LogEntry::new().set_payload(Some(Payload::TextPayload("example".to_string())));
1562 /// ```
1563 pub fn set_payload<
1564 T: std::convert::Into<std::option::Option<crate::model::log_entry::Payload>>,
1565 >(
1566 mut self,
1567 v: T,
1568 ) -> Self {
1569 self.payload = v.into();
1570 self
1571 }
1572
1573 /// The value of [payload][crate::model::LogEntry::payload]
1574 /// if it holds a `ProtoPayload`, `None` if the field is not set or
1575 /// holds a different branch.
1576 pub fn proto_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Any>> {
1577 #[allow(unreachable_patterns)]
1578 self.payload.as_ref().and_then(|v| match v {
1579 crate::model::log_entry::Payload::ProtoPayload(v) => std::option::Option::Some(v),
1580 _ => std::option::Option::None,
1581 })
1582 }
1583
1584 /// Sets the value of [payload][crate::model::LogEntry::payload]
1585 /// to hold a `ProtoPayload`.
1586 ///
1587 /// Note that all the setters affecting `payload` are
1588 /// mutually exclusive.
1589 ///
1590 /// # Example
1591 /// ```ignore,no_run
1592 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1593 /// use wkt::Any;
1594 /// let x = LogEntry::new().set_proto_payload(Any::default()/* use setters */);
1595 /// assert!(x.proto_payload().is_some());
1596 /// assert!(x.text_payload().is_none());
1597 /// assert!(x.struct_payload().is_none());
1598 /// ```
1599 pub fn set_proto_payload<T: std::convert::Into<std::boxed::Box<wkt::Any>>>(
1600 mut self,
1601 v: T,
1602 ) -> Self {
1603 self.payload =
1604 std::option::Option::Some(crate::model::log_entry::Payload::ProtoPayload(v.into()));
1605 self
1606 }
1607
1608 /// The value of [payload][crate::model::LogEntry::payload]
1609 /// if it holds a `TextPayload`, `None` if the field is not set or
1610 /// holds a different branch.
1611 pub fn text_payload(&self) -> std::option::Option<&std::string::String> {
1612 #[allow(unreachable_patterns)]
1613 self.payload.as_ref().and_then(|v| match v {
1614 crate::model::log_entry::Payload::TextPayload(v) => std::option::Option::Some(v),
1615 _ => std::option::Option::None,
1616 })
1617 }
1618
1619 /// Sets the value of [payload][crate::model::LogEntry::payload]
1620 /// to hold a `TextPayload`.
1621 ///
1622 /// Note that all the setters affecting `payload` are
1623 /// mutually exclusive.
1624 ///
1625 /// # Example
1626 /// ```ignore,no_run
1627 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1628 /// let x = LogEntry::new().set_text_payload("example");
1629 /// assert!(x.text_payload().is_some());
1630 /// assert!(x.proto_payload().is_none());
1631 /// assert!(x.struct_payload().is_none());
1632 /// ```
1633 pub fn set_text_payload<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1634 self.payload =
1635 std::option::Option::Some(crate::model::log_entry::Payload::TextPayload(v.into()));
1636 self
1637 }
1638
1639 /// The value of [payload][crate::model::LogEntry::payload]
1640 /// if it holds a `StructPayload`, `None` if the field is not set or
1641 /// holds a different branch.
1642 pub fn struct_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Struct>> {
1643 #[allow(unreachable_patterns)]
1644 self.payload.as_ref().and_then(|v| match v {
1645 crate::model::log_entry::Payload::StructPayload(v) => std::option::Option::Some(v),
1646 _ => std::option::Option::None,
1647 })
1648 }
1649
1650 /// Sets the value of [payload][crate::model::LogEntry::payload]
1651 /// to hold a `StructPayload`.
1652 ///
1653 /// Note that all the setters affecting `payload` are
1654 /// mutually exclusive.
1655 ///
1656 /// # Example
1657 /// ```ignore,no_run
1658 /// # use google_cloud_api_servicecontrol_v1::model::LogEntry;
1659 /// use wkt::Struct;
1660 /// let x = LogEntry::new().set_struct_payload(Struct::default()/* use setters */);
1661 /// assert!(x.struct_payload().is_some());
1662 /// assert!(x.proto_payload().is_none());
1663 /// assert!(x.text_payload().is_none());
1664 /// ```
1665 pub fn set_struct_payload<T: std::convert::Into<std::boxed::Box<wkt::Struct>>>(
1666 mut self,
1667 v: T,
1668 ) -> Self {
1669 self.payload =
1670 std::option::Option::Some(crate::model::log_entry::Payload::StructPayload(v.into()));
1671 self
1672 }
1673}
1674
1675impl wkt::message::Message for LogEntry {
1676 fn typename() -> &'static str {
1677 "type.googleapis.com/google.api.servicecontrol.v1.LogEntry"
1678 }
1679}
1680
1681/// Defines additional types related to [LogEntry].
1682pub mod log_entry {
1683 #[allow(unused_imports)]
1684 use super::*;
1685
1686 /// The log entry payload, which can be one of multiple types.
1687 #[derive(Clone, Debug, PartialEq)]
1688 #[non_exhaustive]
1689 pub enum Payload {
1690 /// The log entry payload, represented as a protocol buffer that is
1691 /// expressed as a JSON object. The only accepted type currently is
1692 /// [AuditLog][google.cloud.audit.AuditLog].
1693 ProtoPayload(std::boxed::Box<wkt::Any>),
1694 /// The log entry payload, represented as a Unicode string (UTF-8).
1695 TextPayload(std::string::String),
1696 /// The log entry payload, represented as a structure that
1697 /// is expressed as a JSON object.
1698 StructPayload(std::boxed::Box<wkt::Struct>),
1699 }
1700}
1701
1702/// Additional information about a potentially long-running operation with which
1703/// a log entry is associated.
1704#[derive(Clone, Default, PartialEq)]
1705#[non_exhaustive]
1706pub struct LogEntryOperation {
1707 /// Optional. An arbitrary operation identifier. Log entries with the
1708 /// same identifier are assumed to be part of the same operation.
1709 pub id: std::string::String,
1710
1711 /// Optional. An arbitrary producer identifier. The combination of
1712 /// `id` and `producer` must be globally unique. Examples for `producer`:
1713 /// `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`.
1714 pub producer: std::string::String,
1715
1716 /// Optional. Set this to True if this is the first log entry in the operation.
1717 pub first: bool,
1718
1719 /// Optional. Set this to True if this is the last log entry in the operation.
1720 pub last: bool,
1721
1722 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1723}
1724
1725impl LogEntryOperation {
1726 pub fn new() -> Self {
1727 std::default::Default::default()
1728 }
1729
1730 /// Sets the value of [id][crate::model::LogEntryOperation::id].
1731 ///
1732 /// # Example
1733 /// ```ignore,no_run
1734 /// # use google_cloud_api_servicecontrol_v1::model::LogEntryOperation;
1735 /// let x = LogEntryOperation::new().set_id("example");
1736 /// ```
1737 pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1738 self.id = v.into();
1739 self
1740 }
1741
1742 /// Sets the value of [producer][crate::model::LogEntryOperation::producer].
1743 ///
1744 /// # Example
1745 /// ```ignore,no_run
1746 /// # use google_cloud_api_servicecontrol_v1::model::LogEntryOperation;
1747 /// let x = LogEntryOperation::new().set_producer("example");
1748 /// ```
1749 pub fn set_producer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1750 self.producer = v.into();
1751 self
1752 }
1753
1754 /// Sets the value of [first][crate::model::LogEntryOperation::first].
1755 ///
1756 /// # Example
1757 /// ```ignore,no_run
1758 /// # use google_cloud_api_servicecontrol_v1::model::LogEntryOperation;
1759 /// let x = LogEntryOperation::new().set_first(true);
1760 /// ```
1761 pub fn set_first<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1762 self.first = v.into();
1763 self
1764 }
1765
1766 /// Sets the value of [last][crate::model::LogEntryOperation::last].
1767 ///
1768 /// # Example
1769 /// ```ignore,no_run
1770 /// # use google_cloud_api_servicecontrol_v1::model::LogEntryOperation;
1771 /// let x = LogEntryOperation::new().set_last(true);
1772 /// ```
1773 pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1774 self.last = v.into();
1775 self
1776 }
1777}
1778
1779impl wkt::message::Message for LogEntryOperation {
1780 fn typename() -> &'static str {
1781 "type.googleapis.com/google.api.servicecontrol.v1.LogEntryOperation"
1782 }
1783}
1784
1785/// Additional information about the source code location that produced the log
1786/// entry.
1787#[derive(Clone, Default, PartialEq)]
1788#[non_exhaustive]
1789pub struct LogEntrySourceLocation {
1790 /// Optional. Source file name. Depending on the runtime environment, this
1791 /// might be a simple name or a fully-qualified name.
1792 pub file: std::string::String,
1793
1794 /// Optional. Line within the source file. 1-based; 0 indicates no line number
1795 /// available.
1796 pub line: i64,
1797
1798 /// Optional. Human-readable name of the function or method being invoked, with
1799 /// optional context such as the class or package name. This information may be
1800 /// used in contexts such as the logs viewer, where a file and line number are
1801 /// less meaningful. The format can vary by language. For example:
1802 /// `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function`
1803 /// (Python).
1804 pub function: std::string::String,
1805
1806 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1807}
1808
1809impl LogEntrySourceLocation {
1810 pub fn new() -> Self {
1811 std::default::Default::default()
1812 }
1813
1814 /// Sets the value of [file][crate::model::LogEntrySourceLocation::file].
1815 ///
1816 /// # Example
1817 /// ```ignore,no_run
1818 /// # use google_cloud_api_servicecontrol_v1::model::LogEntrySourceLocation;
1819 /// let x = LogEntrySourceLocation::new().set_file("example");
1820 /// ```
1821 pub fn set_file<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1822 self.file = v.into();
1823 self
1824 }
1825
1826 /// Sets the value of [line][crate::model::LogEntrySourceLocation::line].
1827 ///
1828 /// # Example
1829 /// ```ignore,no_run
1830 /// # use google_cloud_api_servicecontrol_v1::model::LogEntrySourceLocation;
1831 /// let x = LogEntrySourceLocation::new().set_line(42);
1832 /// ```
1833 pub fn set_line<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1834 self.line = v.into();
1835 self
1836 }
1837
1838 /// Sets the value of [function][crate::model::LogEntrySourceLocation::function].
1839 ///
1840 /// # Example
1841 /// ```ignore,no_run
1842 /// # use google_cloud_api_servicecontrol_v1::model::LogEntrySourceLocation;
1843 /// let x = LogEntrySourceLocation::new().set_function("example");
1844 /// ```
1845 pub fn set_function<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1846 self.function = v.into();
1847 self
1848 }
1849}
1850
1851impl wkt::message::Message for LogEntrySourceLocation {
1852 fn typename() -> &'static str {
1853 "type.googleapis.com/google.api.servicecontrol.v1.LogEntrySourceLocation"
1854 }
1855}
1856
1857/// Represents a single metric value.
1858#[derive(Clone, Default, PartialEq)]
1859#[non_exhaustive]
1860pub struct MetricValue {
1861 /// The labels describing the metric value.
1862 /// See comments on [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels] for
1863 /// the overriding relationship.
1864 /// Note that this map must not contain monitored resource labels.
1865 ///
1866 /// [google.api.servicecontrol.v1.Operation.labels]: crate::model::Operation::labels
1867 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
1868
1869 /// The start of the time period over which this metric value's measurement
1870 /// applies. The time period has different semantics for different metric
1871 /// types (cumulative, delta, and gauge). See the metric definition
1872 /// documentation in the service configuration for details. If not specified,
1873 /// [google.api.servicecontrol.v1.Operation.start_time][google.api.servicecontrol.v1.Operation.start_time] will be used.
1874 ///
1875 /// [google.api.servicecontrol.v1.Operation.start_time]: crate::model::Operation::start_time
1876 pub start_time: std::option::Option<wkt::Timestamp>,
1877
1878 /// The end of the time period over which this metric value's measurement
1879 /// applies. If not specified,
1880 /// [google.api.servicecontrol.v1.Operation.end_time][google.api.servicecontrol.v1.Operation.end_time] will be used.
1881 ///
1882 /// [google.api.servicecontrol.v1.Operation.end_time]: crate::model::Operation::end_time
1883 pub end_time: std::option::Option<wkt::Timestamp>,
1884
1885 /// The value. The type of value used in the request must
1886 /// agree with the metric definition in the service configuration, otherwise
1887 /// the MetricValue is rejected.
1888 pub value: std::option::Option<crate::model::metric_value::Value>,
1889
1890 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1891}
1892
1893impl MetricValue {
1894 pub fn new() -> Self {
1895 std::default::Default::default()
1896 }
1897
1898 /// Sets the value of [labels][crate::model::MetricValue::labels].
1899 ///
1900 /// # Example
1901 /// ```ignore,no_run
1902 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
1903 /// let x = MetricValue::new().set_labels([
1904 /// ("key0", "abc"),
1905 /// ("key1", "xyz"),
1906 /// ]);
1907 /// ```
1908 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
1909 where
1910 T: std::iter::IntoIterator<Item = (K, V)>,
1911 K: std::convert::Into<std::string::String>,
1912 V: std::convert::Into<std::string::String>,
1913 {
1914 use std::iter::Iterator;
1915 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1916 self
1917 }
1918
1919 /// Sets the value of [start_time][crate::model::MetricValue::start_time].
1920 ///
1921 /// # Example
1922 /// ```ignore,no_run
1923 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
1924 /// use wkt::Timestamp;
1925 /// let x = MetricValue::new().set_start_time(Timestamp::default()/* use setters */);
1926 /// ```
1927 pub fn set_start_time<T>(mut self, v: T) -> Self
1928 where
1929 T: std::convert::Into<wkt::Timestamp>,
1930 {
1931 self.start_time = std::option::Option::Some(v.into());
1932 self
1933 }
1934
1935 /// Sets or clears the value of [start_time][crate::model::MetricValue::start_time].
1936 ///
1937 /// # Example
1938 /// ```ignore,no_run
1939 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
1940 /// use wkt::Timestamp;
1941 /// let x = MetricValue::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
1942 /// let x = MetricValue::new().set_or_clear_start_time(None::<Timestamp>);
1943 /// ```
1944 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
1945 where
1946 T: std::convert::Into<wkt::Timestamp>,
1947 {
1948 self.start_time = v.map(|x| x.into());
1949 self
1950 }
1951
1952 /// Sets the value of [end_time][crate::model::MetricValue::end_time].
1953 ///
1954 /// # Example
1955 /// ```ignore,no_run
1956 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
1957 /// use wkt::Timestamp;
1958 /// let x = MetricValue::new().set_end_time(Timestamp::default()/* use setters */);
1959 /// ```
1960 pub fn set_end_time<T>(mut self, v: T) -> Self
1961 where
1962 T: std::convert::Into<wkt::Timestamp>,
1963 {
1964 self.end_time = std::option::Option::Some(v.into());
1965 self
1966 }
1967
1968 /// Sets or clears the value of [end_time][crate::model::MetricValue::end_time].
1969 ///
1970 /// # Example
1971 /// ```ignore,no_run
1972 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
1973 /// use wkt::Timestamp;
1974 /// let x = MetricValue::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
1975 /// let x = MetricValue::new().set_or_clear_end_time(None::<Timestamp>);
1976 /// ```
1977 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1978 where
1979 T: std::convert::Into<wkt::Timestamp>,
1980 {
1981 self.end_time = v.map(|x| x.into());
1982 self
1983 }
1984
1985 /// Sets the value of [value][crate::model::MetricValue::value].
1986 ///
1987 /// Note that all the setters affecting `value` are mutually
1988 /// exclusive.
1989 ///
1990 /// # Example
1991 /// ```ignore,no_run
1992 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
1993 /// use google_cloud_api_servicecontrol_v1::model::metric_value::Value;
1994 /// let x = MetricValue::new().set_value(Some(Value::BoolValue(true)));
1995 /// ```
1996 pub fn set_value<
1997 T: std::convert::Into<std::option::Option<crate::model::metric_value::Value>>,
1998 >(
1999 mut self,
2000 v: T,
2001 ) -> Self {
2002 self.value = v.into();
2003 self
2004 }
2005
2006 /// The value of [value][crate::model::MetricValue::value]
2007 /// if it holds a `BoolValue`, `None` if the field is not set or
2008 /// holds a different branch.
2009 pub fn bool_value(&self) -> std::option::Option<&bool> {
2010 #[allow(unreachable_patterns)]
2011 self.value.as_ref().and_then(|v| match v {
2012 crate::model::metric_value::Value::BoolValue(v) => std::option::Option::Some(v),
2013 _ => std::option::Option::None,
2014 })
2015 }
2016
2017 /// Sets the value of [value][crate::model::MetricValue::value]
2018 /// to hold a `BoolValue`.
2019 ///
2020 /// Note that all the setters affecting `value` are
2021 /// mutually exclusive.
2022 ///
2023 /// # Example
2024 /// ```ignore,no_run
2025 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
2026 /// let x = MetricValue::new().set_bool_value(true);
2027 /// assert!(x.bool_value().is_some());
2028 /// assert!(x.int64_value().is_none());
2029 /// assert!(x.double_value().is_none());
2030 /// assert!(x.string_value().is_none());
2031 /// assert!(x.distribution_value().is_none());
2032 /// ```
2033 pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2034 self.value =
2035 std::option::Option::Some(crate::model::metric_value::Value::BoolValue(v.into()));
2036 self
2037 }
2038
2039 /// The value of [value][crate::model::MetricValue::value]
2040 /// if it holds a `Int64Value`, `None` if the field is not set or
2041 /// holds a different branch.
2042 pub fn int64_value(&self) -> std::option::Option<&i64> {
2043 #[allow(unreachable_patterns)]
2044 self.value.as_ref().and_then(|v| match v {
2045 crate::model::metric_value::Value::Int64Value(v) => std::option::Option::Some(v),
2046 _ => std::option::Option::None,
2047 })
2048 }
2049
2050 /// Sets the value of [value][crate::model::MetricValue::value]
2051 /// to hold a `Int64Value`.
2052 ///
2053 /// Note that all the setters affecting `value` are
2054 /// mutually exclusive.
2055 ///
2056 /// # Example
2057 /// ```ignore,no_run
2058 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
2059 /// let x = MetricValue::new().set_int64_value(42);
2060 /// assert!(x.int64_value().is_some());
2061 /// assert!(x.bool_value().is_none());
2062 /// assert!(x.double_value().is_none());
2063 /// assert!(x.string_value().is_none());
2064 /// assert!(x.distribution_value().is_none());
2065 /// ```
2066 pub fn set_int64_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2067 self.value =
2068 std::option::Option::Some(crate::model::metric_value::Value::Int64Value(v.into()));
2069 self
2070 }
2071
2072 /// The value of [value][crate::model::MetricValue::value]
2073 /// if it holds a `DoubleValue`, `None` if the field is not set or
2074 /// holds a different branch.
2075 pub fn double_value(&self) -> std::option::Option<&f64> {
2076 #[allow(unreachable_patterns)]
2077 self.value.as_ref().and_then(|v| match v {
2078 crate::model::metric_value::Value::DoubleValue(v) => std::option::Option::Some(v),
2079 _ => std::option::Option::None,
2080 })
2081 }
2082
2083 /// Sets the value of [value][crate::model::MetricValue::value]
2084 /// to hold a `DoubleValue`.
2085 ///
2086 /// Note that all the setters affecting `value` are
2087 /// mutually exclusive.
2088 ///
2089 /// # Example
2090 /// ```ignore,no_run
2091 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
2092 /// let x = MetricValue::new().set_double_value(42.0);
2093 /// assert!(x.double_value().is_some());
2094 /// assert!(x.bool_value().is_none());
2095 /// assert!(x.int64_value().is_none());
2096 /// assert!(x.string_value().is_none());
2097 /// assert!(x.distribution_value().is_none());
2098 /// ```
2099 pub fn set_double_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2100 self.value =
2101 std::option::Option::Some(crate::model::metric_value::Value::DoubleValue(v.into()));
2102 self
2103 }
2104
2105 /// The value of [value][crate::model::MetricValue::value]
2106 /// if it holds a `StringValue`, `None` if the field is not set or
2107 /// holds a different branch.
2108 pub fn string_value(&self) -> std::option::Option<&std::string::String> {
2109 #[allow(unreachable_patterns)]
2110 self.value.as_ref().and_then(|v| match v {
2111 crate::model::metric_value::Value::StringValue(v) => std::option::Option::Some(v),
2112 _ => std::option::Option::None,
2113 })
2114 }
2115
2116 /// Sets the value of [value][crate::model::MetricValue::value]
2117 /// to hold a `StringValue`.
2118 ///
2119 /// Note that all the setters affecting `value` are
2120 /// mutually exclusive.
2121 ///
2122 /// # Example
2123 /// ```ignore,no_run
2124 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
2125 /// let x = MetricValue::new().set_string_value("example");
2126 /// assert!(x.string_value().is_some());
2127 /// assert!(x.bool_value().is_none());
2128 /// assert!(x.int64_value().is_none());
2129 /// assert!(x.double_value().is_none());
2130 /// assert!(x.distribution_value().is_none());
2131 /// ```
2132 pub fn set_string_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2133 self.value =
2134 std::option::Option::Some(crate::model::metric_value::Value::StringValue(v.into()));
2135 self
2136 }
2137
2138 /// The value of [value][crate::model::MetricValue::value]
2139 /// if it holds a `DistributionValue`, `None` if the field is not set or
2140 /// holds a different branch.
2141 pub fn distribution_value(
2142 &self,
2143 ) -> std::option::Option<&std::boxed::Box<crate::model::Distribution>> {
2144 #[allow(unreachable_patterns)]
2145 self.value.as_ref().and_then(|v| match v {
2146 crate::model::metric_value::Value::DistributionValue(v) => std::option::Option::Some(v),
2147 _ => std::option::Option::None,
2148 })
2149 }
2150
2151 /// Sets the value of [value][crate::model::MetricValue::value]
2152 /// to hold a `DistributionValue`.
2153 ///
2154 /// Note that all the setters affecting `value` are
2155 /// mutually exclusive.
2156 ///
2157 /// # Example
2158 /// ```ignore,no_run
2159 /// # use google_cloud_api_servicecontrol_v1::model::MetricValue;
2160 /// use google_cloud_api_servicecontrol_v1::model::Distribution;
2161 /// let x = MetricValue::new().set_distribution_value(Distribution::default()/* use setters */);
2162 /// assert!(x.distribution_value().is_some());
2163 /// assert!(x.bool_value().is_none());
2164 /// assert!(x.int64_value().is_none());
2165 /// assert!(x.double_value().is_none());
2166 /// assert!(x.string_value().is_none());
2167 /// ```
2168 pub fn set_distribution_value<
2169 T: std::convert::Into<std::boxed::Box<crate::model::Distribution>>,
2170 >(
2171 mut self,
2172 v: T,
2173 ) -> Self {
2174 self.value = std::option::Option::Some(
2175 crate::model::metric_value::Value::DistributionValue(v.into()),
2176 );
2177 self
2178 }
2179}
2180
2181impl wkt::message::Message for MetricValue {
2182 fn typename() -> &'static str {
2183 "type.googleapis.com/google.api.servicecontrol.v1.MetricValue"
2184 }
2185}
2186
2187/// Defines additional types related to [MetricValue].
2188pub mod metric_value {
2189 #[allow(unused_imports)]
2190 use super::*;
2191
2192 /// The value. The type of value used in the request must
2193 /// agree with the metric definition in the service configuration, otherwise
2194 /// the MetricValue is rejected.
2195 #[derive(Clone, Debug, PartialEq)]
2196 #[non_exhaustive]
2197 pub enum Value {
2198 /// A boolean value.
2199 BoolValue(bool),
2200 /// A signed 64-bit integer value.
2201 Int64Value(i64),
2202 /// A double precision floating point value.
2203 DoubleValue(f64),
2204 /// A text string value.
2205 StringValue(std::string::String),
2206 /// A distribution value.
2207 DistributionValue(std::boxed::Box<crate::model::Distribution>),
2208 }
2209}
2210
2211/// Represents a set of metric values in the same metric.
2212/// Each metric value in the set should have a unique combination of start time,
2213/// end time, and label values.
2214#[derive(Clone, Default, PartialEq)]
2215#[non_exhaustive]
2216pub struct MetricValueSet {
2217 /// The metric name defined in the service configuration.
2218 pub metric_name: std::string::String,
2219
2220 /// The values in this metric.
2221 pub metric_values: std::vec::Vec<crate::model::MetricValue>,
2222
2223 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2224}
2225
2226impl MetricValueSet {
2227 pub fn new() -> Self {
2228 std::default::Default::default()
2229 }
2230
2231 /// Sets the value of [metric_name][crate::model::MetricValueSet::metric_name].
2232 ///
2233 /// # Example
2234 /// ```ignore,no_run
2235 /// # use google_cloud_api_servicecontrol_v1::model::MetricValueSet;
2236 /// let x = MetricValueSet::new().set_metric_name("example");
2237 /// ```
2238 pub fn set_metric_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2239 self.metric_name = v.into();
2240 self
2241 }
2242
2243 /// Sets the value of [metric_values][crate::model::MetricValueSet::metric_values].
2244 ///
2245 /// # Example
2246 /// ```ignore,no_run
2247 /// # use google_cloud_api_servicecontrol_v1::model::MetricValueSet;
2248 /// use google_cloud_api_servicecontrol_v1::model::MetricValue;
2249 /// let x = MetricValueSet::new()
2250 /// .set_metric_values([
2251 /// MetricValue::default()/* use setters */,
2252 /// MetricValue::default()/* use (different) setters */,
2253 /// ]);
2254 /// ```
2255 pub fn set_metric_values<T, V>(mut self, v: T) -> Self
2256 where
2257 T: std::iter::IntoIterator<Item = V>,
2258 V: std::convert::Into<crate::model::MetricValue>,
2259 {
2260 use std::iter::Iterator;
2261 self.metric_values = v.into_iter().map(|i| i.into()).collect();
2262 self
2263 }
2264}
2265
2266impl wkt::message::Message for MetricValueSet {
2267 fn typename() -> &'static str {
2268 "type.googleapis.com/google.api.servicecontrol.v1.MetricValueSet"
2269 }
2270}
2271
2272/// Represents information regarding an operation.
2273#[derive(Clone, Default, PartialEq)]
2274#[non_exhaustive]
2275pub struct Operation {
2276 /// Identity of the operation. This must be unique within the scope of the
2277 /// service that generated the operation. If the service calls
2278 /// Check() and Report() on the same operation, the two calls should carry
2279 /// the same id.
2280 ///
2281 /// UUID version 4 is recommended, though not required.
2282 /// In scenarios where an operation is computed from existing information
2283 /// and an idempotent id is desirable for deduplication purpose, UUID version 5
2284 /// is recommended. See RFC 4122 for details.
2285 pub operation_id: std::string::String,
2286
2287 /// Fully qualified name of the operation. Reserved for future use.
2288 pub operation_name: std::string::String,
2289
2290 /// Identity of the consumer who is using the service.
2291 /// This field should be filled in for the operations initiated by a
2292 /// consumer, but not for service-initiated operations that are
2293 /// not related to a specific consumer.
2294 ///
2295 /// - This can be in one of the following formats:
2296 /// - project:PROJECT_ID,
2297 /// - project`_`number:PROJECT_NUMBER,
2298 /// - projects/PROJECT_ID or PROJECT_NUMBER,
2299 /// - folders/FOLDER_NUMBER,
2300 /// - organizations/ORGANIZATION_NUMBER,
2301 /// - api`_`key:API_KEY.
2302 pub consumer_id: std::string::String,
2303
2304 /// Required. Start time of the operation.
2305 pub start_time: std::option::Option<wkt::Timestamp>,
2306
2307 /// End time of the operation.
2308 /// Required when the operation is used in
2309 /// [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report],
2310 /// but optional when the operation is used in
2311 /// [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check].
2312 ///
2313 /// [google.api.servicecontrol.v1.ServiceController.Check]: crate::client::ServiceController::check
2314 /// [google.api.servicecontrol.v1.ServiceController.Report]: crate::client::ServiceController::report
2315 pub end_time: std::option::Option<wkt::Timestamp>,
2316
2317 /// Labels describing the operation. Only the following labels are allowed:
2318 ///
2319 /// - Labels describing monitored resources as defined in
2320 /// the service configuration.
2321 /// - Default labels of metric values. When specified, labels defined in the
2322 /// metric value override these default.
2323 /// - The following labels defined by Google Cloud Platform:
2324 /// - `cloud.googleapis.com/location` describing the location where the
2325 /// operation happened,
2326 /// - `servicecontrol.googleapis.com/user_agent` describing the user agent
2327 /// of the API request,
2328 /// - `servicecontrol.googleapis.com/service_agent` describing the service
2329 /// used to handle the API request (e.g. ESP),
2330 /// - `servicecontrol.googleapis.com/platform` describing the platform
2331 /// where the API is served, such as App Engine, Compute Engine, or
2332 /// Kubernetes Engine.
2333 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
2334
2335 /// Represents information about this operation. Each MetricValueSet
2336 /// corresponds to a metric defined in the service configuration.
2337 /// The data type used in the MetricValueSet must agree with
2338 /// the data type specified in the metric definition.
2339 ///
2340 /// Within a single operation, it is not allowed to have more than one
2341 /// MetricValue instances that have the same metric names and identical
2342 /// label value combinations. If a request has such duplicated MetricValue
2343 /// instances, the entire request is rejected with
2344 /// an invalid argument error.
2345 pub metric_value_sets: std::vec::Vec<crate::model::MetricValueSet>,
2346
2347 /// Represents information to be logged.
2348 pub log_entries: std::vec::Vec<crate::model::LogEntry>,
2349
2350 /// DO NOT USE. This is an experimental field.
2351 pub importance: crate::model::operation::Importance,
2352
2353 /// Unimplemented.
2354 pub extensions: std::vec::Vec<wkt::Any>,
2355
2356 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2357}
2358
2359impl Operation {
2360 pub fn new() -> Self {
2361 std::default::Default::default()
2362 }
2363
2364 /// Sets the value of [operation_id][crate::model::Operation::operation_id].
2365 ///
2366 /// # Example
2367 /// ```ignore,no_run
2368 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2369 /// let x = Operation::new().set_operation_id("example");
2370 /// ```
2371 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2372 self.operation_id = v.into();
2373 self
2374 }
2375
2376 /// Sets the value of [operation_name][crate::model::Operation::operation_name].
2377 ///
2378 /// # Example
2379 /// ```ignore,no_run
2380 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2381 /// let x = Operation::new().set_operation_name("example");
2382 /// ```
2383 pub fn set_operation_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2384 self.operation_name = v.into();
2385 self
2386 }
2387
2388 /// Sets the value of [consumer_id][crate::model::Operation::consumer_id].
2389 ///
2390 /// # Example
2391 /// ```ignore,no_run
2392 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2393 /// let x = Operation::new().set_consumer_id("example");
2394 /// ```
2395 pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2396 self.consumer_id = v.into();
2397 self
2398 }
2399
2400 /// Sets the value of [start_time][crate::model::Operation::start_time].
2401 ///
2402 /// # Example
2403 /// ```ignore,no_run
2404 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2405 /// use wkt::Timestamp;
2406 /// let x = Operation::new().set_start_time(Timestamp::default()/* use setters */);
2407 /// ```
2408 pub fn set_start_time<T>(mut self, v: T) -> Self
2409 where
2410 T: std::convert::Into<wkt::Timestamp>,
2411 {
2412 self.start_time = std::option::Option::Some(v.into());
2413 self
2414 }
2415
2416 /// Sets or clears the value of [start_time][crate::model::Operation::start_time].
2417 ///
2418 /// # Example
2419 /// ```ignore,no_run
2420 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2421 /// use wkt::Timestamp;
2422 /// let x = Operation::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
2423 /// let x = Operation::new().set_or_clear_start_time(None::<Timestamp>);
2424 /// ```
2425 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2426 where
2427 T: std::convert::Into<wkt::Timestamp>,
2428 {
2429 self.start_time = v.map(|x| x.into());
2430 self
2431 }
2432
2433 /// Sets the value of [end_time][crate::model::Operation::end_time].
2434 ///
2435 /// # Example
2436 /// ```ignore,no_run
2437 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2438 /// use wkt::Timestamp;
2439 /// let x = Operation::new().set_end_time(Timestamp::default()/* use setters */);
2440 /// ```
2441 pub fn set_end_time<T>(mut self, v: T) -> Self
2442 where
2443 T: std::convert::Into<wkt::Timestamp>,
2444 {
2445 self.end_time = std::option::Option::Some(v.into());
2446 self
2447 }
2448
2449 /// Sets or clears the value of [end_time][crate::model::Operation::end_time].
2450 ///
2451 /// # Example
2452 /// ```ignore,no_run
2453 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2454 /// use wkt::Timestamp;
2455 /// let x = Operation::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
2456 /// let x = Operation::new().set_or_clear_end_time(None::<Timestamp>);
2457 /// ```
2458 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2459 where
2460 T: std::convert::Into<wkt::Timestamp>,
2461 {
2462 self.end_time = v.map(|x| x.into());
2463 self
2464 }
2465
2466 /// Sets the value of [labels][crate::model::Operation::labels].
2467 ///
2468 /// # Example
2469 /// ```ignore,no_run
2470 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2471 /// let x = Operation::new().set_labels([
2472 /// ("key0", "abc"),
2473 /// ("key1", "xyz"),
2474 /// ]);
2475 /// ```
2476 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
2477 where
2478 T: std::iter::IntoIterator<Item = (K, V)>,
2479 K: std::convert::Into<std::string::String>,
2480 V: std::convert::Into<std::string::String>,
2481 {
2482 use std::iter::Iterator;
2483 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2484 self
2485 }
2486
2487 /// Sets the value of [metric_value_sets][crate::model::Operation::metric_value_sets].
2488 ///
2489 /// # Example
2490 /// ```ignore,no_run
2491 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2492 /// use google_cloud_api_servicecontrol_v1::model::MetricValueSet;
2493 /// let x = Operation::new()
2494 /// .set_metric_value_sets([
2495 /// MetricValueSet::default()/* use setters */,
2496 /// MetricValueSet::default()/* use (different) setters */,
2497 /// ]);
2498 /// ```
2499 pub fn set_metric_value_sets<T, V>(mut self, v: T) -> Self
2500 where
2501 T: std::iter::IntoIterator<Item = V>,
2502 V: std::convert::Into<crate::model::MetricValueSet>,
2503 {
2504 use std::iter::Iterator;
2505 self.metric_value_sets = v.into_iter().map(|i| i.into()).collect();
2506 self
2507 }
2508
2509 /// Sets the value of [log_entries][crate::model::Operation::log_entries].
2510 ///
2511 /// # Example
2512 /// ```ignore,no_run
2513 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2514 /// use google_cloud_api_servicecontrol_v1::model::LogEntry;
2515 /// let x = Operation::new()
2516 /// .set_log_entries([
2517 /// LogEntry::default()/* use setters */,
2518 /// LogEntry::default()/* use (different) setters */,
2519 /// ]);
2520 /// ```
2521 pub fn set_log_entries<T, V>(mut self, v: T) -> Self
2522 where
2523 T: std::iter::IntoIterator<Item = V>,
2524 V: std::convert::Into<crate::model::LogEntry>,
2525 {
2526 use std::iter::Iterator;
2527 self.log_entries = v.into_iter().map(|i| i.into()).collect();
2528 self
2529 }
2530
2531 /// Sets the value of [importance][crate::model::Operation::importance].
2532 ///
2533 /// # Example
2534 /// ```ignore,no_run
2535 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2536 /// use google_cloud_api_servicecontrol_v1::model::operation::Importance;
2537 /// let x0 = Operation::new().set_importance(Importance::High);
2538 /// ```
2539 pub fn set_importance<T: std::convert::Into<crate::model::operation::Importance>>(
2540 mut self,
2541 v: T,
2542 ) -> Self {
2543 self.importance = v.into();
2544 self
2545 }
2546
2547 /// Sets the value of [extensions][crate::model::Operation::extensions].
2548 ///
2549 /// # Example
2550 /// ```ignore,no_run
2551 /// # use google_cloud_api_servicecontrol_v1::model::Operation;
2552 /// use wkt::Any;
2553 /// let x = Operation::new()
2554 /// .set_extensions([
2555 /// Any::default()/* use setters */,
2556 /// Any::default()/* use (different) setters */,
2557 /// ]);
2558 /// ```
2559 pub fn set_extensions<T, V>(mut self, v: T) -> Self
2560 where
2561 T: std::iter::IntoIterator<Item = V>,
2562 V: std::convert::Into<wkt::Any>,
2563 {
2564 use std::iter::Iterator;
2565 self.extensions = v.into_iter().map(|i| i.into()).collect();
2566 self
2567 }
2568}
2569
2570impl wkt::message::Message for Operation {
2571 fn typename() -> &'static str {
2572 "type.googleapis.com/google.api.servicecontrol.v1.Operation"
2573 }
2574}
2575
2576/// Defines additional types related to [Operation].
2577pub mod operation {
2578 #[allow(unused_imports)]
2579 use super::*;
2580
2581 /// Defines the importance of the data contained in the operation.
2582 ///
2583 /// # Working with unknown values
2584 ///
2585 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2586 /// additional enum variants at any time. Adding new variants is not considered
2587 /// a breaking change. Applications should write their code in anticipation of:
2588 ///
2589 /// - New values appearing in future releases of the client library, **and**
2590 /// - New values received dynamically, without application changes.
2591 ///
2592 /// Please consult the [Working with enums] section in the user guide for some
2593 /// guidelines.
2594 ///
2595 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2596 #[derive(Clone, Debug, PartialEq)]
2597 #[non_exhaustive]
2598 pub enum Importance {
2599 /// Allows data caching, batching, and aggregation. It provides
2600 /// higher performance with higher data loss risk.
2601 Low,
2602 /// Disables data aggregation to minimize data loss. It is for operations
2603 /// that contains significant monetary value or audit trail. This feature
2604 /// only applies to the client libraries.
2605 High,
2606 /// If set, the enum was initialized with an unknown value.
2607 ///
2608 /// Applications can examine the value using [Importance::value] or
2609 /// [Importance::name].
2610 UnknownValue(importance::UnknownValue),
2611 }
2612
2613 #[doc(hidden)]
2614 pub mod importance {
2615 #[allow(unused_imports)]
2616 use super::*;
2617 #[derive(Clone, Debug, PartialEq)]
2618 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2619 }
2620
2621 impl Importance {
2622 /// Gets the enum value.
2623 ///
2624 /// Returns `None` if the enum contains an unknown value deserialized from
2625 /// the string representation of enums.
2626 pub fn value(&self) -> std::option::Option<i32> {
2627 match self {
2628 Self::Low => std::option::Option::Some(0),
2629 Self::High => std::option::Option::Some(1),
2630 Self::UnknownValue(u) => u.0.value(),
2631 }
2632 }
2633
2634 /// Gets the enum value as a string.
2635 ///
2636 /// Returns `None` if the enum contains an unknown value deserialized from
2637 /// the integer representation of enums.
2638 pub fn name(&self) -> std::option::Option<&str> {
2639 match self {
2640 Self::Low => std::option::Option::Some("LOW"),
2641 Self::High => std::option::Option::Some("HIGH"),
2642 Self::UnknownValue(u) => u.0.name(),
2643 }
2644 }
2645 }
2646
2647 impl std::default::Default for Importance {
2648 fn default() -> Self {
2649 use std::convert::From;
2650 Self::from(0)
2651 }
2652 }
2653
2654 impl std::fmt::Display for Importance {
2655 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2656 wkt::internal::display_enum(f, self.name(), self.value())
2657 }
2658 }
2659
2660 impl std::convert::From<i32> for Importance {
2661 fn from(value: i32) -> Self {
2662 match value {
2663 0 => Self::Low,
2664 1 => Self::High,
2665 _ => Self::UnknownValue(importance::UnknownValue(
2666 wkt::internal::UnknownEnumValue::Integer(value),
2667 )),
2668 }
2669 }
2670 }
2671
2672 impl std::convert::From<&str> for Importance {
2673 fn from(value: &str) -> Self {
2674 use std::string::ToString;
2675 match value {
2676 "LOW" => Self::Low,
2677 "HIGH" => Self::High,
2678 _ => Self::UnknownValue(importance::UnknownValue(
2679 wkt::internal::UnknownEnumValue::String(value.to_string()),
2680 )),
2681 }
2682 }
2683 }
2684
2685 impl serde::ser::Serialize for Importance {
2686 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2687 where
2688 S: serde::Serializer,
2689 {
2690 match self {
2691 Self::Low => serializer.serialize_i32(0),
2692 Self::High => serializer.serialize_i32(1),
2693 Self::UnknownValue(u) => u.0.serialize(serializer),
2694 }
2695 }
2696 }
2697
2698 impl<'de> serde::de::Deserialize<'de> for Importance {
2699 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2700 where
2701 D: serde::Deserializer<'de>,
2702 {
2703 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Importance>::new(
2704 ".google.api.servicecontrol.v1.Operation.Importance",
2705 ))
2706 }
2707 }
2708}
2709
2710/// Request message for the AllocateQuota method.
2711#[derive(Clone, Default, PartialEq)]
2712#[non_exhaustive]
2713pub struct AllocateQuotaRequest {
2714 /// Name of the service as specified in the service configuration. For example,
2715 /// `"pubsub.googleapis.com"`.
2716 ///
2717 /// See [google.api.Service][google.api.Service] for the definition of a service name.
2718 pub service_name: std::string::String,
2719
2720 /// Operation that describes the quota allocation.
2721 pub allocate_operation: std::option::Option<crate::model::QuotaOperation>,
2722
2723 /// Specifies which version of service configuration should be used to process
2724 /// the request. If unspecified or no matching version can be found, the latest
2725 /// one will be used.
2726 pub service_config_id: std::string::String,
2727
2728 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2729}
2730
2731impl AllocateQuotaRequest {
2732 pub fn new() -> Self {
2733 std::default::Default::default()
2734 }
2735
2736 /// Sets the value of [service_name][crate::model::AllocateQuotaRequest::service_name].
2737 ///
2738 /// # Example
2739 /// ```ignore,no_run
2740 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaRequest;
2741 /// let x = AllocateQuotaRequest::new().set_service_name("example");
2742 /// ```
2743 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2744 self.service_name = v.into();
2745 self
2746 }
2747
2748 /// Sets the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
2749 ///
2750 /// # Example
2751 /// ```ignore,no_run
2752 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaRequest;
2753 /// use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2754 /// let x = AllocateQuotaRequest::new().set_allocate_operation(QuotaOperation::default()/* use setters */);
2755 /// ```
2756 pub fn set_allocate_operation<T>(mut self, v: T) -> Self
2757 where
2758 T: std::convert::Into<crate::model::QuotaOperation>,
2759 {
2760 self.allocate_operation = std::option::Option::Some(v.into());
2761 self
2762 }
2763
2764 /// Sets or clears the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
2765 ///
2766 /// # Example
2767 /// ```ignore,no_run
2768 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaRequest;
2769 /// use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2770 /// let x = AllocateQuotaRequest::new().set_or_clear_allocate_operation(Some(QuotaOperation::default()/* use setters */));
2771 /// let x = AllocateQuotaRequest::new().set_or_clear_allocate_operation(None::<QuotaOperation>);
2772 /// ```
2773 pub fn set_or_clear_allocate_operation<T>(mut self, v: std::option::Option<T>) -> Self
2774 where
2775 T: std::convert::Into<crate::model::QuotaOperation>,
2776 {
2777 self.allocate_operation = v.map(|x| x.into());
2778 self
2779 }
2780
2781 /// Sets the value of [service_config_id][crate::model::AllocateQuotaRequest::service_config_id].
2782 ///
2783 /// # Example
2784 /// ```ignore,no_run
2785 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaRequest;
2786 /// let x = AllocateQuotaRequest::new().set_service_config_id("example");
2787 /// ```
2788 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
2789 mut self,
2790 v: T,
2791 ) -> Self {
2792 self.service_config_id = v.into();
2793 self
2794 }
2795}
2796
2797impl wkt::message::Message for AllocateQuotaRequest {
2798 fn typename() -> &'static str {
2799 "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaRequest"
2800 }
2801}
2802
2803/// Represents information regarding a quota operation.
2804#[derive(Clone, Default, PartialEq)]
2805#[non_exhaustive]
2806pub struct QuotaOperation {
2807 /// Identity of the operation. This is expected to be unique within the scope
2808 /// of the service that generated the operation, and guarantees idempotency in
2809 /// case of retries.
2810 ///
2811 /// In order to ensure best performance and latency in the Quota backends,
2812 /// operation_ids are optimally associated with time, so that related
2813 /// operations can be accessed fast in storage. For this reason, the
2814 /// recommended token for services that intend to operate at a high QPS is
2815 /// Unix time in nanos + UUID
2816 pub operation_id: std::string::String,
2817
2818 /// Fully qualified name of the API method for which this quota operation is
2819 /// requested. This name is used for matching quota rules or metric rules and
2820 /// billing status rules defined in service configuration.
2821 ///
2822 /// This field should not be set if any of the following is true:
2823 /// (1) the quota operation is performed on non-API resources.
2824 /// (2) quota_metrics is set because the caller is doing quota override.
2825 ///
2826 /// Example of an RPC method name:
2827 /// google.example.library.v1.LibraryService.CreateShelf
2828 pub method_name: std::string::String,
2829
2830 /// Identity of the consumer for whom this quota operation is being performed.
2831 ///
2832 /// This can be in one of the following formats:
2833 /// project:<project_id>,
2834 /// project_number:<project_number>,
2835 /// api_key:<api_key>.
2836 pub consumer_id: std::string::String,
2837
2838 /// Labels describing the operation.
2839 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
2840
2841 /// Represents information about this operation. Each MetricValueSet
2842 /// corresponds to a metric defined in the service configuration.
2843 /// The data type used in the MetricValueSet must agree with
2844 /// the data type specified in the metric definition.
2845 ///
2846 /// Within a single operation, it is not allowed to have more than one
2847 /// MetricValue instances that have the same metric names and identical
2848 /// label value combinations. If a request has such duplicated MetricValue
2849 /// instances, the entire request is rejected with
2850 /// an invalid argument error.
2851 ///
2852 /// This field is mutually exclusive with method_name.
2853 pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
2854
2855 /// Quota mode for this operation.
2856 pub quota_mode: crate::model::quota_operation::QuotaMode,
2857
2858 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2859}
2860
2861impl QuotaOperation {
2862 pub fn new() -> Self {
2863 std::default::Default::default()
2864 }
2865
2866 /// Sets the value of [operation_id][crate::model::QuotaOperation::operation_id].
2867 ///
2868 /// # Example
2869 /// ```ignore,no_run
2870 /// # use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2871 /// let x = QuotaOperation::new().set_operation_id("example");
2872 /// ```
2873 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2874 self.operation_id = v.into();
2875 self
2876 }
2877
2878 /// Sets the value of [method_name][crate::model::QuotaOperation::method_name].
2879 ///
2880 /// # Example
2881 /// ```ignore,no_run
2882 /// # use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2883 /// let x = QuotaOperation::new().set_method_name("example");
2884 /// ```
2885 pub fn set_method_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2886 self.method_name = v.into();
2887 self
2888 }
2889
2890 /// Sets the value of [consumer_id][crate::model::QuotaOperation::consumer_id].
2891 ///
2892 /// # Example
2893 /// ```ignore,no_run
2894 /// # use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2895 /// let x = QuotaOperation::new().set_consumer_id("example");
2896 /// ```
2897 pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2898 self.consumer_id = v.into();
2899 self
2900 }
2901
2902 /// Sets the value of [labels][crate::model::QuotaOperation::labels].
2903 ///
2904 /// # Example
2905 /// ```ignore,no_run
2906 /// # use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2907 /// let x = QuotaOperation::new().set_labels([
2908 /// ("key0", "abc"),
2909 /// ("key1", "xyz"),
2910 /// ]);
2911 /// ```
2912 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
2913 where
2914 T: std::iter::IntoIterator<Item = (K, V)>,
2915 K: std::convert::Into<std::string::String>,
2916 V: std::convert::Into<std::string::String>,
2917 {
2918 use std::iter::Iterator;
2919 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2920 self
2921 }
2922
2923 /// Sets the value of [quota_metrics][crate::model::QuotaOperation::quota_metrics].
2924 ///
2925 /// # Example
2926 /// ```ignore,no_run
2927 /// # use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2928 /// use google_cloud_api_servicecontrol_v1::model::MetricValueSet;
2929 /// let x = QuotaOperation::new()
2930 /// .set_quota_metrics([
2931 /// MetricValueSet::default()/* use setters */,
2932 /// MetricValueSet::default()/* use (different) setters */,
2933 /// ]);
2934 /// ```
2935 pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
2936 where
2937 T: std::iter::IntoIterator<Item = V>,
2938 V: std::convert::Into<crate::model::MetricValueSet>,
2939 {
2940 use std::iter::Iterator;
2941 self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
2942 self
2943 }
2944
2945 /// Sets the value of [quota_mode][crate::model::QuotaOperation::quota_mode].
2946 ///
2947 /// # Example
2948 /// ```ignore,no_run
2949 /// # use google_cloud_api_servicecontrol_v1::model::QuotaOperation;
2950 /// use google_cloud_api_servicecontrol_v1::model::quota_operation::QuotaMode;
2951 /// let x0 = QuotaOperation::new().set_quota_mode(QuotaMode::Normal);
2952 /// let x1 = QuotaOperation::new().set_quota_mode(QuotaMode::BestEffort);
2953 /// let x2 = QuotaOperation::new().set_quota_mode(QuotaMode::CheckOnly);
2954 /// ```
2955 pub fn set_quota_mode<T: std::convert::Into<crate::model::quota_operation::QuotaMode>>(
2956 mut self,
2957 v: T,
2958 ) -> Self {
2959 self.quota_mode = v.into();
2960 self
2961 }
2962}
2963
2964impl wkt::message::Message for QuotaOperation {
2965 fn typename() -> &'static str {
2966 "type.googleapis.com/google.api.servicecontrol.v1.QuotaOperation"
2967 }
2968}
2969
2970/// Defines additional types related to [QuotaOperation].
2971pub mod quota_operation {
2972 #[allow(unused_imports)]
2973 use super::*;
2974
2975 /// Supported quota modes.
2976 ///
2977 /// # Working with unknown values
2978 ///
2979 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2980 /// additional enum variants at any time. Adding new variants is not considered
2981 /// a breaking change. Applications should write their code in anticipation of:
2982 ///
2983 /// - New values appearing in future releases of the client library, **and**
2984 /// - New values received dynamically, without application changes.
2985 ///
2986 /// Please consult the [Working with enums] section in the user guide for some
2987 /// guidelines.
2988 ///
2989 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2990 #[derive(Clone, Debug, PartialEq)]
2991 #[non_exhaustive]
2992 pub enum QuotaMode {
2993 /// Guard against implicit default. Must not be used.
2994 Unspecified,
2995 /// For AllocateQuota request, allocates quota for the amount specified in
2996 /// the service configuration or specified using the quota metrics. If the
2997 /// amount is higher than the available quota, allocation error will be
2998 /// returned and no quota will be allocated.
2999 /// If multiple quotas are part of the request, and one fails, none of the
3000 /// quotas are allocated or released.
3001 Normal,
3002 /// The operation allocates quota for the amount specified in the service
3003 /// configuration or specified using the quota metrics. If the amount is
3004 /// higher than the available quota, request does not fail but all available
3005 /// quota will be allocated.
3006 /// For rate quota, BEST_EFFORT will continue to deduct from other groups
3007 /// even if one does not have enough quota. For allocation, it will find the
3008 /// minimum available amount across all groups and deduct that amount from
3009 /// all the affected groups.
3010 BestEffort,
3011 /// For AllocateQuota request, only checks if there is enough quota
3012 /// available and does not change the available quota. No lock is placed on
3013 /// the available quota either.
3014 CheckOnly,
3015 /// Unimplemented. When used in AllocateQuotaRequest, this returns the
3016 /// effective quota limit(s) in the response, and no quota check will be
3017 /// performed. Not supported for other requests, and even for
3018 /// AllocateQuotaRequest, this is currently supported only for allowlisted
3019 /// services.
3020 QueryOnly,
3021 /// The operation allocates quota for the amount specified in the service
3022 /// configuration or specified using the quota metrics. If the requested
3023 /// amount is higher than the available quota, request does not fail and
3024 /// remaining quota would become negative (going over the limit).
3025 /// Not supported for Rate Quota.
3026 AdjustOnly,
3027 /// If set, the enum was initialized with an unknown value.
3028 ///
3029 /// Applications can examine the value using [QuotaMode::value] or
3030 /// [QuotaMode::name].
3031 UnknownValue(quota_mode::UnknownValue),
3032 }
3033
3034 #[doc(hidden)]
3035 pub mod quota_mode {
3036 #[allow(unused_imports)]
3037 use super::*;
3038 #[derive(Clone, Debug, PartialEq)]
3039 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3040 }
3041
3042 impl QuotaMode {
3043 /// Gets the enum value.
3044 ///
3045 /// Returns `None` if the enum contains an unknown value deserialized from
3046 /// the string representation of enums.
3047 pub fn value(&self) -> std::option::Option<i32> {
3048 match self {
3049 Self::Unspecified => std::option::Option::Some(0),
3050 Self::Normal => std::option::Option::Some(1),
3051 Self::BestEffort => std::option::Option::Some(2),
3052 Self::CheckOnly => std::option::Option::Some(3),
3053 Self::QueryOnly => std::option::Option::Some(4),
3054 Self::AdjustOnly => std::option::Option::Some(5),
3055 Self::UnknownValue(u) => u.0.value(),
3056 }
3057 }
3058
3059 /// Gets the enum value as a string.
3060 ///
3061 /// Returns `None` if the enum contains an unknown value deserialized from
3062 /// the integer representation of enums.
3063 pub fn name(&self) -> std::option::Option<&str> {
3064 match self {
3065 Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
3066 Self::Normal => std::option::Option::Some("NORMAL"),
3067 Self::BestEffort => std::option::Option::Some("BEST_EFFORT"),
3068 Self::CheckOnly => std::option::Option::Some("CHECK_ONLY"),
3069 Self::QueryOnly => std::option::Option::Some("QUERY_ONLY"),
3070 Self::AdjustOnly => std::option::Option::Some("ADJUST_ONLY"),
3071 Self::UnknownValue(u) => u.0.name(),
3072 }
3073 }
3074 }
3075
3076 impl std::default::Default for QuotaMode {
3077 fn default() -> Self {
3078 use std::convert::From;
3079 Self::from(0)
3080 }
3081 }
3082
3083 impl std::fmt::Display for QuotaMode {
3084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3085 wkt::internal::display_enum(f, self.name(), self.value())
3086 }
3087 }
3088
3089 impl std::convert::From<i32> for QuotaMode {
3090 fn from(value: i32) -> Self {
3091 match value {
3092 0 => Self::Unspecified,
3093 1 => Self::Normal,
3094 2 => Self::BestEffort,
3095 3 => Self::CheckOnly,
3096 4 => Self::QueryOnly,
3097 5 => Self::AdjustOnly,
3098 _ => Self::UnknownValue(quota_mode::UnknownValue(
3099 wkt::internal::UnknownEnumValue::Integer(value),
3100 )),
3101 }
3102 }
3103 }
3104
3105 impl std::convert::From<&str> for QuotaMode {
3106 fn from(value: &str) -> Self {
3107 use std::string::ToString;
3108 match value {
3109 "UNSPECIFIED" => Self::Unspecified,
3110 "NORMAL" => Self::Normal,
3111 "BEST_EFFORT" => Self::BestEffort,
3112 "CHECK_ONLY" => Self::CheckOnly,
3113 "QUERY_ONLY" => Self::QueryOnly,
3114 "ADJUST_ONLY" => Self::AdjustOnly,
3115 _ => Self::UnknownValue(quota_mode::UnknownValue(
3116 wkt::internal::UnknownEnumValue::String(value.to_string()),
3117 )),
3118 }
3119 }
3120 }
3121
3122 impl serde::ser::Serialize for QuotaMode {
3123 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3124 where
3125 S: serde::Serializer,
3126 {
3127 match self {
3128 Self::Unspecified => serializer.serialize_i32(0),
3129 Self::Normal => serializer.serialize_i32(1),
3130 Self::BestEffort => serializer.serialize_i32(2),
3131 Self::CheckOnly => serializer.serialize_i32(3),
3132 Self::QueryOnly => serializer.serialize_i32(4),
3133 Self::AdjustOnly => serializer.serialize_i32(5),
3134 Self::UnknownValue(u) => u.0.serialize(serializer),
3135 }
3136 }
3137 }
3138
3139 impl<'de> serde::de::Deserialize<'de> for QuotaMode {
3140 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3141 where
3142 D: serde::Deserializer<'de>,
3143 {
3144 deserializer.deserialize_any(wkt::internal::EnumVisitor::<QuotaMode>::new(
3145 ".google.api.servicecontrol.v1.QuotaOperation.QuotaMode",
3146 ))
3147 }
3148 }
3149}
3150
3151/// Response message for the AllocateQuota method.
3152#[derive(Clone, Default, PartialEq)]
3153#[non_exhaustive]
3154pub struct AllocateQuotaResponse {
3155 /// The same operation_id value used in the AllocateQuotaRequest. Used for
3156 /// logging and diagnostics purposes.
3157 pub operation_id: std::string::String,
3158
3159 /// Indicates the decision of the allocate.
3160 pub allocate_errors: std::vec::Vec<crate::model::QuotaError>,
3161
3162 /// Quota metrics to indicate the result of allocation. Depending on the
3163 /// request, one or more of the following metrics will be included:
3164 ///
3165 /// 1. Per quota group or per quota metric incremental usage will be specified
3166 /// using the following delta metric :
3167 /// "serviceruntime.googleapis.com/api/consumer/quota_used_count"
3168 ///
3169 /// 1. The quota limit reached condition will be specified using the following
3170 /// boolean metric :
3171 /// "serviceruntime.googleapis.com/quota/exceeded"
3172 ///
3173 pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
3174
3175 /// ID of the actual config used to process the request.
3176 pub service_config_id: std::string::String,
3177
3178 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3179}
3180
3181impl AllocateQuotaResponse {
3182 pub fn new() -> Self {
3183 std::default::Default::default()
3184 }
3185
3186 /// Sets the value of [operation_id][crate::model::AllocateQuotaResponse::operation_id].
3187 ///
3188 /// # Example
3189 /// ```ignore,no_run
3190 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaResponse;
3191 /// let x = AllocateQuotaResponse::new().set_operation_id("example");
3192 /// ```
3193 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3194 self.operation_id = v.into();
3195 self
3196 }
3197
3198 /// Sets the value of [allocate_errors][crate::model::AllocateQuotaResponse::allocate_errors].
3199 ///
3200 /// # Example
3201 /// ```ignore,no_run
3202 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaResponse;
3203 /// use google_cloud_api_servicecontrol_v1::model::QuotaError;
3204 /// let x = AllocateQuotaResponse::new()
3205 /// .set_allocate_errors([
3206 /// QuotaError::default()/* use setters */,
3207 /// QuotaError::default()/* use (different) setters */,
3208 /// ]);
3209 /// ```
3210 pub fn set_allocate_errors<T, V>(mut self, v: T) -> Self
3211 where
3212 T: std::iter::IntoIterator<Item = V>,
3213 V: std::convert::Into<crate::model::QuotaError>,
3214 {
3215 use std::iter::Iterator;
3216 self.allocate_errors = v.into_iter().map(|i| i.into()).collect();
3217 self
3218 }
3219
3220 /// Sets the value of [quota_metrics][crate::model::AllocateQuotaResponse::quota_metrics].
3221 ///
3222 /// # Example
3223 /// ```ignore,no_run
3224 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaResponse;
3225 /// use google_cloud_api_servicecontrol_v1::model::MetricValueSet;
3226 /// let x = AllocateQuotaResponse::new()
3227 /// .set_quota_metrics([
3228 /// MetricValueSet::default()/* use setters */,
3229 /// MetricValueSet::default()/* use (different) setters */,
3230 /// ]);
3231 /// ```
3232 pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
3233 where
3234 T: std::iter::IntoIterator<Item = V>,
3235 V: std::convert::Into<crate::model::MetricValueSet>,
3236 {
3237 use std::iter::Iterator;
3238 self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
3239 self
3240 }
3241
3242 /// Sets the value of [service_config_id][crate::model::AllocateQuotaResponse::service_config_id].
3243 ///
3244 /// # Example
3245 /// ```ignore,no_run
3246 /// # use google_cloud_api_servicecontrol_v1::model::AllocateQuotaResponse;
3247 /// let x = AllocateQuotaResponse::new().set_service_config_id("example");
3248 /// ```
3249 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
3250 mut self,
3251 v: T,
3252 ) -> Self {
3253 self.service_config_id = v.into();
3254 self
3255 }
3256}
3257
3258impl wkt::message::Message for AllocateQuotaResponse {
3259 fn typename() -> &'static str {
3260 "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaResponse"
3261 }
3262}
3263
3264/// Represents error information for [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation].
3265///
3266/// [google.api.servicecontrol.v1.QuotaOperation]: crate::model::QuotaOperation
3267#[derive(Clone, Default, PartialEq)]
3268#[non_exhaustive]
3269pub struct QuotaError {
3270 /// Error code.
3271 pub code: crate::model::quota_error::Code,
3272
3273 /// Subject to whom this error applies. See the specific enum for more details
3274 /// on this field. For example, "clientip:\<ip address of client\>" or
3275 /// "project:\<Google developer project id\>".
3276 pub subject: std::string::String,
3277
3278 /// Free-form text that provides details on the cause of the error.
3279 pub description: std::string::String,
3280
3281 /// Contains additional information about the quota error.
3282 /// If available, `status.code` will be non zero.
3283 pub status: std::option::Option<rpc::model::Status>,
3284
3285 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3286}
3287
3288impl QuotaError {
3289 pub fn new() -> Self {
3290 std::default::Default::default()
3291 }
3292
3293 /// Sets the value of [code][crate::model::QuotaError::code].
3294 ///
3295 /// # Example
3296 /// ```ignore,no_run
3297 /// # use google_cloud_api_servicecontrol_v1::model::QuotaError;
3298 /// use google_cloud_api_servicecontrol_v1::model::quota_error::Code;
3299 /// let x0 = QuotaError::new().set_code(Code::ResourceExhausted);
3300 /// let x1 = QuotaError::new().set_code(Code::BillingNotActive);
3301 /// let x2 = QuotaError::new().set_code(Code::ProjectDeleted);
3302 /// ```
3303 pub fn set_code<T: std::convert::Into<crate::model::quota_error::Code>>(
3304 mut self,
3305 v: T,
3306 ) -> Self {
3307 self.code = v.into();
3308 self
3309 }
3310
3311 /// Sets the value of [subject][crate::model::QuotaError::subject].
3312 ///
3313 /// # Example
3314 /// ```ignore,no_run
3315 /// # use google_cloud_api_servicecontrol_v1::model::QuotaError;
3316 /// let x = QuotaError::new().set_subject("example");
3317 /// ```
3318 pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3319 self.subject = v.into();
3320 self
3321 }
3322
3323 /// Sets the value of [description][crate::model::QuotaError::description].
3324 ///
3325 /// # Example
3326 /// ```ignore,no_run
3327 /// # use google_cloud_api_servicecontrol_v1::model::QuotaError;
3328 /// let x = QuotaError::new().set_description("example");
3329 /// ```
3330 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3331 self.description = v.into();
3332 self
3333 }
3334
3335 /// Sets the value of [status][crate::model::QuotaError::status].
3336 ///
3337 /// # Example
3338 /// ```ignore,no_run
3339 /// # use google_cloud_api_servicecontrol_v1::model::QuotaError;
3340 /// use rpc::model::Status;
3341 /// let x = QuotaError::new().set_status(Status::default()/* use setters */);
3342 /// ```
3343 pub fn set_status<T>(mut self, v: T) -> Self
3344 where
3345 T: std::convert::Into<rpc::model::Status>,
3346 {
3347 self.status = std::option::Option::Some(v.into());
3348 self
3349 }
3350
3351 /// Sets or clears the value of [status][crate::model::QuotaError::status].
3352 ///
3353 /// # Example
3354 /// ```ignore,no_run
3355 /// # use google_cloud_api_servicecontrol_v1::model::QuotaError;
3356 /// use rpc::model::Status;
3357 /// let x = QuotaError::new().set_or_clear_status(Some(Status::default()/* use setters */));
3358 /// let x = QuotaError::new().set_or_clear_status(None::<Status>);
3359 /// ```
3360 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
3361 where
3362 T: std::convert::Into<rpc::model::Status>,
3363 {
3364 self.status = v.map(|x| x.into());
3365 self
3366 }
3367}
3368
3369impl wkt::message::Message for QuotaError {
3370 fn typename() -> &'static str {
3371 "type.googleapis.com/google.api.servicecontrol.v1.QuotaError"
3372 }
3373}
3374
3375/// Defines additional types related to [QuotaError].
3376pub mod quota_error {
3377 #[allow(unused_imports)]
3378 use super::*;
3379
3380 /// Error codes related to project config validations are deprecated since the
3381 /// quota controller methods do not perform these validations. Instead services
3382 /// have to call the Check method, without quota_properties field, to perform
3383 /// these validations before calling the quota controller methods. These
3384 /// methods check only for project deletion to be wipe out compliant.
3385 ///
3386 /// # Working with unknown values
3387 ///
3388 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3389 /// additional enum variants at any time. Adding new variants is not considered
3390 /// a breaking change. Applications should write their code in anticipation of:
3391 ///
3392 /// - New values appearing in future releases of the client library, **and**
3393 /// - New values received dynamically, without application changes.
3394 ///
3395 /// Please consult the [Working with enums] section in the user guide for some
3396 /// guidelines.
3397 ///
3398 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
3399 #[derive(Clone, Debug, PartialEq)]
3400 #[non_exhaustive]
3401 pub enum Code {
3402 /// This is never used.
3403 Unspecified,
3404 /// Quota allocation failed.
3405 /// Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
3406 ResourceExhausted,
3407 /// Consumer cannot access the service because the service requires active
3408 /// billing.
3409 BillingNotActive,
3410 /// Consumer's project has been marked as deleted (soft deletion).
3411 ProjectDeleted,
3412 /// Specified API key is invalid.
3413 ApiKeyInvalid,
3414 /// Specified API Key has expired.
3415 ApiKeyExpired,
3416 /// If set, the enum was initialized with an unknown value.
3417 ///
3418 /// Applications can examine the value using [Code::value] or
3419 /// [Code::name].
3420 UnknownValue(code::UnknownValue),
3421 }
3422
3423 #[doc(hidden)]
3424 pub mod code {
3425 #[allow(unused_imports)]
3426 use super::*;
3427 #[derive(Clone, Debug, PartialEq)]
3428 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3429 }
3430
3431 impl Code {
3432 /// Gets the enum value.
3433 ///
3434 /// Returns `None` if the enum contains an unknown value deserialized from
3435 /// the string representation of enums.
3436 pub fn value(&self) -> std::option::Option<i32> {
3437 match self {
3438 Self::Unspecified => std::option::Option::Some(0),
3439 Self::ResourceExhausted => std::option::Option::Some(8),
3440 Self::BillingNotActive => std::option::Option::Some(107),
3441 Self::ProjectDeleted => std::option::Option::Some(108),
3442 Self::ApiKeyInvalid => std::option::Option::Some(105),
3443 Self::ApiKeyExpired => std::option::Option::Some(112),
3444 Self::UnknownValue(u) => u.0.value(),
3445 }
3446 }
3447
3448 /// Gets the enum value as a string.
3449 ///
3450 /// Returns `None` if the enum contains an unknown value deserialized from
3451 /// the integer representation of enums.
3452 pub fn name(&self) -> std::option::Option<&str> {
3453 match self {
3454 Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
3455 Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
3456 Self::BillingNotActive => std::option::Option::Some("BILLING_NOT_ACTIVE"),
3457 Self::ProjectDeleted => std::option::Option::Some("PROJECT_DELETED"),
3458 Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
3459 Self::ApiKeyExpired => std::option::Option::Some("API_KEY_EXPIRED"),
3460 Self::UnknownValue(u) => u.0.name(),
3461 }
3462 }
3463 }
3464
3465 impl std::default::Default for Code {
3466 fn default() -> Self {
3467 use std::convert::From;
3468 Self::from(0)
3469 }
3470 }
3471
3472 impl std::fmt::Display for Code {
3473 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3474 wkt::internal::display_enum(f, self.name(), self.value())
3475 }
3476 }
3477
3478 impl std::convert::From<i32> for Code {
3479 fn from(value: i32) -> Self {
3480 match value {
3481 0 => Self::Unspecified,
3482 8 => Self::ResourceExhausted,
3483 105 => Self::ApiKeyInvalid,
3484 107 => Self::BillingNotActive,
3485 108 => Self::ProjectDeleted,
3486 112 => Self::ApiKeyExpired,
3487 _ => Self::UnknownValue(code::UnknownValue(
3488 wkt::internal::UnknownEnumValue::Integer(value),
3489 )),
3490 }
3491 }
3492 }
3493
3494 impl std::convert::From<&str> for Code {
3495 fn from(value: &str) -> Self {
3496 use std::string::ToString;
3497 match value {
3498 "UNSPECIFIED" => Self::Unspecified,
3499 "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
3500 "BILLING_NOT_ACTIVE" => Self::BillingNotActive,
3501 "PROJECT_DELETED" => Self::ProjectDeleted,
3502 "API_KEY_INVALID" => Self::ApiKeyInvalid,
3503 "API_KEY_EXPIRED" => Self::ApiKeyExpired,
3504 _ => Self::UnknownValue(code::UnknownValue(
3505 wkt::internal::UnknownEnumValue::String(value.to_string()),
3506 )),
3507 }
3508 }
3509 }
3510
3511 impl serde::ser::Serialize for Code {
3512 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3513 where
3514 S: serde::Serializer,
3515 {
3516 match self {
3517 Self::Unspecified => serializer.serialize_i32(0),
3518 Self::ResourceExhausted => serializer.serialize_i32(8),
3519 Self::BillingNotActive => serializer.serialize_i32(107),
3520 Self::ProjectDeleted => serializer.serialize_i32(108),
3521 Self::ApiKeyInvalid => serializer.serialize_i32(105),
3522 Self::ApiKeyExpired => serializer.serialize_i32(112),
3523 Self::UnknownValue(u) => u.0.serialize(serializer),
3524 }
3525 }
3526 }
3527
3528 impl<'de> serde::de::Deserialize<'de> for Code {
3529 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3530 where
3531 D: serde::Deserializer<'de>,
3532 {
3533 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
3534 ".google.api.servicecontrol.v1.QuotaError.Code",
3535 ))
3536 }
3537 }
3538}
3539
3540/// Request message for the Check method.
3541#[derive(Clone, Default, PartialEq)]
3542#[non_exhaustive]
3543pub struct CheckRequest {
3544 /// The service name as specified in its service configuration. For example,
3545 /// `"pubsub.googleapis.com"`.
3546 ///
3547 /// See
3548 /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
3549 /// for the definition of a service name.
3550 pub service_name: std::string::String,
3551
3552 /// The operation to be checked.
3553 pub operation: std::option::Option<crate::model::Operation>,
3554
3555 /// Specifies which version of service configuration should be used to process
3556 /// the request.
3557 ///
3558 /// If unspecified or no matching version can be found, the
3559 /// latest one will be used.
3560 pub service_config_id: std::string::String,
3561
3562 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3563}
3564
3565impl CheckRequest {
3566 pub fn new() -> Self {
3567 std::default::Default::default()
3568 }
3569
3570 /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
3571 ///
3572 /// # Example
3573 /// ```ignore,no_run
3574 /// # use google_cloud_api_servicecontrol_v1::model::CheckRequest;
3575 /// let x = CheckRequest::new().set_service_name("example");
3576 /// ```
3577 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3578 self.service_name = v.into();
3579 self
3580 }
3581
3582 /// Sets the value of [operation][crate::model::CheckRequest::operation].
3583 ///
3584 /// # Example
3585 /// ```ignore,no_run
3586 /// # use google_cloud_api_servicecontrol_v1::model::CheckRequest;
3587 /// use google_cloud_api_servicecontrol_v1::model::Operation;
3588 /// let x = CheckRequest::new().set_operation(Operation::default()/* use setters */);
3589 /// ```
3590 pub fn set_operation<T>(mut self, v: T) -> Self
3591 where
3592 T: std::convert::Into<crate::model::Operation>,
3593 {
3594 self.operation = std::option::Option::Some(v.into());
3595 self
3596 }
3597
3598 /// Sets or clears the value of [operation][crate::model::CheckRequest::operation].
3599 ///
3600 /// # Example
3601 /// ```ignore,no_run
3602 /// # use google_cloud_api_servicecontrol_v1::model::CheckRequest;
3603 /// use google_cloud_api_servicecontrol_v1::model::Operation;
3604 /// let x = CheckRequest::new().set_or_clear_operation(Some(Operation::default()/* use setters */));
3605 /// let x = CheckRequest::new().set_or_clear_operation(None::<Operation>);
3606 /// ```
3607 pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
3608 where
3609 T: std::convert::Into<crate::model::Operation>,
3610 {
3611 self.operation = v.map(|x| x.into());
3612 self
3613 }
3614
3615 /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
3616 ///
3617 /// # Example
3618 /// ```ignore,no_run
3619 /// # use google_cloud_api_servicecontrol_v1::model::CheckRequest;
3620 /// let x = CheckRequest::new().set_service_config_id("example");
3621 /// ```
3622 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
3623 mut self,
3624 v: T,
3625 ) -> Self {
3626 self.service_config_id = v.into();
3627 self
3628 }
3629}
3630
3631impl wkt::message::Message for CheckRequest {
3632 fn typename() -> &'static str {
3633 "type.googleapis.com/google.api.servicecontrol.v1.CheckRequest"
3634 }
3635}
3636
3637/// Response message for the Check method.
3638#[derive(Clone, Default, PartialEq)]
3639#[non_exhaustive]
3640pub struct CheckResponse {
3641 /// The same operation_id value used in the
3642 /// [CheckRequest][google.api.servicecontrol.v1.CheckRequest]. Used for logging
3643 /// and diagnostics purposes.
3644 ///
3645 /// [google.api.servicecontrol.v1.CheckRequest]: crate::model::CheckRequest
3646 pub operation_id: std::string::String,
3647
3648 /// Indicate the decision of the check.
3649 ///
3650 /// If no check errors are present, the service should process the operation.
3651 /// Otherwise the service should use the list of errors to determine the
3652 /// appropriate action.
3653 pub check_errors: std::vec::Vec<crate::model::CheckError>,
3654
3655 /// The actual config id used to process the request.
3656 pub service_config_id: std::string::String,
3657
3658 /// The current service rollout id used to process the request.
3659 pub service_rollout_id: std::string::String,
3660
3661 /// Feedback data returned from the server during processing a Check request.
3662 pub check_info: std::option::Option<crate::model::check_response::CheckInfo>,
3663
3664 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3665}
3666
3667impl CheckResponse {
3668 pub fn new() -> Self {
3669 std::default::Default::default()
3670 }
3671
3672 /// Sets the value of [operation_id][crate::model::CheckResponse::operation_id].
3673 ///
3674 /// # Example
3675 /// ```ignore,no_run
3676 /// # use google_cloud_api_servicecontrol_v1::model::CheckResponse;
3677 /// let x = CheckResponse::new().set_operation_id("example");
3678 /// ```
3679 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3680 self.operation_id = v.into();
3681 self
3682 }
3683
3684 /// Sets the value of [check_errors][crate::model::CheckResponse::check_errors].
3685 ///
3686 /// # Example
3687 /// ```ignore,no_run
3688 /// # use google_cloud_api_servicecontrol_v1::model::CheckResponse;
3689 /// use google_cloud_api_servicecontrol_v1::model::CheckError;
3690 /// let x = CheckResponse::new()
3691 /// .set_check_errors([
3692 /// CheckError::default()/* use setters */,
3693 /// CheckError::default()/* use (different) setters */,
3694 /// ]);
3695 /// ```
3696 pub fn set_check_errors<T, V>(mut self, v: T) -> Self
3697 where
3698 T: std::iter::IntoIterator<Item = V>,
3699 V: std::convert::Into<crate::model::CheckError>,
3700 {
3701 use std::iter::Iterator;
3702 self.check_errors = v.into_iter().map(|i| i.into()).collect();
3703 self
3704 }
3705
3706 /// Sets the value of [service_config_id][crate::model::CheckResponse::service_config_id].
3707 ///
3708 /// # Example
3709 /// ```ignore,no_run
3710 /// # use google_cloud_api_servicecontrol_v1::model::CheckResponse;
3711 /// let x = CheckResponse::new().set_service_config_id("example");
3712 /// ```
3713 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
3714 mut self,
3715 v: T,
3716 ) -> Self {
3717 self.service_config_id = v.into();
3718 self
3719 }
3720
3721 /// Sets the value of [service_rollout_id][crate::model::CheckResponse::service_rollout_id].
3722 ///
3723 /// # Example
3724 /// ```ignore,no_run
3725 /// # use google_cloud_api_servicecontrol_v1::model::CheckResponse;
3726 /// let x = CheckResponse::new().set_service_rollout_id("example");
3727 /// ```
3728 pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
3729 mut self,
3730 v: T,
3731 ) -> Self {
3732 self.service_rollout_id = v.into();
3733 self
3734 }
3735
3736 /// Sets the value of [check_info][crate::model::CheckResponse::check_info].
3737 ///
3738 /// # Example
3739 /// ```ignore,no_run
3740 /// # use google_cloud_api_servicecontrol_v1::model::CheckResponse;
3741 /// use google_cloud_api_servicecontrol_v1::model::check_response::CheckInfo;
3742 /// let x = CheckResponse::new().set_check_info(CheckInfo::default()/* use setters */);
3743 /// ```
3744 pub fn set_check_info<T>(mut self, v: T) -> Self
3745 where
3746 T: std::convert::Into<crate::model::check_response::CheckInfo>,
3747 {
3748 self.check_info = std::option::Option::Some(v.into());
3749 self
3750 }
3751
3752 /// Sets or clears the value of [check_info][crate::model::CheckResponse::check_info].
3753 ///
3754 /// # Example
3755 /// ```ignore,no_run
3756 /// # use google_cloud_api_servicecontrol_v1::model::CheckResponse;
3757 /// use google_cloud_api_servicecontrol_v1::model::check_response::CheckInfo;
3758 /// let x = CheckResponse::new().set_or_clear_check_info(Some(CheckInfo::default()/* use setters */));
3759 /// let x = CheckResponse::new().set_or_clear_check_info(None::<CheckInfo>);
3760 /// ```
3761 pub fn set_or_clear_check_info<T>(mut self, v: std::option::Option<T>) -> Self
3762 where
3763 T: std::convert::Into<crate::model::check_response::CheckInfo>,
3764 {
3765 self.check_info = v.map(|x| x.into());
3766 self
3767 }
3768}
3769
3770impl wkt::message::Message for CheckResponse {
3771 fn typename() -> &'static str {
3772 "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse"
3773 }
3774}
3775
3776/// Defines additional types related to [CheckResponse].
3777pub mod check_response {
3778 #[allow(unused_imports)]
3779 use super::*;
3780
3781 /// Contains additional information about the check operation.
3782 #[derive(Clone, Default, PartialEq)]
3783 #[non_exhaustive]
3784 pub struct CheckInfo {
3785 /// A list of fields and label keys that are ignored by the server.
3786 /// The client doesn't need to send them for following requests to improve
3787 /// performance and allow better aggregation.
3788 pub unused_arguments: std::vec::Vec<std::string::String>,
3789
3790 /// Consumer info of this check.
3791 pub consumer_info: std::option::Option<crate::model::check_response::ConsumerInfo>,
3792
3793 /// The unique id of the api key in the format of "apikey:\<UID\>".
3794 /// This field will be populated when the consumer passed to Service Control
3795 /// is an API key and all the API key related validations are successful.
3796 pub api_key_uid: std::string::String,
3797
3798 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3799 }
3800
3801 impl CheckInfo {
3802 pub fn new() -> Self {
3803 std::default::Default::default()
3804 }
3805
3806 /// Sets the value of [unused_arguments][crate::model::check_response::CheckInfo::unused_arguments].
3807 ///
3808 /// # Example
3809 /// ```ignore,no_run
3810 /// # use google_cloud_api_servicecontrol_v1::model::check_response::CheckInfo;
3811 /// let x = CheckInfo::new().set_unused_arguments(["a", "b", "c"]);
3812 /// ```
3813 pub fn set_unused_arguments<T, V>(mut self, v: T) -> Self
3814 where
3815 T: std::iter::IntoIterator<Item = V>,
3816 V: std::convert::Into<std::string::String>,
3817 {
3818 use std::iter::Iterator;
3819 self.unused_arguments = v.into_iter().map(|i| i.into()).collect();
3820 self
3821 }
3822
3823 /// Sets the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
3824 ///
3825 /// # Example
3826 /// ```ignore,no_run
3827 /// # use google_cloud_api_servicecontrol_v1::model::check_response::CheckInfo;
3828 /// use google_cloud_api_servicecontrol_v1::model::check_response::ConsumerInfo;
3829 /// let x = CheckInfo::new().set_consumer_info(ConsumerInfo::default()/* use setters */);
3830 /// ```
3831 pub fn set_consumer_info<T>(mut self, v: T) -> Self
3832 where
3833 T: std::convert::Into<crate::model::check_response::ConsumerInfo>,
3834 {
3835 self.consumer_info = std::option::Option::Some(v.into());
3836 self
3837 }
3838
3839 /// Sets or clears the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
3840 ///
3841 /// # Example
3842 /// ```ignore,no_run
3843 /// # use google_cloud_api_servicecontrol_v1::model::check_response::CheckInfo;
3844 /// use google_cloud_api_servicecontrol_v1::model::check_response::ConsumerInfo;
3845 /// let x = CheckInfo::new().set_or_clear_consumer_info(Some(ConsumerInfo::default()/* use setters */));
3846 /// let x = CheckInfo::new().set_or_clear_consumer_info(None::<ConsumerInfo>);
3847 /// ```
3848 pub fn set_or_clear_consumer_info<T>(mut self, v: std::option::Option<T>) -> Self
3849 where
3850 T: std::convert::Into<crate::model::check_response::ConsumerInfo>,
3851 {
3852 self.consumer_info = v.map(|x| x.into());
3853 self
3854 }
3855
3856 /// Sets the value of [api_key_uid][crate::model::check_response::CheckInfo::api_key_uid].
3857 ///
3858 /// # Example
3859 /// ```ignore,no_run
3860 /// # use google_cloud_api_servicecontrol_v1::model::check_response::CheckInfo;
3861 /// let x = CheckInfo::new().set_api_key_uid("example");
3862 /// ```
3863 pub fn set_api_key_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3864 self.api_key_uid = v.into();
3865 self
3866 }
3867 }
3868
3869 impl wkt::message::Message for CheckInfo {
3870 fn typename() -> &'static str {
3871 "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.CheckInfo"
3872 }
3873 }
3874
3875 /// `ConsumerInfo` provides information about the consumer.
3876 #[derive(Clone, Default, PartialEq)]
3877 #[non_exhaustive]
3878 pub struct ConsumerInfo {
3879 /// The Google cloud project number, e.g. 1234567890. A value of 0 indicates
3880 /// no project number is found.
3881 ///
3882 /// NOTE: This field is deprecated after we support flexible consumer
3883 /// id. New code should not depend on this field anymore.
3884 pub project_number: i64,
3885
3886 /// The type of the consumer which should have been defined in
3887 /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
3888 pub r#type: crate::model::check_response::consumer_info::ConsumerType,
3889
3890 /// The consumer identity number, can be Google cloud project number, folder
3891 /// number or organization number e.g. 1234567890. A value of 0 indicates no
3892 /// consumer number is found.
3893 pub consumer_number: i64,
3894
3895 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3896 }
3897
3898 impl ConsumerInfo {
3899 pub fn new() -> Self {
3900 std::default::Default::default()
3901 }
3902
3903 /// Sets the value of [project_number][crate::model::check_response::ConsumerInfo::project_number].
3904 ///
3905 /// # Example
3906 /// ```ignore,no_run
3907 /// # use google_cloud_api_servicecontrol_v1::model::check_response::ConsumerInfo;
3908 /// let x = ConsumerInfo::new().set_project_number(42);
3909 /// ```
3910 pub fn set_project_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3911 self.project_number = v.into();
3912 self
3913 }
3914
3915 /// Sets the value of [r#type][crate::model::check_response::ConsumerInfo::type].
3916 ///
3917 /// # Example
3918 /// ```ignore,no_run
3919 /// # use google_cloud_api_servicecontrol_v1::model::check_response::ConsumerInfo;
3920 /// use google_cloud_api_servicecontrol_v1::model::check_response::consumer_info::ConsumerType;
3921 /// let x0 = ConsumerInfo::new().set_type(ConsumerType::Project);
3922 /// let x1 = ConsumerInfo::new().set_type(ConsumerType::Folder);
3923 /// let x2 = ConsumerInfo::new().set_type(ConsumerType::Organization);
3924 /// ```
3925 pub fn set_type<
3926 T: std::convert::Into<crate::model::check_response::consumer_info::ConsumerType>,
3927 >(
3928 mut self,
3929 v: T,
3930 ) -> Self {
3931 self.r#type = v.into();
3932 self
3933 }
3934
3935 /// Sets the value of [consumer_number][crate::model::check_response::ConsumerInfo::consumer_number].
3936 ///
3937 /// # Example
3938 /// ```ignore,no_run
3939 /// # use google_cloud_api_servicecontrol_v1::model::check_response::ConsumerInfo;
3940 /// let x = ConsumerInfo::new().set_consumer_number(42);
3941 /// ```
3942 pub fn set_consumer_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3943 self.consumer_number = v.into();
3944 self
3945 }
3946 }
3947
3948 impl wkt::message::Message for ConsumerInfo {
3949 fn typename() -> &'static str {
3950 "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.ConsumerInfo"
3951 }
3952 }
3953
3954 /// Defines additional types related to [ConsumerInfo].
3955 pub mod consumer_info {
3956 #[allow(unused_imports)]
3957 use super::*;
3958
3959 /// The type of the consumer as defined in
3960 /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
3961 ///
3962 /// # Working with unknown values
3963 ///
3964 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3965 /// additional enum variants at any time. Adding new variants is not considered
3966 /// a breaking change. Applications should write their code in anticipation of:
3967 ///
3968 /// - New values appearing in future releases of the client library, **and**
3969 /// - New values received dynamically, without application changes.
3970 ///
3971 /// Please consult the [Working with enums] section in the user guide for some
3972 /// guidelines.
3973 ///
3974 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
3975 #[derive(Clone, Debug, PartialEq)]
3976 #[non_exhaustive]
3977 pub enum ConsumerType {
3978 /// This is never used.
3979 Unspecified,
3980 /// The consumer is a Google Cloud Project.
3981 Project,
3982 /// The consumer is a Google Cloud Folder.
3983 Folder,
3984 /// The consumer is a Google Cloud Organization.
3985 Organization,
3986 /// Service-specific resource container which is defined by the service
3987 /// producer to offer their users the ability to manage service control
3988 /// functionalities at a finer level of granularity than the PROJECT.
3989 ServiceSpecific,
3990 /// If set, the enum was initialized with an unknown value.
3991 ///
3992 /// Applications can examine the value using [ConsumerType::value] or
3993 /// [ConsumerType::name].
3994 UnknownValue(consumer_type::UnknownValue),
3995 }
3996
3997 #[doc(hidden)]
3998 pub mod consumer_type {
3999 #[allow(unused_imports)]
4000 use super::*;
4001 #[derive(Clone, Debug, PartialEq)]
4002 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4003 }
4004
4005 impl ConsumerType {
4006 /// Gets the enum value.
4007 ///
4008 /// Returns `None` if the enum contains an unknown value deserialized from
4009 /// the string representation of enums.
4010 pub fn value(&self) -> std::option::Option<i32> {
4011 match self {
4012 Self::Unspecified => std::option::Option::Some(0),
4013 Self::Project => std::option::Option::Some(1),
4014 Self::Folder => std::option::Option::Some(2),
4015 Self::Organization => std::option::Option::Some(3),
4016 Self::ServiceSpecific => std::option::Option::Some(4),
4017 Self::UnknownValue(u) => u.0.value(),
4018 }
4019 }
4020
4021 /// Gets the enum value as a string.
4022 ///
4023 /// Returns `None` if the enum contains an unknown value deserialized from
4024 /// the integer representation of enums.
4025 pub fn name(&self) -> std::option::Option<&str> {
4026 match self {
4027 Self::Unspecified => std::option::Option::Some("CONSUMER_TYPE_UNSPECIFIED"),
4028 Self::Project => std::option::Option::Some("PROJECT"),
4029 Self::Folder => std::option::Option::Some("FOLDER"),
4030 Self::Organization => std::option::Option::Some("ORGANIZATION"),
4031 Self::ServiceSpecific => std::option::Option::Some("SERVICE_SPECIFIC"),
4032 Self::UnknownValue(u) => u.0.name(),
4033 }
4034 }
4035 }
4036
4037 impl std::default::Default for ConsumerType {
4038 fn default() -> Self {
4039 use std::convert::From;
4040 Self::from(0)
4041 }
4042 }
4043
4044 impl std::fmt::Display for ConsumerType {
4045 fn fmt(
4046 &self,
4047 f: &mut std::fmt::Formatter<'_>,
4048 ) -> std::result::Result<(), std::fmt::Error> {
4049 wkt::internal::display_enum(f, self.name(), self.value())
4050 }
4051 }
4052
4053 impl std::convert::From<i32> for ConsumerType {
4054 fn from(value: i32) -> Self {
4055 match value {
4056 0 => Self::Unspecified,
4057 1 => Self::Project,
4058 2 => Self::Folder,
4059 3 => Self::Organization,
4060 4 => Self::ServiceSpecific,
4061 _ => Self::UnknownValue(consumer_type::UnknownValue(
4062 wkt::internal::UnknownEnumValue::Integer(value),
4063 )),
4064 }
4065 }
4066 }
4067
4068 impl std::convert::From<&str> for ConsumerType {
4069 fn from(value: &str) -> Self {
4070 use std::string::ToString;
4071 match value {
4072 "CONSUMER_TYPE_UNSPECIFIED" => Self::Unspecified,
4073 "PROJECT" => Self::Project,
4074 "FOLDER" => Self::Folder,
4075 "ORGANIZATION" => Self::Organization,
4076 "SERVICE_SPECIFIC" => Self::ServiceSpecific,
4077 _ => Self::UnknownValue(consumer_type::UnknownValue(
4078 wkt::internal::UnknownEnumValue::String(value.to_string()),
4079 )),
4080 }
4081 }
4082 }
4083
4084 impl serde::ser::Serialize for ConsumerType {
4085 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4086 where
4087 S: serde::Serializer,
4088 {
4089 match self {
4090 Self::Unspecified => serializer.serialize_i32(0),
4091 Self::Project => serializer.serialize_i32(1),
4092 Self::Folder => serializer.serialize_i32(2),
4093 Self::Organization => serializer.serialize_i32(3),
4094 Self::ServiceSpecific => serializer.serialize_i32(4),
4095 Self::UnknownValue(u) => u.0.serialize(serializer),
4096 }
4097 }
4098 }
4099
4100 impl<'de> serde::de::Deserialize<'de> for ConsumerType {
4101 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4102 where
4103 D: serde::Deserializer<'de>,
4104 {
4105 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ConsumerType>::new(
4106 ".google.api.servicecontrol.v1.CheckResponse.ConsumerInfo.ConsumerType",
4107 ))
4108 }
4109 }
4110 }
4111}
4112
4113/// Request message for the Report method.
4114#[derive(Clone, Default, PartialEq)]
4115#[non_exhaustive]
4116pub struct ReportRequest {
4117 /// The service name as specified in its service configuration. For example,
4118 /// `"pubsub.googleapis.com"`.
4119 ///
4120 /// See
4121 /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
4122 /// for the definition of a service name.
4123 pub service_name: std::string::String,
4124
4125 /// Operations to be reported.
4126 ///
4127 /// Typically the service should report one operation per request.
4128 /// Putting multiple operations into a single request is allowed, but should
4129 /// be used only when multiple operations are natually available at the time
4130 /// of the report.
4131 ///
4132 /// There is no limit on the number of operations in the same ReportRequest,
4133 /// however the ReportRequest size should be no larger than 1MB. See
4134 /// [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors]
4135 /// for partial failure behavior.
4136 ///
4137 /// [google.api.servicecontrol.v1.ReportResponse.report_errors]: crate::model::ReportResponse::report_errors
4138 pub operations: std::vec::Vec<crate::model::Operation>,
4139
4140 /// Specifies which version of service config should be used to process the
4141 /// request.
4142 ///
4143 /// If unspecified or no matching version can be found, the
4144 /// latest one will be used.
4145 pub service_config_id: std::string::String,
4146
4147 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4148}
4149
4150impl ReportRequest {
4151 pub fn new() -> Self {
4152 std::default::Default::default()
4153 }
4154
4155 /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
4156 ///
4157 /// # Example
4158 /// ```ignore,no_run
4159 /// # use google_cloud_api_servicecontrol_v1::model::ReportRequest;
4160 /// let x = ReportRequest::new().set_service_name("example");
4161 /// ```
4162 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4163 self.service_name = v.into();
4164 self
4165 }
4166
4167 /// Sets the value of [operations][crate::model::ReportRequest::operations].
4168 ///
4169 /// # Example
4170 /// ```ignore,no_run
4171 /// # use google_cloud_api_servicecontrol_v1::model::ReportRequest;
4172 /// use google_cloud_api_servicecontrol_v1::model::Operation;
4173 /// let x = ReportRequest::new()
4174 /// .set_operations([
4175 /// Operation::default()/* use setters */,
4176 /// Operation::default()/* use (different) setters */,
4177 /// ]);
4178 /// ```
4179 pub fn set_operations<T, V>(mut self, v: T) -> Self
4180 where
4181 T: std::iter::IntoIterator<Item = V>,
4182 V: std::convert::Into<crate::model::Operation>,
4183 {
4184 use std::iter::Iterator;
4185 self.operations = v.into_iter().map(|i| i.into()).collect();
4186 self
4187 }
4188
4189 /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
4190 ///
4191 /// # Example
4192 /// ```ignore,no_run
4193 /// # use google_cloud_api_servicecontrol_v1::model::ReportRequest;
4194 /// let x = ReportRequest::new().set_service_config_id("example");
4195 /// ```
4196 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
4197 mut self,
4198 v: T,
4199 ) -> Self {
4200 self.service_config_id = v.into();
4201 self
4202 }
4203}
4204
4205impl wkt::message::Message for ReportRequest {
4206 fn typename() -> &'static str {
4207 "type.googleapis.com/google.api.servicecontrol.v1.ReportRequest"
4208 }
4209}
4210
4211/// Response message for the Report method.
4212#[derive(Clone, Default, PartialEq)]
4213#[non_exhaustive]
4214pub struct ReportResponse {
4215 /// Partial failures, one for each `Operation` in the request that failed
4216 /// processing. There are three possible combinations of the RPC status:
4217 ///
4218 /// 1. The combination of a successful RPC status and an empty `report_errors`
4219 /// list indicates a complete success where all `Operations` in the
4220 /// request are processed successfully.
4221 /// 1. The combination of a successful RPC status and a non-empty
4222 /// `report_errors` list indicates a partial success where some
4223 /// `Operations` in the request succeeded. Each
4224 /// `Operation` that failed processing has a corresponding item
4225 /// in this list.
4226 /// 1. A failed RPC status indicates a general non-deterministic failure.
4227 /// When this happens, it's impossible to know which of the
4228 /// 'Operations' in the request succeeded or failed.
4229 pub report_errors: std::vec::Vec<crate::model::report_response::ReportError>,
4230
4231 /// The actual config id used to process the request.
4232 pub service_config_id: std::string::String,
4233
4234 /// The current service rollout id used to process the request.
4235 pub service_rollout_id: std::string::String,
4236
4237 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4238}
4239
4240impl ReportResponse {
4241 pub fn new() -> Self {
4242 std::default::Default::default()
4243 }
4244
4245 /// Sets the value of [report_errors][crate::model::ReportResponse::report_errors].
4246 ///
4247 /// # Example
4248 /// ```ignore,no_run
4249 /// # use google_cloud_api_servicecontrol_v1::model::ReportResponse;
4250 /// use google_cloud_api_servicecontrol_v1::model::report_response::ReportError;
4251 /// let x = ReportResponse::new()
4252 /// .set_report_errors([
4253 /// ReportError::default()/* use setters */,
4254 /// ReportError::default()/* use (different) setters */,
4255 /// ]);
4256 /// ```
4257 pub fn set_report_errors<T, V>(mut self, v: T) -> Self
4258 where
4259 T: std::iter::IntoIterator<Item = V>,
4260 V: std::convert::Into<crate::model::report_response::ReportError>,
4261 {
4262 use std::iter::Iterator;
4263 self.report_errors = v.into_iter().map(|i| i.into()).collect();
4264 self
4265 }
4266
4267 /// Sets the value of [service_config_id][crate::model::ReportResponse::service_config_id].
4268 ///
4269 /// # Example
4270 /// ```ignore,no_run
4271 /// # use google_cloud_api_servicecontrol_v1::model::ReportResponse;
4272 /// let x = ReportResponse::new().set_service_config_id("example");
4273 /// ```
4274 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
4275 mut self,
4276 v: T,
4277 ) -> Self {
4278 self.service_config_id = v.into();
4279 self
4280 }
4281
4282 /// Sets the value of [service_rollout_id][crate::model::ReportResponse::service_rollout_id].
4283 ///
4284 /// # Example
4285 /// ```ignore,no_run
4286 /// # use google_cloud_api_servicecontrol_v1::model::ReportResponse;
4287 /// let x = ReportResponse::new().set_service_rollout_id("example");
4288 /// ```
4289 pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
4290 mut self,
4291 v: T,
4292 ) -> Self {
4293 self.service_rollout_id = v.into();
4294 self
4295 }
4296}
4297
4298impl wkt::message::Message for ReportResponse {
4299 fn typename() -> &'static str {
4300 "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse"
4301 }
4302}
4303
4304/// Defines additional types related to [ReportResponse].
4305pub mod report_response {
4306 #[allow(unused_imports)]
4307 use super::*;
4308
4309 /// Represents the processing error of one
4310 /// [Operation][google.api.servicecontrol.v1.Operation] in the request.
4311 ///
4312 /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
4313 #[derive(Clone, Default, PartialEq)]
4314 #[non_exhaustive]
4315 pub struct ReportError {
4316 /// The
4317 /// [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id]
4318 /// value from the request.
4319 ///
4320 /// [google.api.servicecontrol.v1.Operation.operation_id]: crate::model::Operation::operation_id
4321 pub operation_id: std::string::String,
4322
4323 /// Details of the error when processing the
4324 /// [Operation][google.api.servicecontrol.v1.Operation].
4325 ///
4326 /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
4327 pub status: std::option::Option<rpc::model::Status>,
4328
4329 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4330 }
4331
4332 impl ReportError {
4333 pub fn new() -> Self {
4334 std::default::Default::default()
4335 }
4336
4337 /// Sets the value of [operation_id][crate::model::report_response::ReportError::operation_id].
4338 ///
4339 /// # Example
4340 /// ```ignore,no_run
4341 /// # use google_cloud_api_servicecontrol_v1::model::report_response::ReportError;
4342 /// let x = ReportError::new().set_operation_id("example");
4343 /// ```
4344 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(
4345 mut self,
4346 v: T,
4347 ) -> Self {
4348 self.operation_id = v.into();
4349 self
4350 }
4351
4352 /// Sets the value of [status][crate::model::report_response::ReportError::status].
4353 ///
4354 /// # Example
4355 /// ```ignore,no_run
4356 /// # use google_cloud_api_servicecontrol_v1::model::report_response::ReportError;
4357 /// use rpc::model::Status;
4358 /// let x = ReportError::new().set_status(Status::default()/* use setters */);
4359 /// ```
4360 pub fn set_status<T>(mut self, v: T) -> Self
4361 where
4362 T: std::convert::Into<rpc::model::Status>,
4363 {
4364 self.status = std::option::Option::Some(v.into());
4365 self
4366 }
4367
4368 /// Sets or clears the value of [status][crate::model::report_response::ReportError::status].
4369 ///
4370 /// # Example
4371 /// ```ignore,no_run
4372 /// # use google_cloud_api_servicecontrol_v1::model::report_response::ReportError;
4373 /// use rpc::model::Status;
4374 /// let x = ReportError::new().set_or_clear_status(Some(Status::default()/* use setters */));
4375 /// let x = ReportError::new().set_or_clear_status(None::<Status>);
4376 /// ```
4377 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
4378 where
4379 T: std::convert::Into<rpc::model::Status>,
4380 {
4381 self.status = v.map(|x| x.into());
4382 self
4383 }
4384 }
4385
4386 impl wkt::message::Message for ReportError {
4387 fn typename() -> &'static str {
4388 "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse.ReportError"
4389 }
4390 }
4391}