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