google_servicecontrol1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18
19    /// Manage your Google Service Control data
20    Full,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::Full => "https://www.googleapis.com/auth/servicecontrol",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::CloudPlatform
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all ServiceControl related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_servicecontrol1 as servicecontrol1;
53/// use servicecontrol1::api::CheckRequest;
54/// use servicecontrol1::{Result, Error};
55/// # async fn dox() {
56/// use servicecontrol1::{ServiceControl, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67///     secret,
68///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72///     hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75///     hyper_rustls::HttpsConnectorBuilder::new()
76///         .with_native_roots()
77///         .unwrap()
78///         .https_or_http()
79///         .enable_http1()
80///         .build()
81/// );
82/// let mut hub = ServiceControl::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = CheckRequest::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.services().check(req, "serviceName")
92///              .doit().await;
93///
94/// match result {
95///     Err(e) => match e {
96///         // The Error enum provides details about what exactly happened.
97///         // You can also just use its `Debug`, `Display` or `Error` traits
98///          Error::HttpError(_)
99///         |Error::Io(_)
100///         |Error::MissingAPIKey
101///         |Error::MissingToken(_)
102///         |Error::Cancelled
103///         |Error::UploadSizeLimitExceeded(_, _)
104///         |Error::Failure(_)
105///         |Error::BadRequest(_)
106///         |Error::FieldClash(_)
107///         |Error::JsonDecodeError(_, _) => println!("{}", e),
108///     },
109///     Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct ServiceControl<C> {
115    pub client: common::Client<C>,
116    pub auth: Box<dyn common::GetToken>,
117    _user_agent: String,
118    _base_url: String,
119    _root_url: String,
120}
121
122impl<C> common::Hub for ServiceControl<C> {}
123
124impl<'a, C> ServiceControl<C> {
125    pub fn new<A: 'static + common::GetToken>(
126        client: common::Client<C>,
127        auth: A,
128    ) -> ServiceControl<C> {
129        ServiceControl {
130            client,
131            auth: Box::new(auth),
132            _user_agent: "google-api-rust-client/6.0.0".to_string(),
133            _base_url: "https://servicecontrol.googleapis.com/".to_string(),
134            _root_url: "https://servicecontrol.googleapis.com/".to_string(),
135        }
136    }
137
138    pub fn services(&'a self) -> ServiceMethods<'a, C> {
139        ServiceMethods { hub: self }
140    }
141
142    /// Set the user-agent header field to use in all requests to the server.
143    /// It defaults to `google-api-rust-client/6.0.0`.
144    ///
145    /// Returns the previously set user-agent.
146    pub fn user_agent(&mut self, agent_name: String) -> String {
147        std::mem::replace(&mut self._user_agent, agent_name)
148    }
149
150    /// Set the base url to use in all requests to the server.
151    /// It defaults to `https://servicecontrol.googleapis.com/`.
152    ///
153    /// Returns the previously set base url.
154    pub fn base_url(&mut self, new_base_url: String) -> String {
155        std::mem::replace(&mut self._base_url, new_base_url)
156    }
157
158    /// Set the root url to use in all requests to the server.
159    /// It defaults to `https://servicecontrol.googleapis.com/`.
160    ///
161    /// Returns the previously set root url.
162    pub fn root_url(&mut self, new_root_url: String) -> String {
163        std::mem::replace(&mut self._root_url, new_root_url)
164    }
165}
166
167// ############
168// SCHEMAS ###
169// ##########
170/// There is no detailed description.
171///
172/// This type is not used in any activity, and only used as *part* of another schema.
173///
174#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
175#[serde_with::serde_as]
176#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
177pub struct AllocateInfo {
178    /// A list of label keys that were unused by the server in processing the request. Thus, for similar requests repeated in a certain future time window, the caller can choose to ignore these labels in the requests to achieve better client-side cache hits and quota aggregation for rate quota. This field is not populated for allocation quota checks.
179    #[serde(rename = "unusedArguments")]
180    pub unused_arguments: Option<Vec<String>>,
181}
182
183impl common::Part for AllocateInfo {}
184
185/// Request message for the AllocateQuota method.
186///
187/// # Activities
188///
189/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
190/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
191///
192/// * [allocate quota services](ServiceAllocateQuotaCall) (request)
193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
194#[serde_with::serde_as]
195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
196pub struct AllocateQuotaRequest {
197    /// Operation that describes the quota allocation.
198    #[serde(rename = "allocateOperation")]
199    pub allocate_operation: Option<QuotaOperation>,
200    /// Specifies which version of service configuration should be used to process the request. If unspecified or no matching version can be found, the latest one will be used.
201    #[serde(rename = "serviceConfigId")]
202    pub service_config_id: Option<String>,
203}
204
205impl common::RequestValue for AllocateQuotaRequest {}
206
207/// Response message for the AllocateQuota method.
208///
209/// # Activities
210///
211/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
212/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
213///
214/// * [allocate quota services](ServiceAllocateQuotaCall) (response)
215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
216#[serde_with::serde_as]
217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
218pub struct AllocateQuotaResponse {
219    /// Indicates the decision of the allocate.
220    #[serde(rename = "allocateErrors")]
221    pub allocate_errors: Option<Vec<QuotaError>>,
222    /// WARNING: DO NOT use this field until this warning message is removed.
223    #[serde(rename = "allocateInfo")]
224    pub allocate_info: Option<AllocateInfo>,
225    /// The same operation_id value used in the AllocateQuotaRequest. Used for logging and diagnostics purposes.
226    #[serde(rename = "operationId")]
227    pub operation_id: Option<String>,
228    /// Quota metrics to indicate the result of allocation. Depending on the request, one or more of the following metrics will be included: 1. Per quota group or per quota metric incremental usage will be specified using the following delta metric : "serviceruntime.googleapis.com/api/consumer/quota_used_count" 2. The quota limit reached condition will be specified using the following boolean metric : "serviceruntime.googleapis.com/quota/exceeded"
229    #[serde(rename = "quotaMetrics")]
230    pub quota_metrics: Option<Vec<MetricValueSet>>,
231    /// ID of the actual config used to process the request.
232    #[serde(rename = "serviceConfigId")]
233    pub service_config_id: Option<String>,
234}
235
236impl common::ResponseResult for AllocateQuotaResponse {}
237
238/// The allowed types for [VALUE] in a `[KEY]:[VALUE]` attribute.
239///
240/// This type is not used in any activity, and only used as *part* of another schema.
241///
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct AttributeValue {
246    /// A Boolean value represented by `true` or `false`.
247    #[serde(rename = "boolValue")]
248    pub bool_value: Option<bool>,
249    /// A 64-bit signed integer.
250    #[serde(rename = "intValue")]
251    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
252    pub int_value: Option<i64>,
253    /// A string up to 256 bytes long.
254    #[serde(rename = "stringValue")]
255    pub string_value: Option<TruncatableString>,
256}
257
258impl common::Part for AttributeValue {}
259
260/// A set of attributes, each in the format `[KEY]:[VALUE]`.
261///
262/// This type is not used in any activity, and only used as *part* of another schema.
263///
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct Attributes {
268    /// The set of attributes. Each attribute's key can be up to 128 bytes long. The value can be a string up to 256 bytes, a signed 64-bit integer, or the Boolean values `true` and `false`. For example: "/instance_id": "my-instance" "/http/user_agent": "" "/http/request_bytes": 300 "abc.com/myattribute": true
269    #[serde(rename = "attributeMap")]
270    pub attribute_map: Option<HashMap<String, AttributeValue>>,
271    /// The number of attributes that were discarded. Attributes can be discarded because their keys are too long or because there are too many attributes. If this value is 0 then all attributes are valid.
272    #[serde(rename = "droppedAttributesCount")]
273    pub dropped_attributes_count: Option<i32>,
274}
275
276impl common::Part for Attributes {}
277
278/// Defines the errors to be returned in google.api.servicecontrol.v1.CheckResponse.check_errors.
279///
280/// This type is not used in any activity, and only used as *part* of another schema.
281///
282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
283#[serde_with::serde_as]
284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
285pub struct CheckError {
286    /// The error code.
287    pub code: Option<String>,
288    /// Free-form text providing details on the error cause of the error.
289    pub detail: Option<String>,
290    /// Contains public information about the check error. If available, `status.code` will be non zero and client can propagate it out as public error.
291    pub status: Option<Status>,
292    /// Subject to whom this error applies. See the specific code enum for more details on this field. For example: - "project:" - "folder:" - "organization:"
293    pub subject: Option<String>,
294}
295
296impl common::Part for CheckError {}
297
298/// Contains additional information about the check operation.
299///
300/// This type is not used in any activity, and only used as *part* of another schema.
301///
302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
303#[serde_with::serde_as]
304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
305pub struct CheckInfo {
306    /// The unique id of the api key in the format of "apikey:". This field will be populated when the consumer passed to Chemist is an API key and all the API key related validations are successful.
307    #[serde(rename = "apiKeyUid")]
308    pub api_key_uid: Option<String>,
309    /// Consumer info of this check.
310    #[serde(rename = "consumerInfo")]
311    pub consumer_info: Option<ConsumerInfo>,
312    /// A list of fields and label keys that are ignored by the server. The client doesn't need to send them for following requests to improve performance and allow better aggregation.
313    #[serde(rename = "unusedArguments")]
314    pub unused_arguments: Option<Vec<String>>,
315}
316
317impl common::Part for CheckInfo {}
318
319/// Request message for the Check method.
320///
321/// # Activities
322///
323/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
324/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
325///
326/// * [check services](ServiceCheckCall) (request)
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct CheckRequest {
331    /// The operation to be checked.
332    pub operation: Option<Operation>,
333    /// Requests the project settings to be returned as part of the check response.
334    #[serde(rename = "requestProjectSettings")]
335    pub request_project_settings: Option<bool>,
336    /// Specifies which version of service configuration should be used to process the request. If unspecified or no matching version can be found, the latest one will be used.
337    #[serde(rename = "serviceConfigId")]
338    pub service_config_id: Option<String>,
339    /// Indicates if service activation check should be skipped for this request. Default behavior is to perform the check and apply relevant quota. WARNING: Setting this flag to "true" will disable quota enforcement.
340    #[serde(rename = "skipActivationCheck")]
341    pub skip_activation_check: Option<bool>,
342}
343
344impl common::RequestValue for CheckRequest {}
345
346/// Response message for the Check method.
347///
348/// # Activities
349///
350/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
351/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
352///
353/// * [check services](ServiceCheckCall) (response)
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct CheckResponse {
358    /// Indicate the decision of the check. If no check errors are present, the service should process the operation. Otherwise the service should use the list of errors to determine the appropriate action.
359    #[serde(rename = "checkErrors")]
360    pub check_errors: Option<Vec<CheckError>>,
361    /// Feedback data returned from the server during processing a Check request.
362    #[serde(rename = "checkInfo")]
363    pub check_info: Option<CheckInfo>,
364    /// The same operation_id value used in the CheckRequest. Used for logging and diagnostics purposes.
365    #[serde(rename = "operationId")]
366    pub operation_id: Option<String>,
367    /// Quota information for the check request associated with this response.
368    #[serde(rename = "quotaInfo")]
369    pub quota_info: Option<QuotaInfo>,
370    /// The actual config id used to process the request.
371    #[serde(rename = "serviceConfigId")]
372    pub service_config_id: Option<String>,
373    /// The current service rollout id used to process the request.
374    #[serde(rename = "serviceRolloutId")]
375    pub service_rollout_id: Option<String>,
376}
377
378impl common::ResponseResult for CheckResponse {}
379
380/// `ConsumerInfo` provides information about the consumer.
381///
382/// This type is not used in any activity, and only used as *part* of another schema.
383///
384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
385#[serde_with::serde_as]
386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
387pub struct ConsumerInfo {
388    /// The consumer identity number, can be Google cloud project number, folder number or organization number e.g. 1234567890. A value of 0 indicates no consumer number is found.
389    #[serde(rename = "consumerNumber")]
390    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
391    pub consumer_number: Option<i64>,
392    /// The Google cloud project number, e.g. 1234567890. A value of 0 indicates no project number is found. NOTE: This field is deprecated after Chemist support flexible consumer id. New code should not depend on this field anymore.
393    #[serde(rename = "projectNumber")]
394    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
395    pub project_number: Option<i64>,
396    /// The type of the consumer which should have been defined in [Google Resource Manager](https://cloud.google.com/resource-manager/).
397    #[serde(rename = "type")]
398    pub type_: Option<String>,
399}
400
401impl common::Part for ConsumerInfo {}
402
403/// Distribution represents a frequency distribution of double-valued sample points. It contains the size of the population of sample points plus additional optional information: * the arithmetic mean of the samples * the minimum and maximum of the samples * the sum-squared-deviation of the samples, used to compute variance * a histogram of the values of the sample points
404///
405/// This type is not used in any activity, and only used as *part* of another schema.
406///
407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
408#[serde_with::serde_as]
409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
410pub struct Distribution {
411    /// The number of samples in each histogram bucket. `bucket_counts` are optional. If present, they must sum to the `count` value. The buckets are defined below in `bucket_option`. There are N buckets. `bucket_counts[0]` is the number of samples in the underflow bucket. `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples in each of the finite buckets. And `bucket_counts[N] is the number of samples in the overflow bucket. See the comments of `bucket_option` below for more details. Any suffix of trailing zeros may be omitted.
412    #[serde(rename = "bucketCounts")]
413    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
414    pub bucket_counts: Option<Vec<i64>>,
415    /// The total number of samples in the distribution. Must be >= 0.
416    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
417    pub count: Option<i64>,
418    /// Example points. Must be in increasing order of `value` field.
419    pub exemplars: Option<Vec<Exemplar>>,
420    /// Buckets with arbitrary user-provided width.
421    #[serde(rename = "explicitBuckets")]
422    pub explicit_buckets: Option<ExplicitBuckets>,
423    /// Buckets with exponentially growing width.
424    #[serde(rename = "exponentialBuckets")]
425    pub exponential_buckets: Option<ExponentialBuckets>,
426    /// Buckets with constant width.
427    #[serde(rename = "linearBuckets")]
428    pub linear_buckets: Option<LinearBuckets>,
429    /// The maximum of the population of values. Ignored if `count` is zero.
430    pub maximum: Option<f64>,
431    /// The arithmetic mean of the samples in the distribution. If `count` is zero then this field must be zero.
432    pub mean: Option<f64>,
433    /// The minimum of the population of values. Ignored if `count` is zero.
434    pub minimum: Option<f64>,
435    /// The sum of squared deviations from the mean: Sum\[i=1..count\]((x_i - mean)^2) where each x_i is a sample values. If `count` is zero then this field must be zero, otherwise validation of the request fails.
436    #[serde(rename = "sumOfSquaredDeviation")]
437    pub sum_of_squared_deviation: Option<f64>,
438}
439
440impl common::Part for Distribution {}
441
442/// Exemplars are example points that may be used to annotate aggregated distribution values. They are metadata that gives information about a particular value added to a Distribution bucket, such as a trace ID that was active when a value was added. They may contain further information, such as a example values and timestamps, origin, etc.
443///
444/// This type is not used in any activity, and only used as *part* of another schema.
445///
446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
447#[serde_with::serde_as]
448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
449pub struct Exemplar {
450    /// Contextual information about the example value. Examples are: Trace: type.googleapis.com/google.monitoring.v3.SpanContext Literal string: type.googleapis.com/google.protobuf.StringValue Labels dropped during aggregation: type.googleapis.com/google.monitoring.v3.DroppedLabels There may be only a single attachment of any given message type in a single exemplar, and this is enforced by the system.
451    pub attachments: Option<Vec<HashMap<String, serde_json::Value>>>,
452    /// The observation (sampling) time of the above value.
453    pub timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
454    /// Value of the exemplar point. This value determines to which bucket the exemplar belongs.
455    pub value: Option<f64>,
456}
457
458impl common::Part for Exemplar {}
459
460/// Describing buckets with arbitrary user-provided width.
461///
462/// This type is not used in any activity, and only used as *part* of another schema.
463///
464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
465#[serde_with::serde_as]
466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
467pub struct ExplicitBuckets {
468    /// 'bound' is a list of strictly increasing boundaries between buckets. Note that a list of length N-1 defines N buckets because of fenceposting. See comments on `bucket_options` for details. The i'th finite bucket covers the interval [bound[i-1], bound[i]) where i ranges from 1 to bound_size() - 1. Note that there are no finite buckets at all if 'bound' only contains a single element; in that special case the single bound defines the boundary between the underflow and overflow buckets. bucket number lower bound upper bound i == 0 (underflow) -inf bound[i] 0 < i < bound_size() bound[i-1] bound[i] i == bound_size() (overflow) bound[i-1] +inf
469    pub bounds: Option<Vec<f64>>,
470}
471
472impl common::Part for ExplicitBuckets {}
473
474/// Describing buckets with exponentially growing width.
475///
476/// This type is not used in any activity, and only used as *part* of another schema.
477///
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct ExponentialBuckets {
482    /// The i'th exponential bucket covers the interval [scale * growth_factor^(i-1), scale * growth_factor^i) where i ranges from 1 to num_finite_buckets inclusive. Must be larger than 1.0.
483    #[serde(rename = "growthFactor")]
484    pub growth_factor: Option<f64>,
485    /// The number of finite buckets. With the underflow and overflow buckets, the total number of buckets is `num_finite_buckets` + 2. See comments on `bucket_options` for details.
486    #[serde(rename = "numFiniteBuckets")]
487    pub num_finite_buckets: Option<i32>,
488    /// The i'th exponential bucket covers the interval [scale * growth_factor^(i-1), scale * growth_factor^i) where i ranges from 1 to num_finite_buckets inclusive. Must be > 0.
489    pub scale: Option<f64>,
490}
491
492impl common::Part for ExponentialBuckets {}
493
494/// A common proto for logging HTTP requests. Only contains semantics defined by the HTTP specification. Product-specific logging information MUST be defined in a separate message.
495///
496/// This type is not used in any activity, and only used as *part* of another schema.
497///
498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
499#[serde_with::serde_as]
500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
501pub struct HttpRequest {
502    /// The number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted.
503    #[serde(rename = "cacheFillBytes")]
504    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
505    pub cache_fill_bytes: Option<i64>,
506    /// Whether or not an entity was served from cache (with or without validation).
507    #[serde(rename = "cacheHit")]
508    pub cache_hit: Option<bool>,
509    /// Whether or not a cache lookup was attempted.
510    #[serde(rename = "cacheLookup")]
511    pub cache_lookup: Option<bool>,
512    /// Whether or not the response was validated with the origin server before being served from cache. This field is only meaningful if `cache_hit` is True.
513    #[serde(rename = "cacheValidatedWithOriginServer")]
514    pub cache_validated_with_origin_server: Option<bool>,
515    /// The request processing latency on the server, from the time the request was received until the response was sent.
516    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
517    pub latency: Option<chrono::Duration>,
518    /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
519    pub protocol: Option<String>,
520    /// The referer URL of the request, as defined in [HTTP/1.1 Header Field Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
521    pub referer: Option<String>,
522    /// The IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
523    #[serde(rename = "remoteIp")]
524    pub remote_ip: Option<String>,
525    /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
526    #[serde(rename = "requestMethod")]
527    pub request_method: Option<String>,
528    /// The size of the HTTP request message in bytes, including the request headers and the request body.
529    #[serde(rename = "requestSize")]
530    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
531    pub request_size: Option<i64>,
532    /// The scheme (http, https), the host name, the path, and the query portion of the URL that was requested. Example: `"http://example.com/some/info?color=red"`.
533    #[serde(rename = "requestUrl")]
534    pub request_url: Option<String>,
535    /// The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body.
536    #[serde(rename = "responseSize")]
537    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
538    pub response_size: Option<i64>,
539    /// The IP address (IPv4 or IPv6) of the origin server that the request was sent to.
540    #[serde(rename = "serverIp")]
541    pub server_ip: Option<String>,
542    /// The response code indicating the status of the response. Examples: 200, 404.
543    pub status: Option<i32>,
544    /// The user agent sent by the client. Example: `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)"`.
545    #[serde(rename = "userAgent")]
546    pub user_agent: Option<String>,
547}
548
549impl common::Part for HttpRequest {}
550
551/// Describing buckets with constant width.
552///
553/// This type is not used in any activity, and only used as *part* of another schema.
554///
555#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
556#[serde_with::serde_as]
557#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
558pub struct LinearBuckets {
559    /// The number of finite buckets. With the underflow and overflow buckets, the total number of buckets is `num_finite_buckets` + 2. See comments on `bucket_options` for details.
560    #[serde(rename = "numFiniteBuckets")]
561    pub num_finite_buckets: Option<i32>,
562    /// The i'th linear bucket covers the interval [offset + (i-1) * width, offset + i * width) where i ranges from 1 to num_finite_buckets, inclusive.
563    pub offset: Option<f64>,
564    /// The i'th linear bucket covers the interval [offset + (i-1) * width, offset + i * width) where i ranges from 1 to num_finite_buckets, inclusive. Must be strictly positive.
565    pub width: Option<f64>,
566}
567
568impl common::Part for LinearBuckets {}
569
570/// An individual log entry.
571///
572/// This type is not used in any activity, and only used as *part* of another schema.
573///
574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
575#[serde_with::serde_as]
576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
577pub struct LogEntry {
578    /// Optional. Information about the HTTP request associated with this log entry, if applicable.
579    #[serde(rename = "httpRequest")]
580    pub http_request: Option<HttpRequest>,
581    /// A unique ID for the log entry used for deduplication. If omitted, the implementation will generate one based on operation_id.
582    #[serde(rename = "insertId")]
583    pub insert_id: Option<String>,
584    /// A set of user-defined (key, value) data that provides additional information about the log entry.
585    pub labels: Option<HashMap<String, String>>,
586    /// Required. The log to which this log entry belongs. Examples: `"syslog"`, `"book_log"`.
587    pub name: Option<String>,
588    /// Optional. Information about an operation associated with the log entry, if applicable.
589    pub operation: Option<LogEntryOperation>,
590    /// The log entry payload, represented as a protocol buffer that is expressed as a JSON object. The only accepted type currently is AuditLog.
591    #[serde(rename = "protoPayload")]
592    pub proto_payload: Option<HashMap<String, serde_json::Value>>,
593    /// The severity of the log entry. The default value is `LogSeverity.DEFAULT`.
594    pub severity: Option<String>,
595    /// Optional. Source code location information associated with the log entry, if any.
596    #[serde(rename = "sourceLocation")]
597    pub source_location: Option<LogEntrySourceLocation>,
598    /// The log entry payload, represented as a structure that is expressed as a JSON object.
599    #[serde(rename = "structPayload")]
600    pub struct_payload: Option<HashMap<String, serde_json::Value>>,
601    /// The log entry payload, represented as a Unicode string (UTF-8).
602    #[serde(rename = "textPayload")]
603    pub text_payload: Option<String>,
604    /// The time the event described by the log entry occurred. If omitted, defaults to operation start time.
605    pub timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
606    /// Optional. Resource name of the trace associated with the log entry, if any. If this field contains a relative resource name, you can assume the name is relative to `//tracing.googleapis.com`. Example: `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824`
607    pub trace: Option<String>,
608}
609
610impl common::Part for LogEntry {}
611
612/// Additional information about a potentially long-running operation with which a log entry is associated.
613///
614/// This type is not used in any activity, and only used as *part* of another schema.
615///
616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
617#[serde_with::serde_as]
618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
619pub struct LogEntryOperation {
620    /// Optional. Set this to True if this is the first log entry in the operation.
621    pub first: Option<bool>,
622    /// Optional. An arbitrary operation identifier. Log entries with the same identifier are assumed to be part of the same operation.
623    pub id: Option<String>,
624    /// Optional. Set this to True if this is the last log entry in the operation.
625    pub last: Option<bool>,
626    /// Optional. An arbitrary producer identifier. The combination of `id` and `producer` must be globally unique. Examples for `producer`: `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`.
627    pub producer: Option<String>,
628}
629
630impl common::Part for LogEntryOperation {}
631
632/// Additional information about the source code location that produced the log entry.
633///
634/// This type is not used in any activity, and only used as *part* of another schema.
635///
636#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
637#[serde_with::serde_as]
638#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
639pub struct LogEntrySourceLocation {
640    /// Optional. Source file name. Depending on the runtime environment, this might be a simple name or a fully-qualified name.
641    pub file: Option<String>,
642    /// Optional. Human-readable name of the function or method being invoked, with optional context such as the class or package name. This information may be used in contexts such as the logs viewer, where a file and line number are less meaningful. The format can vary by language. For example: `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` (Python).
643    pub function: Option<String>,
644    /// Optional. Line within the source file. 1-based; 0 indicates no line number available.
645    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
646    pub line: Option<i64>,
647}
648
649impl common::Part for LogEntrySourceLocation {}
650
651/// Represents a single metric value.
652///
653/// This type is not used in any activity, and only used as *part* of another schema.
654///
655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
656#[serde_with::serde_as]
657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
658pub struct MetricValue {
659    /// A boolean value.
660    #[serde(rename = "boolValue")]
661    pub bool_value: Option<bool>,
662    /// A distribution value.
663    #[serde(rename = "distributionValue")]
664    pub distribution_value: Option<Distribution>,
665    /// A double precision floating point value.
666    #[serde(rename = "doubleValue")]
667    pub double_value: Option<f64>,
668    /// The end of the time period over which this metric value's measurement applies. If not specified, google.api.servicecontrol.v1.Operation.end_time will be used.
669    #[serde(rename = "endTime")]
670    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
671    /// A signed 64-bit integer value.
672    #[serde(rename = "int64Value")]
673    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
674    pub int64_value: Option<i64>,
675    /// The labels describing the metric value. See comments on google.api.servicecontrol.v1.Operation.labels for the overriding relationship. Note that this map must not contain monitored resource labels.
676    pub labels: Option<HashMap<String, String>>,
677    /// A money value.
678    #[serde(rename = "moneyValue")]
679    pub money_value: Option<Money>,
680    /// The start of the time period over which this metric value's measurement applies. The time period has different semantics for different metric types (cumulative, delta, and gauge). See the metric definition documentation in the service configuration for details. If not specified, google.api.servicecontrol.v1.Operation.start_time will be used.
681    #[serde(rename = "startTime")]
682    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
683    /// A text string value.
684    #[serde(rename = "stringValue")]
685    pub string_value: Option<String>,
686}
687
688impl common::Part for MetricValue {}
689
690/// Represents a set of metric values in the same metric. Each metric value in the set should have a unique combination of start time, end time, and label values.
691///
692/// This type is not used in any activity, and only used as *part* of another schema.
693///
694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
695#[serde_with::serde_as]
696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
697pub struct MetricValueSet {
698    /// The metric name defined in the service configuration.
699    #[serde(rename = "metricName")]
700    pub metric_name: Option<String>,
701    /// The values in this metric.
702    #[serde(rename = "metricValues")]
703    pub metric_values: Option<Vec<MetricValue>>,
704}
705
706impl common::Part for MetricValueSet {}
707
708/// Represents an amount of money with its currency type.
709///
710/// This type is not used in any activity, and only used as *part* of another schema.
711///
712#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
713#[serde_with::serde_as]
714#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
715pub struct Money {
716    /// The three-letter currency code defined in ISO 4217.
717    #[serde(rename = "currencyCode")]
718    pub currency_code: Option<String>,
719    /// Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` must be positive or zero. If `units` is zero, `nanos` can be positive, zero, or negative. If `units` is negative, `nanos` must be negative or zero. For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
720    pub nanos: Option<i32>,
721    /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
722    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
723    pub units: Option<i64>,
724}
725
726impl common::Part for Money {}
727
728/// Represents information regarding an operation.
729///
730/// This type is not used in any activity, and only used as *part* of another schema.
731///
732#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
733#[serde_with::serde_as]
734#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
735pub struct Operation {
736    /// Identity of the consumer who is using the service. This field should be filled in for the operations initiated by a consumer, but not for service-initiated operations that are not related to a specific consumer. - This can be in one of the following formats: - project:PROJECT_ID, - project`_`number:PROJECT_NUMBER, - projects/PROJECT_ID or PROJECT_NUMBER, - folders/FOLDER_NUMBER, - organizations/ORGANIZATION_NUMBER, - api`_`key:API_KEY.
737    #[serde(rename = "consumerId")]
738    pub consumer_id: Option<String>,
739    /// End time of the operation. Required when the operation is used in ServiceController.Report, but optional when the operation is used in ServiceController.Check.
740    #[serde(rename = "endTime")]
741    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
742    /// DO NOT USE. This is an experimental field.
743    pub importance: Option<String>,
744    /// Labels describing the operation. Only the following labels are allowed: - Labels describing monitored resources as defined in the service configuration. - Default labels of metric values. When specified, labels defined in the metric value override these default. - The following labels defined by Google Cloud Platform: - `cloud.googleapis.com/location` describing the location where the operation happened, - `servicecontrol.googleapis.com/user_agent` describing the user agent of the API request, - `servicecontrol.googleapis.com/service_agent` describing the service used to handle the API request (e.g. ESP), - `servicecontrol.googleapis.com/platform` describing the platform where the API is served, such as App Engine, Compute Engine, or Kubernetes Engine.
745    pub labels: Option<HashMap<String, String>>,
746    /// Represents information to be logged.
747    #[serde(rename = "logEntries")]
748    pub log_entries: Option<Vec<LogEntry>>,
749    /// Represents information about this operation. Each MetricValueSet corresponds to a metric defined in the service configuration. The data type used in the MetricValueSet must agree with the data type specified in the metric definition. Within a single operation, it is not allowed to have more than one MetricValue instances that have the same metric names and identical label value combinations. If a request has such duplicated MetricValue instances, the entire request is rejected with an invalid argument error.
750    #[serde(rename = "metricValueSets")]
751    pub metric_value_sets: Option<Vec<MetricValueSet>>,
752    /// Identity of the operation. This must be unique within the scope of the service that generated the operation. If the service calls Check() and Report() on the same operation, the two calls should carry the same id. UUID version 4 is recommended, though not required. In scenarios where an operation is computed from existing information and an idempotent id is desirable for deduplication purpose, UUID version 5 is recommended. See RFC 4122 for details.
753    #[serde(rename = "operationId")]
754    pub operation_id: Option<String>,
755    /// Fully qualified name of the operation. Reserved for future use.
756    #[serde(rename = "operationName")]
757    pub operation_name: Option<String>,
758    /// Represents the properties needed for quota check. Applicable only if this operation is for a quota check request. If this is not specified, no quota check will be performed.
759    #[serde(rename = "quotaProperties")]
760    pub quota_properties: Option<QuotaProperties>,
761    /// The resources that are involved in the operation. The maximum supported number of entries in this field is 100.
762    pub resources: Option<Vec<ResourceInfo>>,
763    /// Required. Start time of the operation.
764    #[serde(rename = "startTime")]
765    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
766    /// Unimplemented. A list of Cloud Trace spans. The span names shall contain the id of the destination project which can be either the produce or the consumer project.
767    #[serde(rename = "traceSpans")]
768    pub trace_spans: Option<Vec<TraceSpan>>,
769    /// Private Preview. This feature is only available for approved services. User defined labels for the resource that this operation is associated with.
770    #[serde(rename = "userLabels")]
771    pub user_labels: Option<HashMap<String, String>>,
772}
773
774impl common::Part for Operation {}
775
776/// Represents error information for QuotaOperation.
777///
778/// This type is not used in any activity, and only used as *part* of another schema.
779///
780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
781#[serde_with::serde_as]
782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
783pub struct QuotaError {
784    /// Error code.
785    pub code: Option<String>,
786    /// Free-form text that provides details on the cause of the error.
787    pub description: Option<String>,
788    /// Contains additional information about the quota error. If available, `status.code` will be non zero.
789    pub status: Option<Status>,
790    /// Subject to whom this error applies. See the specific enum for more details on this field. For example, "clientip:" or "project:".
791    pub subject: Option<String>,
792}
793
794impl common::Part for QuotaError {}
795
796/// Contains the quota information for a quota check response.
797///
798/// This type is not used in any activity, and only used as *part* of another schema.
799///
800#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
801#[serde_with::serde_as]
802#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
803pub struct QuotaInfo {
804    /// Quota Metrics that have exceeded quota limits. For QuotaGroup-based quota, this is QuotaGroup.name For QuotaLimit-based quota, this is QuotaLimit.name See: google.api.Quota Deprecated: Use quota_metrics to get per quota group limit exceeded status.
805    #[serde(rename = "limitExceeded")]
806    pub limit_exceeded: Option<Vec<String>>,
807    /// Map of quota group name to the actual number of tokens consumed. If the quota check was not successful, then this will not be populated due to no quota consumption. We are not merging this field with 'quota_metrics' field because of the complexity of scaling in Chemist client code base. For simplicity, we will keep this field for Castor (that scales quota usage) and 'quota_metrics' for SuperQuota (that doesn't scale quota usage).
808    #[serde(rename = "quotaConsumed")]
809    pub quota_consumed: Option<HashMap<String, i32>>,
810    /// Quota metrics to indicate the usage. Depending on the check request, one or more of the following metrics will be included: 1. For rate quota, per quota group or per quota metric incremental usage will be specified using the following delta metric: "serviceruntime.googleapis.com/api/consumer/quota_used_count" 2. For allocation quota, per quota metric total usage will be specified using the following gauge metric: "serviceruntime.googleapis.com/allocation/consumer/quota_used_count" 3. For both rate quota and allocation quota, the quota limit reached condition will be specified using the following boolean metric: "serviceruntime.googleapis.com/quota/exceeded"
811    #[serde(rename = "quotaMetrics")]
812    pub quota_metrics: Option<Vec<MetricValueSet>>,
813}
814
815impl common::Part for QuotaInfo {}
816
817/// Represents information regarding a quota operation.
818///
819/// This type is not used in any activity, and only used as *part* of another schema.
820///
821#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
822#[serde_with::serde_as]
823#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
824pub struct QuotaOperation {
825    /// Identity of the consumer for whom this quota operation is being performed. This can be in one of the following formats: project:, project_number:, api_key:.
826    #[serde(rename = "consumerId")]
827    pub consumer_id: Option<String>,
828    /// Labels describing the operation.
829    pub labels: Option<HashMap<String, String>>,
830    /// Fully qualified name of the API method for which this quota operation is requested. This name is used for matching quota rules or metric rules and billing status rules defined in service configuration. This field should not be set if any of the following is true: (1) the quota operation is performed on non-API resources. (2) quota_metrics is set because the caller is doing quota override. Example of an RPC method name: google.example.library.v1.LibraryService.CreateShelf
831    #[serde(rename = "methodName")]
832    pub method_name: Option<String>,
833    /// Identity of the operation. For Allocation Quota, this is expected to be unique within the scope of the service that generated the operation, and guarantees idempotency in case of retries. In order to ensure best performance and latency in the Quota backends, operation_ids are optimally associated with time, so that related operations can be accessed fast in storage. For this reason, the recommended token for services that intend to operate at a high QPS is Unix time in nanos + UUID
834    #[serde(rename = "operationId")]
835    pub operation_id: Option<String>,
836    /// Represents information about this operation. Each MetricValueSet corresponds to a metric defined in the service configuration. The data type used in the MetricValueSet must agree with the data type specified in the metric definition. Within a single operation, it is not allowed to have more than one MetricValue instances that have the same metric names and identical label value combinations. If a request has such duplicated MetricValue instances, the entire request is rejected with an invalid argument error. This field is mutually exclusive with method_name.
837    #[serde(rename = "quotaMetrics")]
838    pub quota_metrics: Option<Vec<MetricValueSet>>,
839    /// Quota mode for this operation.
840    #[serde(rename = "quotaMode")]
841    pub quota_mode: Option<String>,
842}
843
844impl common::Part for QuotaOperation {}
845
846/// Represents the properties needed for quota operations.
847///
848/// This type is not used in any activity, and only used as *part* of another schema.
849///
850#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
851#[serde_with::serde_as]
852#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
853pub struct QuotaProperties {
854    /// Quota mode for this operation.
855    #[serde(rename = "quotaMode")]
856    pub quota_mode: Option<String>,
857}
858
859impl common::Part for QuotaProperties {}
860
861/// Represents the processing error of one Operation in the request.
862///
863/// This type is not used in any activity, and only used as *part* of another schema.
864///
865#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
866#[serde_with::serde_as]
867#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
868pub struct ReportError {
869    /// The Operation.operation_id value from the request.
870    #[serde(rename = "operationId")]
871    pub operation_id: Option<String>,
872    /// Details of the error when processing the Operation.
873    pub status: Option<Status>,
874}
875
876impl common::Part for ReportError {}
877
878/// Request message for the Report method.
879///
880/// # Activities
881///
882/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
883/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
884///
885/// * [report services](ServiceReportCall) (request)
886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
887#[serde_with::serde_as]
888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
889pub struct ReportRequest {
890    /// Operations to be reported. Typically the service should report one operation per request. Putting multiple operations into a single request is allowed, but should be used only when multiple operations are natually available at the time of the report. There is no limit on the number of operations in the same ReportRequest, however the ReportRequest size should be no larger than 1MB. See ReportResponse.report_errors for partial failure behavior.
891    pub operations: Option<Vec<Operation>>,
892    /// Specifies which version of service config should be used to process the request. If unspecified or no matching version can be found, the latest one will be used.
893    #[serde(rename = "serviceConfigId")]
894    pub service_config_id: Option<String>,
895}
896
897impl common::RequestValue for ReportRequest {}
898
899/// Response message for the Report method.
900///
901/// # Activities
902///
903/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
904/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
905///
906/// * [report services](ServiceReportCall) (response)
907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
908#[serde_with::serde_as]
909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
910pub struct ReportResponse {
911    /// Partial failures, one for each `Operation` in the request that failed processing. There are three possible combinations of the RPC status: 1. The combination of a successful RPC status and an empty `report_errors` list indicates a complete success where all `Operations` in the request are processed successfully. 2. The combination of a successful RPC status and a non-empty `report_errors` list indicates a partial success where some `Operations` in the request succeeded. Each `Operation` that failed processing has a corresponding item in this list. 3. A failed RPC status indicates a general non-deterministic failure. When this happens, it's impossible to know which of the 'Operations' in the request succeeded or failed.
912    #[serde(rename = "reportErrors")]
913    pub report_errors: Option<Vec<ReportError>>,
914    /// The actual config id used to process the request.
915    #[serde(rename = "serviceConfigId")]
916    pub service_config_id: Option<String>,
917    /// The current service rollout id used to process the request.
918    #[serde(rename = "serviceRolloutId")]
919    pub service_rollout_id: Option<String>,
920}
921
922impl common::ResponseResult for ReportResponse {}
923
924/// Describes a resource associated with this operation.
925///
926/// This type is not used in any activity, and only used as *part* of another schema.
927///
928#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
929#[serde_with::serde_as]
930#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
931pub struct ResourceInfo {
932    /// The resource permission required for this request.
933    pub permission: Option<String>,
934    /// The identifier of the parent of this resource instance. Must be in one of the following formats: - `projects/` - `folders/` - `organizations/`
935    #[serde(rename = "resourceContainer")]
936    pub resource_container: Option<String>,
937    /// The location of the resource. If not empty, the resource will be checked against location policy. The value must be a valid zone, region or multiregion. For example: "europe-west4" or "northamerica-northeast1-a"
938    #[serde(rename = "resourceLocation")]
939    pub resource_location: Option<String>,
940    /// Name of the resource. This is used for auditing purposes.
941    #[serde(rename = "resourceName")]
942    pub resource_name: Option<String>,
943}
944
945impl common::Part for ResourceInfo {}
946
947/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
948///
949/// This type is not used in any activity, and only used as *part* of another schema.
950///
951#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
952#[serde_with::serde_as]
953#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
954pub struct Status {
955    /// The status code, which should be an enum value of google.rpc.Code.
956    pub code: Option<i32>,
957    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
958    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
959    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
960    pub message: Option<String>,
961}
962
963impl common::Part for Status {}
964
965/// A span represents a single operation within a trace. Spans can be nested to form a trace tree. Often, a trace contains a root span that describes the end-to-end latency, and one or more subspans for its sub-operations. A trace can also contain multiple root spans, or none at all. Spans do not need to be contiguous—there may be gaps or overlaps between spans in a trace.
966///
967/// This type is not used in any activity, and only used as *part* of another schema.
968///
969#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
970#[serde_with::serde_as]
971#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
972pub struct TraceSpan {
973    /// A set of attributes on the span. You can have up to 32 attributes per span.
974    pub attributes: Option<Attributes>,
975    /// An optional number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans.
976    #[serde(rename = "childSpanCount")]
977    pub child_span_count: Option<i32>,
978    /// A description of the span's operation (up to 128 bytes). Stackdriver Trace displays the description in the Google Cloud Platform Console. For example, the display name can be a qualified method name or a file name and a line number where the operation is called. A best practice is to use the same display name within an application and at the same call point. This makes it easier to correlate spans in different traces.
979    #[serde(rename = "displayName")]
980    pub display_name: Option<TruncatableString>,
981    /// The end time of the span. On the client side, this is the time kept by the local machine where the span execution ends. On the server side, this is the time when the server application handler stops running.
982    #[serde(rename = "endTime")]
983    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
984    /// The resource name of the span in the following format: projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/SPAN_ID is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. [SPAN_ID] is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array.
985    pub name: Option<String>,
986    /// The [SPAN_ID] of this span's parent span. If this is a root span, then this field must be empty.
987    #[serde(rename = "parentSpanId")]
988    pub parent_span_id: Option<String>,
989    /// (Optional) Set this parameter to indicate whether this span is in the same process as its parent. If you do not set this parameter, Stackdriver Trace is unable to take advantage of this helpful information.
990    #[serde(rename = "sameProcessAsParentSpan")]
991    pub same_process_as_parent_span: Option<bool>,
992    /// The [SPAN_ID] portion of the span's resource name.
993    #[serde(rename = "spanId")]
994    pub span_id: Option<String>,
995    /// Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call.
996    #[serde(rename = "spanKind")]
997    pub span_kind: Option<String>,
998    /// The start time of the span. On the client side, this is the time kept by the local machine where the span execution starts. On the server side, this is the time when the server's application handler starts running.
999    #[serde(rename = "startTime")]
1000    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1001    /// An optional final status for this span.
1002    pub status: Option<Status>,
1003}
1004
1005impl common::Part for TraceSpan {}
1006
1007/// Represents a string that might be shortened to a specified length.
1008///
1009/// This type is not used in any activity, and only used as *part* of another schema.
1010///
1011#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1012#[serde_with::serde_as]
1013#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1014pub struct TruncatableString {
1015    /// The number of bytes removed from the original string. If this value is 0, then the string was not shortened.
1016    #[serde(rename = "truncatedByteCount")]
1017    pub truncated_byte_count: Option<i32>,
1018    /// The shortened string. For example, if the original string is 500 bytes long and the limit of the string is 128 bytes, then `value` contains the first 128 bytes of the 500-byte string. Truncation always happens on a UTF8 character boundary. If there are multi-byte characters in the string, then the length of the shortened string might be less than the size limit.
1019    pub value: Option<String>,
1020}
1021
1022impl common::Part for TruncatableString {}
1023
1024// ###################
1025// MethodBuilders ###
1026// #################
1027
1028/// A builder providing access to all methods supported on *service* resources.
1029/// It is not used directly, but through the [`ServiceControl`] hub.
1030///
1031/// # Example
1032///
1033/// Instantiate a resource builder
1034///
1035/// ```test_harness,no_run
1036/// extern crate hyper;
1037/// extern crate hyper_rustls;
1038/// extern crate google_servicecontrol1 as servicecontrol1;
1039///
1040/// # async fn dox() {
1041/// use servicecontrol1::{ServiceControl, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1042///
1043/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1044/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1045///     secret,
1046///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1047/// ).build().await.unwrap();
1048///
1049/// let client = hyper_util::client::legacy::Client::builder(
1050///     hyper_util::rt::TokioExecutor::new()
1051/// )
1052/// .build(
1053///     hyper_rustls::HttpsConnectorBuilder::new()
1054///         .with_native_roots()
1055///         .unwrap()
1056///         .https_or_http()
1057///         .enable_http1()
1058///         .build()
1059/// );
1060/// let mut hub = ServiceControl::new(client, auth);
1061/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1062/// // like `allocate_quota(...)`, `check(...)` and `report(...)`
1063/// // to build up your call.
1064/// let rb = hub.services();
1065/// # }
1066/// ```
1067pub struct ServiceMethods<'a, C>
1068where
1069    C: 'a,
1070{
1071    hub: &'a ServiceControl<C>,
1072}
1073
1074impl<'a, C> common::MethodsBuilder for ServiceMethods<'a, C> {}
1075
1076impl<'a, C> ServiceMethods<'a, C> {
1077    /// Create a builder to help you perform the following task:
1078    ///
1079    /// Attempts to allocate quota for the specified consumer. It should be called before the operation is executed. This method requires the `servicemanagement.services.quota` permission on the specified service. For more information, see [Cloud IAM](https://cloud.google.com/iam). **NOTE:** The client **must** fail-open on server errors `INTERNAL`, `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system reliability, the server may inject these errors to prohibit any hard dependency on the quota functionality.
1080    ///
1081    /// # Arguments
1082    ///
1083    /// * `request` - No description provided.
1084    /// * `serviceName` - Name of the service as specified in the service configuration. For example, `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service name.
1085    pub fn allocate_quota(
1086        &self,
1087        request: AllocateQuotaRequest,
1088        service_name: &str,
1089    ) -> ServiceAllocateQuotaCall<'a, C> {
1090        ServiceAllocateQuotaCall {
1091            hub: self.hub,
1092            _request: request,
1093            _service_name: service_name.to_string(),
1094            _delegate: Default::default(),
1095            _additional_params: Default::default(),
1096            _scopes: Default::default(),
1097        }
1098    }
1099
1100    /// Create a builder to help you perform the following task:
1101    ///
1102    /// Checks whether an operation on a service should be allowed to proceed based on the configuration of the service and related policies. It must be called before the operation is executed. If feasible, the client should cache the check results and reuse them for 60 seconds. In case of any server errors, the client should rely on the cached results for much longer time to avoid outage. WARNING: There is general 60s delay for the configuration and policy propagation, therefore callers MUST NOT depend on the `Check` method having the latest policy information. NOTE: the CheckRequest has the size limit (wire-format byte size) of 1MB. This method requires the `servicemanagement.services.check` permission on the specified service. For more information, see [Cloud IAM](https://cloud.google.com/iam).
1103    ///
1104    /// # Arguments
1105    ///
1106    /// * `request` - No description provided.
1107    /// * `serviceName` - The service name as specified in its service configuration. For example, `"pubsub.googleapis.com"`. See [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) for the definition of a service name.
1108    pub fn check(&self, request: CheckRequest, service_name: &str) -> ServiceCheckCall<'a, C> {
1109        ServiceCheckCall {
1110            hub: self.hub,
1111            _request: request,
1112            _service_name: service_name.to_string(),
1113            _delegate: Default::default(),
1114            _additional_params: Default::default(),
1115            _scopes: Default::default(),
1116        }
1117    }
1118
1119    /// Create a builder to help you perform the following task:
1120    ///
1121    /// Reports operation results to Google Service Control, such as logs and metrics. It should be called after an operation is completed. If feasible, the client should aggregate reporting data for up to 5 seconds to reduce API traffic. Limiting aggregation to 5 seconds is to reduce data loss during client crashes. Clients should carefully choose the aggregation time window to avoid data loss risk more than 0.01% for business and compliance reasons. NOTE: the ReportRequest has the size limit (wire-format byte size) of 1MB. This method requires the `servicemanagement.services.report` permission on the specified service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
1122    ///
1123    /// # Arguments
1124    ///
1125    /// * `request` - No description provided.
1126    /// * `serviceName` - The service name as specified in its service configuration. For example, `"pubsub.googleapis.com"`. See [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) for the definition of a service name.
1127    pub fn report(&self, request: ReportRequest, service_name: &str) -> ServiceReportCall<'a, C> {
1128        ServiceReportCall {
1129            hub: self.hub,
1130            _request: request,
1131            _service_name: service_name.to_string(),
1132            _delegate: Default::default(),
1133            _additional_params: Default::default(),
1134            _scopes: Default::default(),
1135        }
1136    }
1137}
1138
1139// ###################
1140// CallBuilders   ###
1141// #################
1142
1143/// Attempts to allocate quota for the specified consumer. It should be called before the operation is executed. This method requires the `servicemanagement.services.quota` permission on the specified service. For more information, see [Cloud IAM](https://cloud.google.com/iam). **NOTE:** The client **must** fail-open on server errors `INTERNAL`, `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system reliability, the server may inject these errors to prohibit any hard dependency on the quota functionality.
1144///
1145/// A builder for the *allocateQuota* method supported by a *service* resource.
1146/// It is not used directly, but through a [`ServiceMethods`] instance.
1147///
1148/// # Example
1149///
1150/// Instantiate a resource method builder
1151///
1152/// ```test_harness,no_run
1153/// # extern crate hyper;
1154/// # extern crate hyper_rustls;
1155/// # extern crate google_servicecontrol1 as servicecontrol1;
1156/// use servicecontrol1::api::AllocateQuotaRequest;
1157/// # async fn dox() {
1158/// # use servicecontrol1::{ServiceControl, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1159///
1160/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1161/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1162/// #     secret,
1163/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1164/// # ).build().await.unwrap();
1165///
1166/// # let client = hyper_util::client::legacy::Client::builder(
1167/// #     hyper_util::rt::TokioExecutor::new()
1168/// # )
1169/// # .build(
1170/// #     hyper_rustls::HttpsConnectorBuilder::new()
1171/// #         .with_native_roots()
1172/// #         .unwrap()
1173/// #         .https_or_http()
1174/// #         .enable_http1()
1175/// #         .build()
1176/// # );
1177/// # let mut hub = ServiceControl::new(client, auth);
1178/// // As the method needs a request, you would usually fill it with the desired information
1179/// // into the respective structure. Some of the parts shown here might not be applicable !
1180/// // Values shown here are possibly random and not representative !
1181/// let mut req = AllocateQuotaRequest::default();
1182///
1183/// // You can configure optional parameters by calling the respective setters at will, and
1184/// // execute the final call using `doit()`.
1185/// // Values shown here are possibly random and not representative !
1186/// let result = hub.services().allocate_quota(req, "serviceName")
1187///              .doit().await;
1188/// # }
1189/// ```
1190pub struct ServiceAllocateQuotaCall<'a, C>
1191where
1192    C: 'a,
1193{
1194    hub: &'a ServiceControl<C>,
1195    _request: AllocateQuotaRequest,
1196    _service_name: String,
1197    _delegate: Option<&'a mut dyn common::Delegate>,
1198    _additional_params: HashMap<String, String>,
1199    _scopes: BTreeSet<String>,
1200}
1201
1202impl<'a, C> common::CallBuilder for ServiceAllocateQuotaCall<'a, C> {}
1203
1204impl<'a, C> ServiceAllocateQuotaCall<'a, C>
1205where
1206    C: common::Connector,
1207{
1208    /// Perform the operation you have build so far.
1209    pub async fn doit(mut self) -> common::Result<(common::Response, AllocateQuotaResponse)> {
1210        use std::borrow::Cow;
1211        use std::io::{Read, Seek};
1212
1213        use common::{url::Params, ToParts};
1214        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1215
1216        let mut dd = common::DefaultDelegate;
1217        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1218        dlg.begin(common::MethodInfo {
1219            id: "servicecontrol.services.allocateQuota",
1220            http_method: hyper::Method::POST,
1221        });
1222
1223        for &field in ["alt", "serviceName"].iter() {
1224            if self._additional_params.contains_key(field) {
1225                dlg.finished(false);
1226                return Err(common::Error::FieldClash(field));
1227            }
1228        }
1229
1230        let mut params = Params::with_capacity(4 + self._additional_params.len());
1231        params.push("serviceName", self._service_name);
1232
1233        params.extend(self._additional_params.iter());
1234
1235        params.push("alt", "json");
1236        let mut url = self.hub._base_url.clone() + "v1/services/{serviceName}:allocateQuota";
1237        if self._scopes.is_empty() {
1238            self._scopes
1239                .insert(Scope::CloudPlatform.as_ref().to_string());
1240        }
1241
1242        #[allow(clippy::single_element_loop)]
1243        for &(find_this, param_name) in [("{serviceName}", "serviceName")].iter() {
1244            url = params.uri_replacement(url, param_name, find_this, false);
1245        }
1246        {
1247            let to_remove = ["serviceName"];
1248            params.remove_params(&to_remove);
1249        }
1250
1251        let url = params.parse_with_url(&url);
1252
1253        let mut json_mime_type = mime::APPLICATION_JSON;
1254        let mut request_value_reader = {
1255            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1256            common::remove_json_null_values(&mut value);
1257            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1258            serde_json::to_writer(&mut dst, &value).unwrap();
1259            dst
1260        };
1261        let request_size = request_value_reader
1262            .seek(std::io::SeekFrom::End(0))
1263            .unwrap();
1264        request_value_reader
1265            .seek(std::io::SeekFrom::Start(0))
1266            .unwrap();
1267
1268        loop {
1269            let token = match self
1270                .hub
1271                .auth
1272                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1273                .await
1274            {
1275                Ok(token) => token,
1276                Err(e) => match dlg.token(e) {
1277                    Ok(token) => token,
1278                    Err(e) => {
1279                        dlg.finished(false);
1280                        return Err(common::Error::MissingToken(e));
1281                    }
1282                },
1283            };
1284            request_value_reader
1285                .seek(std::io::SeekFrom::Start(0))
1286                .unwrap();
1287            let mut req_result = {
1288                let client = &self.hub.client;
1289                dlg.pre_request();
1290                let mut req_builder = hyper::Request::builder()
1291                    .method(hyper::Method::POST)
1292                    .uri(url.as_str())
1293                    .header(USER_AGENT, self.hub._user_agent.clone());
1294
1295                if let Some(token) = token.as_ref() {
1296                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1297                }
1298
1299                let request = req_builder
1300                    .header(CONTENT_TYPE, json_mime_type.to_string())
1301                    .header(CONTENT_LENGTH, request_size as u64)
1302                    .body(common::to_body(
1303                        request_value_reader.get_ref().clone().into(),
1304                    ));
1305
1306                client.request(request.unwrap()).await
1307            };
1308
1309            match req_result {
1310                Err(err) => {
1311                    if let common::Retry::After(d) = dlg.http_error(&err) {
1312                        sleep(d).await;
1313                        continue;
1314                    }
1315                    dlg.finished(false);
1316                    return Err(common::Error::HttpError(err));
1317                }
1318                Ok(res) => {
1319                    let (mut parts, body) = res.into_parts();
1320                    let mut body = common::Body::new(body);
1321                    if !parts.status.is_success() {
1322                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1323                        let error = serde_json::from_str(&common::to_string(&bytes));
1324                        let response = common::to_response(parts, bytes.into());
1325
1326                        if let common::Retry::After(d) =
1327                            dlg.http_failure(&response, error.as_ref().ok())
1328                        {
1329                            sleep(d).await;
1330                            continue;
1331                        }
1332
1333                        dlg.finished(false);
1334
1335                        return Err(match error {
1336                            Ok(value) => common::Error::BadRequest(value),
1337                            _ => common::Error::Failure(response),
1338                        });
1339                    }
1340                    let response = {
1341                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1342                        let encoded = common::to_string(&bytes);
1343                        match serde_json::from_str(&encoded) {
1344                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1345                            Err(error) => {
1346                                dlg.response_json_decode_error(&encoded, &error);
1347                                return Err(common::Error::JsonDecodeError(
1348                                    encoded.to_string(),
1349                                    error,
1350                                ));
1351                            }
1352                        }
1353                    };
1354
1355                    dlg.finished(true);
1356                    return Ok(response);
1357                }
1358            }
1359        }
1360    }
1361
1362    ///
1363    /// Sets the *request* property to the given value.
1364    ///
1365    /// Even though the property as already been set when instantiating this call,
1366    /// we provide this method for API completeness.
1367    pub fn request(mut self, new_value: AllocateQuotaRequest) -> ServiceAllocateQuotaCall<'a, C> {
1368        self._request = new_value;
1369        self
1370    }
1371    /// Name of the service as specified in the service configuration. For example, `"pubsub.googleapis.com"`. See google.api.Service for the definition of a service name.
1372    ///
1373    /// Sets the *service name* path property to the given value.
1374    ///
1375    /// Even though the property as already been set when instantiating this call,
1376    /// we provide this method for API completeness.
1377    pub fn service_name(mut self, new_value: &str) -> ServiceAllocateQuotaCall<'a, C> {
1378        self._service_name = new_value.to_string();
1379        self
1380    }
1381    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1382    /// while executing the actual API request.
1383    ///
1384    /// ````text
1385    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1386    /// ````
1387    ///
1388    /// Sets the *delegate* property to the given value.
1389    pub fn delegate(
1390        mut self,
1391        new_value: &'a mut dyn common::Delegate,
1392    ) -> ServiceAllocateQuotaCall<'a, C> {
1393        self._delegate = Some(new_value);
1394        self
1395    }
1396
1397    /// Set any additional parameter of the query string used in the request.
1398    /// It should be used to set parameters which are not yet available through their own
1399    /// setters.
1400    ///
1401    /// Please note that this method must not be used to set any of the known parameters
1402    /// which have their own setter method. If done anyway, the request will fail.
1403    ///
1404    /// # Additional Parameters
1405    ///
1406    /// * *$.xgafv* (query-string) - V1 error format.
1407    /// * *access_token* (query-string) - OAuth access token.
1408    /// * *alt* (query-string) - Data format for response.
1409    /// * *callback* (query-string) - JSONP
1410    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1411    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1412    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1413    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1414    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1415    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1416    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1417    pub fn param<T>(mut self, name: T, value: T) -> ServiceAllocateQuotaCall<'a, C>
1418    where
1419        T: AsRef<str>,
1420    {
1421        self._additional_params
1422            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1423        self
1424    }
1425
1426    /// Identifies the authorization scope for the method you are building.
1427    ///
1428    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1429    /// [`Scope::CloudPlatform`].
1430    ///
1431    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1432    /// tokens for more than one scope.
1433    ///
1434    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1435    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1436    /// sufficient, a read-write scope will do as well.
1437    pub fn add_scope<St>(mut self, scope: St) -> ServiceAllocateQuotaCall<'a, C>
1438    where
1439        St: AsRef<str>,
1440    {
1441        self._scopes.insert(String::from(scope.as_ref()));
1442        self
1443    }
1444    /// Identifies the authorization scope(s) for the method you are building.
1445    ///
1446    /// See [`Self::add_scope()`] for details.
1447    pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceAllocateQuotaCall<'a, C>
1448    where
1449        I: IntoIterator<Item = St>,
1450        St: AsRef<str>,
1451    {
1452        self._scopes
1453            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1454        self
1455    }
1456
1457    /// Removes all scopes, and no default scope will be used either.
1458    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1459    /// for details).
1460    pub fn clear_scopes(mut self) -> ServiceAllocateQuotaCall<'a, C> {
1461        self._scopes.clear();
1462        self
1463    }
1464}
1465
1466/// Checks whether an operation on a service should be allowed to proceed based on the configuration of the service and related policies. It must be called before the operation is executed. If feasible, the client should cache the check results and reuse them for 60 seconds. In case of any server errors, the client should rely on the cached results for much longer time to avoid outage. WARNING: There is general 60s delay for the configuration and policy propagation, therefore callers MUST NOT depend on the `Check` method having the latest policy information. NOTE: the CheckRequest has the size limit (wire-format byte size) of 1MB. This method requires the `servicemanagement.services.check` permission on the specified service. For more information, see [Cloud IAM](https://cloud.google.com/iam).
1467///
1468/// A builder for the *check* method supported by a *service* resource.
1469/// It is not used directly, but through a [`ServiceMethods`] instance.
1470///
1471/// # Example
1472///
1473/// Instantiate a resource method builder
1474///
1475/// ```test_harness,no_run
1476/// # extern crate hyper;
1477/// # extern crate hyper_rustls;
1478/// # extern crate google_servicecontrol1 as servicecontrol1;
1479/// use servicecontrol1::api::CheckRequest;
1480/// # async fn dox() {
1481/// # use servicecontrol1::{ServiceControl, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1482///
1483/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1484/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1485/// #     secret,
1486/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1487/// # ).build().await.unwrap();
1488///
1489/// # let client = hyper_util::client::legacy::Client::builder(
1490/// #     hyper_util::rt::TokioExecutor::new()
1491/// # )
1492/// # .build(
1493/// #     hyper_rustls::HttpsConnectorBuilder::new()
1494/// #         .with_native_roots()
1495/// #         .unwrap()
1496/// #         .https_or_http()
1497/// #         .enable_http1()
1498/// #         .build()
1499/// # );
1500/// # let mut hub = ServiceControl::new(client, auth);
1501/// // As the method needs a request, you would usually fill it with the desired information
1502/// // into the respective structure. Some of the parts shown here might not be applicable !
1503/// // Values shown here are possibly random and not representative !
1504/// let mut req = CheckRequest::default();
1505///
1506/// // You can configure optional parameters by calling the respective setters at will, and
1507/// // execute the final call using `doit()`.
1508/// // Values shown here are possibly random and not representative !
1509/// let result = hub.services().check(req, "serviceName")
1510///              .doit().await;
1511/// # }
1512/// ```
1513pub struct ServiceCheckCall<'a, C>
1514where
1515    C: 'a,
1516{
1517    hub: &'a ServiceControl<C>,
1518    _request: CheckRequest,
1519    _service_name: String,
1520    _delegate: Option<&'a mut dyn common::Delegate>,
1521    _additional_params: HashMap<String, String>,
1522    _scopes: BTreeSet<String>,
1523}
1524
1525impl<'a, C> common::CallBuilder for ServiceCheckCall<'a, C> {}
1526
1527impl<'a, C> ServiceCheckCall<'a, C>
1528where
1529    C: common::Connector,
1530{
1531    /// Perform the operation you have build so far.
1532    pub async fn doit(mut self) -> common::Result<(common::Response, CheckResponse)> {
1533        use std::borrow::Cow;
1534        use std::io::{Read, Seek};
1535
1536        use common::{url::Params, ToParts};
1537        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1538
1539        let mut dd = common::DefaultDelegate;
1540        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1541        dlg.begin(common::MethodInfo {
1542            id: "servicecontrol.services.check",
1543            http_method: hyper::Method::POST,
1544        });
1545
1546        for &field in ["alt", "serviceName"].iter() {
1547            if self._additional_params.contains_key(field) {
1548                dlg.finished(false);
1549                return Err(common::Error::FieldClash(field));
1550            }
1551        }
1552
1553        let mut params = Params::with_capacity(4 + self._additional_params.len());
1554        params.push("serviceName", self._service_name);
1555
1556        params.extend(self._additional_params.iter());
1557
1558        params.push("alt", "json");
1559        let mut url = self.hub._base_url.clone() + "v1/services/{serviceName}:check";
1560        if self._scopes.is_empty() {
1561            self._scopes
1562                .insert(Scope::CloudPlatform.as_ref().to_string());
1563        }
1564
1565        #[allow(clippy::single_element_loop)]
1566        for &(find_this, param_name) in [("{serviceName}", "serviceName")].iter() {
1567            url = params.uri_replacement(url, param_name, find_this, false);
1568        }
1569        {
1570            let to_remove = ["serviceName"];
1571            params.remove_params(&to_remove);
1572        }
1573
1574        let url = params.parse_with_url(&url);
1575
1576        let mut json_mime_type = mime::APPLICATION_JSON;
1577        let mut request_value_reader = {
1578            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1579            common::remove_json_null_values(&mut value);
1580            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1581            serde_json::to_writer(&mut dst, &value).unwrap();
1582            dst
1583        };
1584        let request_size = request_value_reader
1585            .seek(std::io::SeekFrom::End(0))
1586            .unwrap();
1587        request_value_reader
1588            .seek(std::io::SeekFrom::Start(0))
1589            .unwrap();
1590
1591        loop {
1592            let token = match self
1593                .hub
1594                .auth
1595                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1596                .await
1597            {
1598                Ok(token) => token,
1599                Err(e) => match dlg.token(e) {
1600                    Ok(token) => token,
1601                    Err(e) => {
1602                        dlg.finished(false);
1603                        return Err(common::Error::MissingToken(e));
1604                    }
1605                },
1606            };
1607            request_value_reader
1608                .seek(std::io::SeekFrom::Start(0))
1609                .unwrap();
1610            let mut req_result = {
1611                let client = &self.hub.client;
1612                dlg.pre_request();
1613                let mut req_builder = hyper::Request::builder()
1614                    .method(hyper::Method::POST)
1615                    .uri(url.as_str())
1616                    .header(USER_AGENT, self.hub._user_agent.clone());
1617
1618                if let Some(token) = token.as_ref() {
1619                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1620                }
1621
1622                let request = req_builder
1623                    .header(CONTENT_TYPE, json_mime_type.to_string())
1624                    .header(CONTENT_LENGTH, request_size as u64)
1625                    .body(common::to_body(
1626                        request_value_reader.get_ref().clone().into(),
1627                    ));
1628
1629                client.request(request.unwrap()).await
1630            };
1631
1632            match req_result {
1633                Err(err) => {
1634                    if let common::Retry::After(d) = dlg.http_error(&err) {
1635                        sleep(d).await;
1636                        continue;
1637                    }
1638                    dlg.finished(false);
1639                    return Err(common::Error::HttpError(err));
1640                }
1641                Ok(res) => {
1642                    let (mut parts, body) = res.into_parts();
1643                    let mut body = common::Body::new(body);
1644                    if !parts.status.is_success() {
1645                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1646                        let error = serde_json::from_str(&common::to_string(&bytes));
1647                        let response = common::to_response(parts, bytes.into());
1648
1649                        if let common::Retry::After(d) =
1650                            dlg.http_failure(&response, error.as_ref().ok())
1651                        {
1652                            sleep(d).await;
1653                            continue;
1654                        }
1655
1656                        dlg.finished(false);
1657
1658                        return Err(match error {
1659                            Ok(value) => common::Error::BadRequest(value),
1660                            _ => common::Error::Failure(response),
1661                        });
1662                    }
1663                    let response = {
1664                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1665                        let encoded = common::to_string(&bytes);
1666                        match serde_json::from_str(&encoded) {
1667                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1668                            Err(error) => {
1669                                dlg.response_json_decode_error(&encoded, &error);
1670                                return Err(common::Error::JsonDecodeError(
1671                                    encoded.to_string(),
1672                                    error,
1673                                ));
1674                            }
1675                        }
1676                    };
1677
1678                    dlg.finished(true);
1679                    return Ok(response);
1680                }
1681            }
1682        }
1683    }
1684
1685    ///
1686    /// Sets the *request* property to the given value.
1687    ///
1688    /// Even though the property as already been set when instantiating this call,
1689    /// we provide this method for API completeness.
1690    pub fn request(mut self, new_value: CheckRequest) -> ServiceCheckCall<'a, C> {
1691        self._request = new_value;
1692        self
1693    }
1694    /// The service name as specified in its service configuration. For example, `"pubsub.googleapis.com"`. See [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) for the definition of a service name.
1695    ///
1696    /// Sets the *service name* path property to the given value.
1697    ///
1698    /// Even though the property as already been set when instantiating this call,
1699    /// we provide this method for API completeness.
1700    pub fn service_name(mut self, new_value: &str) -> ServiceCheckCall<'a, C> {
1701        self._service_name = new_value.to_string();
1702        self
1703    }
1704    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1705    /// while executing the actual API request.
1706    ///
1707    /// ````text
1708    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1709    /// ````
1710    ///
1711    /// Sets the *delegate* property to the given value.
1712    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceCheckCall<'a, C> {
1713        self._delegate = Some(new_value);
1714        self
1715    }
1716
1717    /// Set any additional parameter of the query string used in the request.
1718    /// It should be used to set parameters which are not yet available through their own
1719    /// setters.
1720    ///
1721    /// Please note that this method must not be used to set any of the known parameters
1722    /// which have their own setter method. If done anyway, the request will fail.
1723    ///
1724    /// # Additional Parameters
1725    ///
1726    /// * *$.xgafv* (query-string) - V1 error format.
1727    /// * *access_token* (query-string) - OAuth access token.
1728    /// * *alt* (query-string) - Data format for response.
1729    /// * *callback* (query-string) - JSONP
1730    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1731    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1732    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1733    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1734    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1735    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1736    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1737    pub fn param<T>(mut self, name: T, value: T) -> ServiceCheckCall<'a, C>
1738    where
1739        T: AsRef<str>,
1740    {
1741        self._additional_params
1742            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1743        self
1744    }
1745
1746    /// Identifies the authorization scope for the method you are building.
1747    ///
1748    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1749    /// [`Scope::CloudPlatform`].
1750    ///
1751    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1752    /// tokens for more than one scope.
1753    ///
1754    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1755    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1756    /// sufficient, a read-write scope will do as well.
1757    pub fn add_scope<St>(mut self, scope: St) -> ServiceCheckCall<'a, C>
1758    where
1759        St: AsRef<str>,
1760    {
1761        self._scopes.insert(String::from(scope.as_ref()));
1762        self
1763    }
1764    /// Identifies the authorization scope(s) for the method you are building.
1765    ///
1766    /// See [`Self::add_scope()`] for details.
1767    pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceCheckCall<'a, C>
1768    where
1769        I: IntoIterator<Item = St>,
1770        St: AsRef<str>,
1771    {
1772        self._scopes
1773            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1774        self
1775    }
1776
1777    /// Removes all scopes, and no default scope will be used either.
1778    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1779    /// for details).
1780    pub fn clear_scopes(mut self) -> ServiceCheckCall<'a, C> {
1781        self._scopes.clear();
1782        self
1783    }
1784}
1785
1786/// Reports operation results to Google Service Control, such as logs and metrics. It should be called after an operation is completed. If feasible, the client should aggregate reporting data for up to 5 seconds to reduce API traffic. Limiting aggregation to 5 seconds is to reduce data loss during client crashes. Clients should carefully choose the aggregation time window to avoid data loss risk more than 0.01% for business and compliance reasons. NOTE: the ReportRequest has the size limit (wire-format byte size) of 1MB. This method requires the `servicemanagement.services.report` permission on the specified service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
1787///
1788/// A builder for the *report* method supported by a *service* resource.
1789/// It is not used directly, but through a [`ServiceMethods`] instance.
1790///
1791/// # Example
1792///
1793/// Instantiate a resource method builder
1794///
1795/// ```test_harness,no_run
1796/// # extern crate hyper;
1797/// # extern crate hyper_rustls;
1798/// # extern crate google_servicecontrol1 as servicecontrol1;
1799/// use servicecontrol1::api::ReportRequest;
1800/// # async fn dox() {
1801/// # use servicecontrol1::{ServiceControl, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1802///
1803/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1805/// #     secret,
1806/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1807/// # ).build().await.unwrap();
1808///
1809/// # let client = hyper_util::client::legacy::Client::builder(
1810/// #     hyper_util::rt::TokioExecutor::new()
1811/// # )
1812/// # .build(
1813/// #     hyper_rustls::HttpsConnectorBuilder::new()
1814/// #         .with_native_roots()
1815/// #         .unwrap()
1816/// #         .https_or_http()
1817/// #         .enable_http1()
1818/// #         .build()
1819/// # );
1820/// # let mut hub = ServiceControl::new(client, auth);
1821/// // As the method needs a request, you would usually fill it with the desired information
1822/// // into the respective structure. Some of the parts shown here might not be applicable !
1823/// // Values shown here are possibly random and not representative !
1824/// let mut req = ReportRequest::default();
1825///
1826/// // You can configure optional parameters by calling the respective setters at will, and
1827/// // execute the final call using `doit()`.
1828/// // Values shown here are possibly random and not representative !
1829/// let result = hub.services().report(req, "serviceName")
1830///              .doit().await;
1831/// # }
1832/// ```
1833pub struct ServiceReportCall<'a, C>
1834where
1835    C: 'a,
1836{
1837    hub: &'a ServiceControl<C>,
1838    _request: ReportRequest,
1839    _service_name: String,
1840    _delegate: Option<&'a mut dyn common::Delegate>,
1841    _additional_params: HashMap<String, String>,
1842    _scopes: BTreeSet<String>,
1843}
1844
1845impl<'a, C> common::CallBuilder for ServiceReportCall<'a, C> {}
1846
1847impl<'a, C> ServiceReportCall<'a, C>
1848where
1849    C: common::Connector,
1850{
1851    /// Perform the operation you have build so far.
1852    pub async fn doit(mut self) -> common::Result<(common::Response, ReportResponse)> {
1853        use std::borrow::Cow;
1854        use std::io::{Read, Seek};
1855
1856        use common::{url::Params, ToParts};
1857        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1858
1859        let mut dd = common::DefaultDelegate;
1860        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1861        dlg.begin(common::MethodInfo {
1862            id: "servicecontrol.services.report",
1863            http_method: hyper::Method::POST,
1864        });
1865
1866        for &field in ["alt", "serviceName"].iter() {
1867            if self._additional_params.contains_key(field) {
1868                dlg.finished(false);
1869                return Err(common::Error::FieldClash(field));
1870            }
1871        }
1872
1873        let mut params = Params::with_capacity(4 + self._additional_params.len());
1874        params.push("serviceName", self._service_name);
1875
1876        params.extend(self._additional_params.iter());
1877
1878        params.push("alt", "json");
1879        let mut url = self.hub._base_url.clone() + "v1/services/{serviceName}:report";
1880        if self._scopes.is_empty() {
1881            self._scopes
1882                .insert(Scope::CloudPlatform.as_ref().to_string());
1883        }
1884
1885        #[allow(clippy::single_element_loop)]
1886        for &(find_this, param_name) in [("{serviceName}", "serviceName")].iter() {
1887            url = params.uri_replacement(url, param_name, find_this, false);
1888        }
1889        {
1890            let to_remove = ["serviceName"];
1891            params.remove_params(&to_remove);
1892        }
1893
1894        let url = params.parse_with_url(&url);
1895
1896        let mut json_mime_type = mime::APPLICATION_JSON;
1897        let mut request_value_reader = {
1898            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1899            common::remove_json_null_values(&mut value);
1900            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1901            serde_json::to_writer(&mut dst, &value).unwrap();
1902            dst
1903        };
1904        let request_size = request_value_reader
1905            .seek(std::io::SeekFrom::End(0))
1906            .unwrap();
1907        request_value_reader
1908            .seek(std::io::SeekFrom::Start(0))
1909            .unwrap();
1910
1911        loop {
1912            let token = match self
1913                .hub
1914                .auth
1915                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1916                .await
1917            {
1918                Ok(token) => token,
1919                Err(e) => match dlg.token(e) {
1920                    Ok(token) => token,
1921                    Err(e) => {
1922                        dlg.finished(false);
1923                        return Err(common::Error::MissingToken(e));
1924                    }
1925                },
1926            };
1927            request_value_reader
1928                .seek(std::io::SeekFrom::Start(0))
1929                .unwrap();
1930            let mut req_result = {
1931                let client = &self.hub.client;
1932                dlg.pre_request();
1933                let mut req_builder = hyper::Request::builder()
1934                    .method(hyper::Method::POST)
1935                    .uri(url.as_str())
1936                    .header(USER_AGENT, self.hub._user_agent.clone());
1937
1938                if let Some(token) = token.as_ref() {
1939                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1940                }
1941
1942                let request = req_builder
1943                    .header(CONTENT_TYPE, json_mime_type.to_string())
1944                    .header(CONTENT_LENGTH, request_size as u64)
1945                    .body(common::to_body(
1946                        request_value_reader.get_ref().clone().into(),
1947                    ));
1948
1949                client.request(request.unwrap()).await
1950            };
1951
1952            match req_result {
1953                Err(err) => {
1954                    if let common::Retry::After(d) = dlg.http_error(&err) {
1955                        sleep(d).await;
1956                        continue;
1957                    }
1958                    dlg.finished(false);
1959                    return Err(common::Error::HttpError(err));
1960                }
1961                Ok(res) => {
1962                    let (mut parts, body) = res.into_parts();
1963                    let mut body = common::Body::new(body);
1964                    if !parts.status.is_success() {
1965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1966                        let error = serde_json::from_str(&common::to_string(&bytes));
1967                        let response = common::to_response(parts, bytes.into());
1968
1969                        if let common::Retry::After(d) =
1970                            dlg.http_failure(&response, error.as_ref().ok())
1971                        {
1972                            sleep(d).await;
1973                            continue;
1974                        }
1975
1976                        dlg.finished(false);
1977
1978                        return Err(match error {
1979                            Ok(value) => common::Error::BadRequest(value),
1980                            _ => common::Error::Failure(response),
1981                        });
1982                    }
1983                    let response = {
1984                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1985                        let encoded = common::to_string(&bytes);
1986                        match serde_json::from_str(&encoded) {
1987                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1988                            Err(error) => {
1989                                dlg.response_json_decode_error(&encoded, &error);
1990                                return Err(common::Error::JsonDecodeError(
1991                                    encoded.to_string(),
1992                                    error,
1993                                ));
1994                            }
1995                        }
1996                    };
1997
1998                    dlg.finished(true);
1999                    return Ok(response);
2000                }
2001            }
2002        }
2003    }
2004
2005    ///
2006    /// Sets the *request* property to the given value.
2007    ///
2008    /// Even though the property as already been set when instantiating this call,
2009    /// we provide this method for API completeness.
2010    pub fn request(mut self, new_value: ReportRequest) -> ServiceReportCall<'a, C> {
2011        self._request = new_value;
2012        self
2013    }
2014    /// The service name as specified in its service configuration. For example, `"pubsub.googleapis.com"`. See [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) for the definition of a service name.
2015    ///
2016    /// Sets the *service name* path property to the given value.
2017    ///
2018    /// Even though the property as already been set when instantiating this call,
2019    /// we provide this method for API completeness.
2020    pub fn service_name(mut self, new_value: &str) -> ServiceReportCall<'a, C> {
2021        self._service_name = new_value.to_string();
2022        self
2023    }
2024    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2025    /// while executing the actual API request.
2026    ///
2027    /// ````text
2028    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2029    /// ````
2030    ///
2031    /// Sets the *delegate* property to the given value.
2032    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceReportCall<'a, C> {
2033        self._delegate = Some(new_value);
2034        self
2035    }
2036
2037    /// Set any additional parameter of the query string used in the request.
2038    /// It should be used to set parameters which are not yet available through their own
2039    /// setters.
2040    ///
2041    /// Please note that this method must not be used to set any of the known parameters
2042    /// which have their own setter method. If done anyway, the request will fail.
2043    ///
2044    /// # Additional Parameters
2045    ///
2046    /// * *$.xgafv* (query-string) - V1 error format.
2047    /// * *access_token* (query-string) - OAuth access token.
2048    /// * *alt* (query-string) - Data format for response.
2049    /// * *callback* (query-string) - JSONP
2050    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2051    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2052    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2053    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2054    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2055    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2056    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2057    pub fn param<T>(mut self, name: T, value: T) -> ServiceReportCall<'a, C>
2058    where
2059        T: AsRef<str>,
2060    {
2061        self._additional_params
2062            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2063        self
2064    }
2065
2066    /// Identifies the authorization scope for the method you are building.
2067    ///
2068    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2069    /// [`Scope::CloudPlatform`].
2070    ///
2071    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2072    /// tokens for more than one scope.
2073    ///
2074    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2075    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2076    /// sufficient, a read-write scope will do as well.
2077    pub fn add_scope<St>(mut self, scope: St) -> ServiceReportCall<'a, C>
2078    where
2079        St: AsRef<str>,
2080    {
2081        self._scopes.insert(String::from(scope.as_ref()));
2082        self
2083    }
2084    /// Identifies the authorization scope(s) for the method you are building.
2085    ///
2086    /// See [`Self::add_scope()`] for details.
2087    pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceReportCall<'a, C>
2088    where
2089        I: IntoIterator<Item = St>,
2090        St: AsRef<str>,
2091    {
2092        self._scopes
2093            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2094        self
2095    }
2096
2097    /// Removes all scopes, and no default scope will be used either.
2098    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2099    /// for details).
2100    pub fn clear_scopes(mut self) -> ServiceReportCall<'a, C> {
2101        self._scopes.clear();
2102        self
2103    }
2104}