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