google_discovery1/
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// ########
12// HUB ###
13// ######
14
15/// Central instance to access all Discovery related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_discovery1 as discovery1;
25/// use discovery1::{Result, Error};
26/// # async fn dox() {
27/// use discovery1::{Discovery, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28///
29/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
30/// // `client_secret`, among other things.
31/// let secret: yup_oauth2::ApplicationSecret = Default::default();
32/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
33/// // unless you replace  `None` with the desired Flow.
34/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
35/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
36/// // retrieve them from storage.
37/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
38///     secret,
39///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
40/// ).build().await.unwrap();
41///
42/// let client = hyper_util::client::legacy::Client::builder(
43///     hyper_util::rt::TokioExecutor::new()
44/// )
45/// .build(
46///     hyper_rustls::HttpsConnectorBuilder::new()
47///         .with_native_roots()
48///         .unwrap()
49///         .https_or_http()
50///         .enable_http1()
51///         .build()
52/// );
53/// let mut hub = Discovery::new(client, auth);
54/// // You can configure optional parameters by calling the respective setters at will, and
55/// // execute the final call using `doit()`.
56/// // Values shown here are possibly random and not representative !
57/// let result = hub.apis().get_rest("api", "version")
58///              .doit().await;
59///
60/// match result {
61///     Err(e) => match e {
62///         // The Error enum provides details about what exactly happened.
63///         // You can also just use its `Debug`, `Display` or `Error` traits
64///          Error::HttpError(_)
65///         |Error::Io(_)
66///         |Error::MissingAPIKey
67///         |Error::MissingToken(_)
68///         |Error::Cancelled
69///         |Error::UploadSizeLimitExceeded(_, _)
70///         |Error::Failure(_)
71///         |Error::BadRequest(_)
72///         |Error::FieldClash(_)
73///         |Error::JsonDecodeError(_, _) => println!("{}", e),
74///     },
75///     Ok(res) => println!("Success: {:?}", res),
76/// }
77/// # }
78/// ```
79#[derive(Clone)]
80pub struct Discovery<C> {
81    pub client: common::Client<C>,
82    pub auth: Box<dyn common::GetToken>,
83    _user_agent: String,
84    _base_url: String,
85    _root_url: String,
86}
87
88impl<C> common::Hub for Discovery<C> {}
89
90impl<'a, C> Discovery<C> {
91    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Discovery<C> {
92        Discovery {
93            client,
94            auth: Box::new(auth),
95            _user_agent: "google-api-rust-client/6.0.0".to_string(),
96            _base_url: "https://www.googleapis.com/discovery/v1/".to_string(),
97            _root_url: "https://www.googleapis.com/".to_string(),
98        }
99    }
100
101    pub fn apis(&'a self) -> ApiMethods<'a, C> {
102        ApiMethods { hub: self }
103    }
104
105    /// Set the user-agent header field to use in all requests to the server.
106    /// It defaults to `google-api-rust-client/6.0.0`.
107    ///
108    /// Returns the previously set user-agent.
109    pub fn user_agent(&mut self, agent_name: String) -> String {
110        std::mem::replace(&mut self._user_agent, agent_name)
111    }
112
113    /// Set the base url to use in all requests to the server.
114    /// It defaults to `https://www.googleapis.com/discovery/v1/`.
115    ///
116    /// Returns the previously set base url.
117    pub fn base_url(&mut self, new_base_url: String) -> String {
118        std::mem::replace(&mut self._base_url, new_base_url)
119    }
120
121    /// Set the root url to use in all requests to the server.
122    /// It defaults to `https://www.googleapis.com/`.
123    ///
124    /// Returns the previously set root url.
125    pub fn root_url(&mut self, new_root_url: String) -> String {
126        std::mem::replace(&mut self._root_url, new_root_url)
127    }
128}
129
130// ############
131// SCHEMAS ###
132// ##########
133/// There is no detailed description.
134///
135/// # Activities
136///
137/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
138/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
139///
140/// * [list apis](ApiListCall) (response)
141#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
142#[serde_with::serde_as]
143#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
144pub struct DirectoryList {
145    /// Indicate the version of the Discovery API used to generate this doc.
146    #[serde(rename = "discoveryVersion")]
147    pub discovery_version: Option<String>,
148    /// The individual directory entries. One entry per api/version pair.
149    pub items: Option<Vec<DirectoryListItems>>,
150    /// The kind for this response.
151    pub kind: Option<String>,
152}
153
154impl common::ResponseResult for DirectoryList {}
155
156/// There is no detailed description.
157///
158/// This type is not used in any activity, and only used as *part* of another schema.
159///
160#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
161#[serde_with::serde_as]
162#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
163pub struct JsonSchema {
164    /// A reference to another schema. The value of this property is the "id" of another schema.
165    #[serde(rename = "$ref")]
166    pub ref_: Option<String>,
167    /// If this is a schema for an object, this property is the schema for any additional properties with dynamic keys on this object.
168    #[serde(rename = "additionalProperties")]
169    pub additional_properties: Option<Option<Box<JsonSchema>>>,
170    /// Additional information about this property.
171    pub annotations: Option<JsonSchemaAnnotations>,
172    /// The default value of this property (if one exists).
173    pub default: Option<String>,
174    /// Whether the parameter is deprecated.
175    pub deprecated: Option<bool>,
176    /// A description of this object.
177    pub description: Option<String>,
178    /// Values this parameter may take (if it is an enum).
179    #[serde(rename = "enum")]
180    pub enum_: Option<Vec<String>>,
181    /// The deprecation status for the enums. Each position maps to the corresponding value in the "enum" array.
182    #[serde(rename = "enumDeprecated")]
183    pub enum_deprecated: Option<Vec<bool>>,
184    /// The descriptions for the enums. Each position maps to the corresponding value in the "enum" array.
185    #[serde(rename = "enumDescriptions")]
186    pub enum_descriptions: Option<Vec<String>>,
187    /// An additional regular expression or key that helps constrain the value. For more details see: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23
188    pub format: Option<String>,
189    /// Unique identifier for this schema.
190    pub id: Option<String>,
191    /// If this is a schema for an array, this property is the schema for each element in the array.
192    pub items: Option<Option<Box<JsonSchema>>>,
193    /// Whether this parameter goes in the query or the path for REST requests.
194    pub location: Option<String>,
195    /// The maximum value of this parameter.
196    pub maximum: Option<String>,
197    /// The minimum value of this parameter.
198    pub minimum: Option<String>,
199    /// The regular expression this parameter must conform to. Uses Java 6 regex format: http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
200    pub pattern: Option<String>,
201    /// If this is a schema for an object, list the schema for each property of this object.
202    pub properties: Option<HashMap<String, JsonSchema>>,
203    /// The value is read-only, generated by the service. The value cannot be modified by the client. If the value is included in a POST, PUT, or PATCH request, it is ignored by the service.
204    #[serde(rename = "readOnly")]
205    pub read_only: Option<bool>,
206    /// Whether this parameter may appear multiple times.
207    pub repeated: Option<bool>,
208    /// Whether the parameter is required.
209    pub required: Option<bool>,
210    /// The value type for this schema. A list of values can be found here: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1
211    #[serde(rename = "type")]
212    pub type_: Option<String>,
213    /// In a variant data type, the value of one property is used to determine how to interpret the entire entity. Its value must exist in a map of descriminant values to schema names.
214    pub variant: Option<JsonSchemaVariant>,
215}
216
217impl common::Part for JsonSchema {}
218
219/// There is no detailed description.
220///
221/// # Activities
222///
223/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
224/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
225///
226/// * [get rest apis](ApiGetRestCall) (response)
227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
228#[serde_with::serde_as]
229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
230pub struct RestDescription {
231    /// Authentication information.
232    pub auth: Option<RestDescriptionAuth>,
233    /// [DEPRECATED] The base path for REST requests.
234    #[serde(rename = "basePath")]
235    pub base_path: Option<String>,
236    /// [DEPRECATED] The base URL for REST requests.
237    #[serde(rename = "baseUrl")]
238    pub base_url: Option<String>,
239    /// The path for REST batch requests.
240    #[serde(rename = "batchPath")]
241    pub batch_path: Option<String>,
242    /// Indicates how the API name should be capitalized and split into various parts. Useful for generating pretty class names.
243    #[serde(rename = "canonicalName")]
244    pub canonical_name: Option<String>,
245    /// The description of this API.
246    pub description: Option<String>,
247    /// Indicate the version of the Discovery API used to generate this doc.
248    #[serde(rename = "discoveryVersion")]
249    pub discovery_version: Option<String>,
250    /// A link to human readable documentation for the API.
251    #[serde(rename = "documentationLink")]
252    pub documentation_link: Option<String>,
253    /// A list of location-based endpoint objects for this API. Each object contains the endpoint URL, location, description and deprecation status.
254    pub endpoints: Option<Vec<RestDescriptionEndpoints>>,
255    /// The ETag for this response.
256    pub etag: Option<String>,
257    /// Enable exponential backoff for suitable methods in the generated clients.
258    #[serde(rename = "exponentialBackoffDefault")]
259    pub exponential_backoff_default: Option<bool>,
260    /// A list of supported features for this API.
261    pub features: Option<Vec<String>>,
262    /// Links to 16x16 and 32x32 icons representing the API.
263    pub icons: Option<RestDescriptionIcons>,
264    /// The ID of this API.
265    pub id: Option<String>,
266    /// The kind for this response.
267    pub kind: Option<String>,
268    /// Labels for the status of this API, such as labs or deprecated.
269    pub labels: Option<Vec<String>>,
270    /// API-level methods for this API.
271    pub methods: Option<HashMap<String, RestMethod>>,
272    /// The name of this API.
273    pub name: Option<String>,
274    /// The domain of the owner of this API. Together with the ownerName and a packagePath values, this can be used to generate a library for this API which would have a unique fully qualified name.
275    #[serde(rename = "ownerDomain")]
276    pub owner_domain: Option<String>,
277    /// The name of the owner of this API. See ownerDomain.
278    #[serde(rename = "ownerName")]
279    pub owner_name: Option<String>,
280    /// The package of the owner of this API. See ownerDomain.
281    #[serde(rename = "packagePath")]
282    pub package_path: Option<String>,
283    /// Common parameters that apply across all apis.
284    pub parameters: Option<HashMap<String, JsonSchema>>,
285    /// The protocol described by this document.
286    pub protocol: Option<String>,
287    /// The resources in this API.
288    pub resources: Option<HashMap<String, RestResource>>,
289    /// The version of this API.
290    pub revision: Option<String>,
291    /// The root URL under which all API services live.
292    #[serde(rename = "rootUrl")]
293    pub root_url: Option<String>,
294    /// The schemas for this API.
295    pub schemas: Option<HashMap<String, JsonSchema>>,
296    /// The base path for all REST requests.
297    #[serde(rename = "servicePath")]
298    pub service_path: Option<String>,
299    /// The title of this API.
300    pub title: Option<String>,
301    /// The version of this API.
302    pub version: Option<String>,
303    /// no description provided
304    pub version_module: Option<bool>,
305}
306
307impl common::ResponseResult for RestDescription {}
308
309/// There is no detailed description.
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 RestMethod {
317    /// The API Version of this method, as passed in via the `X-Goog-Api-Version` header or `$apiVersion` query parameter.
318    #[serde(rename = "apiVersion")]
319    pub api_version: Option<String>,
320    /// Whether this method is deprecated.
321    pub deprecated: Option<bool>,
322    /// Description of this method.
323    pub description: Option<String>,
324    /// Whether this method requires an ETag to be specified. The ETag is sent as an HTTP If-Match or If-None-Match header.
325    #[serde(rename = "etagRequired")]
326    pub etag_required: Option<bool>,
327    /// The URI path of this REST method in (RFC 6570) format without level 2 features ({+var}). Supplementary to the path property.
328    #[serde(rename = "flatPath")]
329    pub flat_path: Option<String>,
330    /// HTTP method used by this method.
331    #[serde(rename = "httpMethod")]
332    pub http_method: Option<String>,
333    /// A unique ID for this method. This property can be used to match methods between different versions of Discovery.
334    pub id: Option<String>,
335    /// Media upload parameters.
336    #[serde(rename = "mediaUpload")]
337    pub media_upload: Option<RestMethodMediaUpload>,
338    /// Ordered list of required parameters, serves as a hint to clients on how to structure their method signatures. The array is ordered such that the "most-significant" parameter appears first.
339    #[serde(rename = "parameterOrder")]
340    pub parameter_order: Option<Vec<String>>,
341    /// Details for all parameters in this method.
342    pub parameters: Option<HashMap<String, JsonSchema>>,
343    /// The URI path of this REST method. Should be used in conjunction with the basePath property at the api-level.
344    pub path: Option<String>,
345    /// The schema for the request.
346    pub request: Option<RestMethodRequest>,
347    /// The schema for the response.
348    pub response: Option<RestMethodResponse>,
349    /// OAuth 2.0 scopes applicable to this method.
350    pub scopes: Option<Vec<String>>,
351    /// Whether this method supports media downloads.
352    #[serde(rename = "supportsMediaDownload")]
353    pub supports_media_download: Option<bool>,
354    /// Whether this method supports media uploads.
355    #[serde(rename = "supportsMediaUpload")]
356    pub supports_media_upload: Option<bool>,
357    /// Whether this method supports subscriptions.
358    #[serde(rename = "supportsSubscription")]
359    pub supports_subscription: Option<bool>,
360    /// Indicates that downloads from this method should use the download service URL (i.e. "/download"). Only applies if the method supports media download.
361    #[serde(rename = "useMediaDownloadService")]
362    pub use_media_download_service: Option<bool>,
363}
364
365impl common::Part for RestMethod {}
366
367/// There is no detailed description.
368///
369/// This type is not used in any activity, and only used as *part* of another schema.
370///
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct RestResource {
375    /// Whether this resource is deprecated.
376    pub deprecated: Option<bool>,
377    /// Methods on this resource.
378    pub methods: Option<HashMap<String, RestMethod>>,
379    /// Sub-resources on this resource.
380    pub resources: Option<HashMap<String, RestResource>>,
381}
382
383impl common::Part for RestResource {}
384
385/// The individual directory entries. One entry per api/version pair.
386///
387/// This type is not used in any activity, and only used as *part* of another schema.
388///
389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
390#[serde_with::serde_as]
391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
392pub struct DirectoryListItems {
393    /// The description of this API.
394    pub description: Option<String>,
395    /// A link to the discovery document.
396    #[serde(rename = "discoveryLink")]
397    pub discovery_link: Option<String>,
398    /// The URL for the discovery REST document.
399    #[serde(rename = "discoveryRestUrl")]
400    pub discovery_rest_url: Option<String>,
401    /// A link to human readable documentation for the API.
402    #[serde(rename = "documentationLink")]
403    pub documentation_link: Option<String>,
404    /// Links to 16x16 and 32x32 icons representing the API.
405    pub icons: Option<DirectoryListItemsIcons>,
406    /// The id of this API.
407    pub id: Option<String>,
408    /// The kind for this response.
409    pub kind: Option<String>,
410    /// Labels for the status of this API, such as labs or deprecated.
411    pub labels: Option<Vec<String>>,
412    /// The name of the API.
413    pub name: Option<String>,
414    /// True if this version is the preferred version to use.
415    pub preferred: Option<bool>,
416    /// The title of this API.
417    pub title: Option<String>,
418    /// The version of the API.
419    pub version: Option<String>,
420}
421
422impl common::NestedType for DirectoryListItems {}
423impl common::Part for DirectoryListItems {}
424
425/// Links to 16x16 and 32x32 icons representing the API.
426///
427/// This type is not used in any activity, and only used as *part* of another schema.
428///
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as]
431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
432pub struct DirectoryListItemsIcons {
433    /// The URL of the 16x16 icon.
434    pub x16: Option<String>,
435    /// The URL of the 32x32 icon.
436    pub x32: Option<String>,
437}
438
439impl common::NestedType for DirectoryListItemsIcons {}
440impl common::Part for DirectoryListItemsIcons {}
441
442/// Additional information about this property.
443///
444/// This type is not used in any activity, and only used as *part* of another schema.
445///
446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
447#[serde_with::serde_as]
448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
449pub struct JsonSchemaAnnotations {
450    /// A list of methods for which this property is required on requests.
451    pub required: Option<Vec<String>>,
452}
453
454impl common::NestedType for JsonSchemaAnnotations {}
455impl common::Part for JsonSchemaAnnotations {}
456
457/// In a variant data type, the value of one property is used to determine how to interpret the entire entity. Its value must exist in a map of descriminant values to schema names.
458///
459/// This type is not used in any activity, and only used as *part* of another schema.
460///
461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
462#[serde_with::serde_as]
463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
464pub struct JsonSchemaVariant {
465    /// The name of the type discriminant property.
466    pub discriminant: Option<String>,
467    /// The map of discriminant value to schema to use for parsing..
468    pub map: Option<Vec<JsonSchemaVariantMap>>,
469}
470
471impl common::NestedType for JsonSchemaVariant {}
472impl common::Part for JsonSchemaVariant {}
473
474/// The map of discriminant value to schema to use for parsing..
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 JsonSchemaVariantMap {
482    /// no description provided
483    #[serde(rename = "$ref")]
484    pub ref_: Option<String>,
485    /// no description provided
486    pub type_value: Option<String>,
487}
488
489impl common::NestedType for JsonSchemaVariantMap {}
490impl common::Part for JsonSchemaVariantMap {}
491
492/// Authentication information.
493///
494/// This type is not used in any activity, and only used as *part* of another schema.
495///
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct RestDescriptionAuth {
500    /// OAuth 2.0 authentication information.
501    pub oauth2: Option<RestDescriptionAuthOauth2>,
502}
503
504impl common::NestedType for RestDescriptionAuth {}
505impl common::Part for RestDescriptionAuth {}
506
507/// OAuth 2.0 authentication information.
508///
509/// This type is not used in any activity, and only used as *part* of another schema.
510///
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct RestDescriptionAuthOauth2 {
515    /// Available OAuth 2.0 scopes.
516    pub scopes: Option<HashMap<String, RestDescriptionAuthOauth2Scopes>>,
517}
518
519impl common::NestedType for RestDescriptionAuthOauth2 {}
520impl common::Part for RestDescriptionAuthOauth2 {}
521
522/// The scope value.
523///
524/// This type is not used in any activity, and only used as *part* of another schema.
525///
526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
527#[serde_with::serde_as]
528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
529pub struct RestDescriptionAuthOauth2Scopes {
530    /// Description of scope.
531    pub description: Option<String>,
532}
533
534impl common::NestedType for RestDescriptionAuthOauth2Scopes {}
535impl common::Part for RestDescriptionAuthOauth2Scopes {}
536
537/// A single endpoint object
538///
539/// This type is not used in any activity, and only used as *part* of another schema.
540///
541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
542#[serde_with::serde_as]
543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
544pub struct RestDescriptionEndpoints {
545    /// Whether this endpoint is deprecated
546    pub deprecated: Option<bool>,
547    /// A string describing the host designated by the URL
548    pub description: Option<String>,
549    /// The URL of the endpoint target host
550    #[serde(rename = "endpointUrl")]
551    pub endpoint_url: Option<String>,
552    /// The location of the endpoint
553    pub location: Option<String>,
554}
555
556impl common::NestedType for RestDescriptionEndpoints {}
557impl common::Part for RestDescriptionEndpoints {}
558
559/// Links to 16x16 and 32x32 icons representing the API.
560///
561/// This type is not used in any activity, and only used as *part* of another schema.
562///
563#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
564#[serde_with::serde_as]
565#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
566pub struct RestDescriptionIcons {
567    /// The URL of the 16x16 icon.
568    pub x16: Option<String>,
569    /// The URL of the 32x32 icon.
570    pub x32: Option<String>,
571}
572
573impl common::NestedType for RestDescriptionIcons {}
574impl common::Part for RestDescriptionIcons {}
575
576/// Media upload parameters.
577///
578/// This type is not used in any activity, and only used as *part* of another schema.
579///
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct RestMethodMediaUpload {
584    /// MIME Media Ranges for acceptable media uploads to this method.
585    pub accept: Option<Vec<String>>,
586    /// Maximum size of a media upload, such as "1MB", "2GB" or "3TB".
587    #[serde(rename = "maxSize")]
588    pub max_size: Option<String>,
589    /// Supported upload protocols.
590    pub protocols: Option<RestMethodMediaUploadProtocols>,
591}
592
593impl common::NestedType for RestMethodMediaUpload {}
594impl common::Part for RestMethodMediaUpload {}
595
596/// Supported upload protocols.
597///
598/// This type is not used in any activity, and only used as *part* of another schema.
599///
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct RestMethodMediaUploadProtocols {
604    /// Supports the Resumable Media Upload protocol.
605    pub resumable: Option<RestMethodMediaUploadProtocolsResumable>,
606    /// Supports uploading as a single HTTP request.
607    pub simple: Option<RestMethodMediaUploadProtocolsSimple>,
608}
609
610impl common::NestedType for RestMethodMediaUploadProtocols {}
611impl common::Part for RestMethodMediaUploadProtocols {}
612
613/// Supports the Resumable Media Upload protocol.
614///
615/// This type is not used in any activity, and only used as *part* of another schema.
616///
617#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
618#[serde_with::serde_as]
619#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
620pub struct RestMethodMediaUploadProtocolsResumable {
621    /// True if this endpoint supports uploading multipart media.
622    pub multipart: Option<bool>,
623    /// The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level.
624    pub path: Option<String>,
625}
626
627impl common::NestedType for RestMethodMediaUploadProtocolsResumable {}
628impl common::Part for RestMethodMediaUploadProtocolsResumable {}
629
630/// Supports uploading as a single HTTP request.
631///
632/// This type is not used in any activity, and only used as *part* of another schema.
633///
634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
635#[serde_with::serde_as]
636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
637pub struct RestMethodMediaUploadProtocolsSimple {
638    /// True if this endpoint supports upload multipart media.
639    pub multipart: Option<bool>,
640    /// The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level.
641    pub path: Option<String>,
642}
643
644impl common::NestedType for RestMethodMediaUploadProtocolsSimple {}
645impl common::Part for RestMethodMediaUploadProtocolsSimple {}
646
647/// The schema for the request.
648///
649/// This type is not used in any activity, and only used as *part* of another schema.
650///
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct RestMethodRequest {
655    /// Schema ID for the request schema.
656    #[serde(rename = "$ref")]
657    pub ref_: Option<String>,
658    /// parameter name.
659    #[serde(rename = "parameterName")]
660    pub parameter_name: Option<String>,
661}
662
663impl common::NestedType for RestMethodRequest {}
664impl common::Part for RestMethodRequest {}
665
666/// The schema for the response.
667///
668/// This type is not used in any activity, and only used as *part* of another schema.
669///
670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
671#[serde_with::serde_as]
672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
673pub struct RestMethodResponse {
674    /// Schema ID for the response schema.
675    #[serde(rename = "$ref")]
676    pub ref_: Option<String>,
677}
678
679impl common::NestedType for RestMethodResponse {}
680impl common::Part for RestMethodResponse {}
681
682// ###################
683// MethodBuilders ###
684// #################
685
686/// A builder providing access to all methods supported on *api* resources.
687/// It is not used directly, but through the [`Discovery`] hub.
688///
689/// # Example
690///
691/// Instantiate a resource builder
692///
693/// ```test_harness,no_run
694/// extern crate hyper;
695/// extern crate hyper_rustls;
696/// extern crate google_discovery1 as discovery1;
697///
698/// # async fn dox() {
699/// use discovery1::{Discovery, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
700///
701/// let secret: yup_oauth2::ApplicationSecret = Default::default();
702/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
703///     secret,
704///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
705/// ).build().await.unwrap();
706///
707/// let client = hyper_util::client::legacy::Client::builder(
708///     hyper_util::rt::TokioExecutor::new()
709/// )
710/// .build(
711///     hyper_rustls::HttpsConnectorBuilder::new()
712///         .with_native_roots()
713///         .unwrap()
714///         .https_or_http()
715///         .enable_http1()
716///         .build()
717/// );
718/// let mut hub = Discovery::new(client, auth);
719/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
720/// // like `get_rest(...)` and `list(...)`
721/// // to build up your call.
722/// let rb = hub.apis();
723/// # }
724/// ```
725pub struct ApiMethods<'a, C>
726where
727    C: 'a,
728{
729    hub: &'a Discovery<C>,
730}
731
732impl<'a, C> common::MethodsBuilder for ApiMethods<'a, C> {}
733
734impl<'a, C> ApiMethods<'a, C> {
735    /// Create a builder to help you perform the following task:
736    ///
737    /// Retrieve the description of a particular version of an api.
738    ///
739    /// # Arguments
740    ///
741    /// * `api` - The name of the API.
742    /// * `version` - The version of the API.
743    pub fn get_rest(&self, api: &str, version: &str) -> ApiGetRestCall<'a, C> {
744        ApiGetRestCall {
745            hub: self.hub,
746            _api: api.to_string(),
747            _version: version.to_string(),
748            _delegate: Default::default(),
749            _additional_params: Default::default(),
750        }
751    }
752
753    /// Create a builder to help you perform the following task:
754    ///
755    /// Retrieve the list of APIs supported at this endpoint.
756    pub fn list(&self) -> ApiListCall<'a, C> {
757        ApiListCall {
758            hub: self.hub,
759            _preferred: Default::default(),
760            _name: Default::default(),
761            _delegate: Default::default(),
762            _additional_params: Default::default(),
763        }
764    }
765}
766
767// ###################
768// CallBuilders   ###
769// #################
770
771/// Retrieve the description of a particular version of an api.
772///
773/// A builder for the *getRest* method supported by a *api* resource.
774/// It is not used directly, but through a [`ApiMethods`] instance.
775///
776/// # Example
777///
778/// Instantiate a resource method builder
779///
780/// ```test_harness,no_run
781/// # extern crate hyper;
782/// # extern crate hyper_rustls;
783/// # extern crate google_discovery1 as discovery1;
784/// # async fn dox() {
785/// # use discovery1::{Discovery, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
786///
787/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
788/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
789/// #     secret,
790/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
791/// # ).build().await.unwrap();
792///
793/// # let client = hyper_util::client::legacy::Client::builder(
794/// #     hyper_util::rt::TokioExecutor::new()
795/// # )
796/// # .build(
797/// #     hyper_rustls::HttpsConnectorBuilder::new()
798/// #         .with_native_roots()
799/// #         .unwrap()
800/// #         .https_or_http()
801/// #         .enable_http1()
802/// #         .build()
803/// # );
804/// # let mut hub = Discovery::new(client, auth);
805/// // You can configure optional parameters by calling the respective setters at will, and
806/// // execute the final call using `doit()`.
807/// // Values shown here are possibly random and not representative !
808/// let result = hub.apis().get_rest("api", "version")
809///              .doit().await;
810/// # }
811/// ```
812pub struct ApiGetRestCall<'a, C>
813where
814    C: 'a,
815{
816    hub: &'a Discovery<C>,
817    _api: String,
818    _version: String,
819    _delegate: Option<&'a mut dyn common::Delegate>,
820    _additional_params: HashMap<String, String>,
821}
822
823impl<'a, C> common::CallBuilder for ApiGetRestCall<'a, C> {}
824
825impl<'a, C> ApiGetRestCall<'a, C>
826where
827    C: common::Connector,
828{
829    /// Perform the operation you have build so far.
830    pub async fn doit(mut self) -> common::Result<(common::Response, RestDescription)> {
831        use std::borrow::Cow;
832        use std::io::{Read, Seek};
833
834        use common::{url::Params, ToParts};
835        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
836
837        let mut dd = common::DefaultDelegate;
838        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
839        dlg.begin(common::MethodInfo {
840            id: "discovery.apis.getRest",
841            http_method: hyper::Method::GET,
842        });
843
844        for &field in ["alt", "api", "version"].iter() {
845            if self._additional_params.contains_key(field) {
846                dlg.finished(false);
847                return Err(common::Error::FieldClash(field));
848            }
849        }
850
851        let mut params = Params::with_capacity(4 + self._additional_params.len());
852        params.push("api", self._api);
853        params.push("version", self._version);
854
855        params.extend(self._additional_params.iter());
856
857        params.push("alt", "json");
858        let mut url = self.hub._base_url.clone() + "apis/{api}/{version}/rest";
859
860        #[allow(clippy::single_element_loop)]
861        for &(find_this, param_name) in [("{api}", "api"), ("{version}", "version")].iter() {
862            url = params.uri_replacement(url, param_name, find_this, false);
863        }
864        {
865            let to_remove = ["version", "api"];
866            params.remove_params(&to_remove);
867        }
868
869        let url = params.parse_with_url(&url);
870
871        loop {
872            let mut req_result = {
873                let client = &self.hub.client;
874                dlg.pre_request();
875                let mut req_builder = hyper::Request::builder()
876                    .method(hyper::Method::GET)
877                    .uri(url.as_str())
878                    .header(USER_AGENT, self.hub._user_agent.clone());
879
880                let request = req_builder
881                    .header(CONTENT_LENGTH, 0_u64)
882                    .body(common::to_body::<String>(None));
883
884                client.request(request.unwrap()).await
885            };
886
887            match req_result {
888                Err(err) => {
889                    if let common::Retry::After(d) = dlg.http_error(&err) {
890                        sleep(d).await;
891                        continue;
892                    }
893                    dlg.finished(false);
894                    return Err(common::Error::HttpError(err));
895                }
896                Ok(res) => {
897                    let (mut parts, body) = res.into_parts();
898                    let mut body = common::Body::new(body);
899                    if !parts.status.is_success() {
900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
901                        let error = serde_json::from_str(&common::to_string(&bytes));
902                        let response = common::to_response(parts, bytes.into());
903
904                        if let common::Retry::After(d) =
905                            dlg.http_failure(&response, error.as_ref().ok())
906                        {
907                            sleep(d).await;
908                            continue;
909                        }
910
911                        dlg.finished(false);
912
913                        return Err(match error {
914                            Ok(value) => common::Error::BadRequest(value),
915                            _ => common::Error::Failure(response),
916                        });
917                    }
918                    let response = {
919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
920                        let encoded = common::to_string(&bytes);
921                        match serde_json::from_str(&encoded) {
922                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
923                            Err(error) => {
924                                dlg.response_json_decode_error(&encoded, &error);
925                                return Err(common::Error::JsonDecodeError(
926                                    encoded.to_string(),
927                                    error,
928                                ));
929                            }
930                        }
931                    };
932
933                    dlg.finished(true);
934                    return Ok(response);
935                }
936            }
937        }
938    }
939
940    /// The name of the API.
941    ///
942    /// Sets the *api* path property to the given value.
943    ///
944    /// Even though the property as already been set when instantiating this call,
945    /// we provide this method for API completeness.
946    pub fn api(mut self, new_value: &str) -> ApiGetRestCall<'a, C> {
947        self._api = new_value.to_string();
948        self
949    }
950    /// The version of the API.
951    ///
952    /// Sets the *version* path property to the given value.
953    ///
954    /// Even though the property as already been set when instantiating this call,
955    /// we provide this method for API completeness.
956    pub fn version(mut self, new_value: &str) -> ApiGetRestCall<'a, C> {
957        self._version = new_value.to_string();
958        self
959    }
960    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
961    /// while executing the actual API request.
962    ///
963    /// ````text
964    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
965    /// ````
966    ///
967    /// Sets the *delegate* property to the given value.
968    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ApiGetRestCall<'a, C> {
969        self._delegate = Some(new_value);
970        self
971    }
972
973    /// Set any additional parameter of the query string used in the request.
974    /// It should be used to set parameters which are not yet available through their own
975    /// setters.
976    ///
977    /// Please note that this method must not be used to set any of the known parameters
978    /// which have their own setter method. If done anyway, the request will fail.
979    ///
980    /// # Additional Parameters
981    ///
982    /// * *alt* (query-string) - Data format for the response.
983    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
984    /// * *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.
985    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
986    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
987    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
988    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
989    pub fn param<T>(mut self, name: T, value: T) -> ApiGetRestCall<'a, C>
990    where
991        T: AsRef<str>,
992    {
993        self._additional_params
994            .insert(name.as_ref().to_string(), value.as_ref().to_string());
995        self
996    }
997}
998
999/// Retrieve the list of APIs supported at this endpoint.
1000///
1001/// A builder for the *list* method supported by a *api* resource.
1002/// It is not used directly, but through a [`ApiMethods`] instance.
1003///
1004/// # Example
1005///
1006/// Instantiate a resource method builder
1007///
1008/// ```test_harness,no_run
1009/// # extern crate hyper;
1010/// # extern crate hyper_rustls;
1011/// # extern crate google_discovery1 as discovery1;
1012/// # async fn dox() {
1013/// # use discovery1::{Discovery, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1014///
1015/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1016/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1017/// #     secret,
1018/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1019/// # ).build().await.unwrap();
1020///
1021/// # let client = hyper_util::client::legacy::Client::builder(
1022/// #     hyper_util::rt::TokioExecutor::new()
1023/// # )
1024/// # .build(
1025/// #     hyper_rustls::HttpsConnectorBuilder::new()
1026/// #         .with_native_roots()
1027/// #         .unwrap()
1028/// #         .https_or_http()
1029/// #         .enable_http1()
1030/// #         .build()
1031/// # );
1032/// # let mut hub = Discovery::new(client, auth);
1033/// // You can configure optional parameters by calling the respective setters at will, and
1034/// // execute the final call using `doit()`.
1035/// // Values shown here are possibly random and not representative !
1036/// let result = hub.apis().list()
1037///              .preferred(true)
1038///              .name("amet.")
1039///              .doit().await;
1040/// # }
1041/// ```
1042pub struct ApiListCall<'a, C>
1043where
1044    C: 'a,
1045{
1046    hub: &'a Discovery<C>,
1047    _preferred: Option<bool>,
1048    _name: Option<String>,
1049    _delegate: Option<&'a mut dyn common::Delegate>,
1050    _additional_params: HashMap<String, String>,
1051}
1052
1053impl<'a, C> common::CallBuilder for ApiListCall<'a, C> {}
1054
1055impl<'a, C> ApiListCall<'a, C>
1056where
1057    C: common::Connector,
1058{
1059    /// Perform the operation you have build so far.
1060    pub async fn doit(mut self) -> common::Result<(common::Response, DirectoryList)> {
1061        use std::borrow::Cow;
1062        use std::io::{Read, Seek};
1063
1064        use common::{url::Params, ToParts};
1065        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1066
1067        let mut dd = common::DefaultDelegate;
1068        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1069        dlg.begin(common::MethodInfo {
1070            id: "discovery.apis.list",
1071            http_method: hyper::Method::GET,
1072        });
1073
1074        for &field in ["alt", "preferred", "name"].iter() {
1075            if self._additional_params.contains_key(field) {
1076                dlg.finished(false);
1077                return Err(common::Error::FieldClash(field));
1078            }
1079        }
1080
1081        let mut params = Params::with_capacity(4 + self._additional_params.len());
1082        if let Some(value) = self._preferred.as_ref() {
1083            params.push("preferred", value.to_string());
1084        }
1085        if let Some(value) = self._name.as_ref() {
1086            params.push("name", value);
1087        }
1088
1089        params.extend(self._additional_params.iter());
1090
1091        params.push("alt", "json");
1092        let mut url = self.hub._base_url.clone() + "apis";
1093
1094        let url = params.parse_with_url(&url);
1095
1096        loop {
1097            let mut req_result = {
1098                let client = &self.hub.client;
1099                dlg.pre_request();
1100                let mut req_builder = hyper::Request::builder()
1101                    .method(hyper::Method::GET)
1102                    .uri(url.as_str())
1103                    .header(USER_AGENT, self.hub._user_agent.clone());
1104
1105                let request = req_builder
1106                    .header(CONTENT_LENGTH, 0_u64)
1107                    .body(common::to_body::<String>(None));
1108
1109                client.request(request.unwrap()).await
1110            };
1111
1112            match req_result {
1113                Err(err) => {
1114                    if let common::Retry::After(d) = dlg.http_error(&err) {
1115                        sleep(d).await;
1116                        continue;
1117                    }
1118                    dlg.finished(false);
1119                    return Err(common::Error::HttpError(err));
1120                }
1121                Ok(res) => {
1122                    let (mut parts, body) = res.into_parts();
1123                    let mut body = common::Body::new(body);
1124                    if !parts.status.is_success() {
1125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1126                        let error = serde_json::from_str(&common::to_string(&bytes));
1127                        let response = common::to_response(parts, bytes.into());
1128
1129                        if let common::Retry::After(d) =
1130                            dlg.http_failure(&response, error.as_ref().ok())
1131                        {
1132                            sleep(d).await;
1133                            continue;
1134                        }
1135
1136                        dlg.finished(false);
1137
1138                        return Err(match error {
1139                            Ok(value) => common::Error::BadRequest(value),
1140                            _ => common::Error::Failure(response),
1141                        });
1142                    }
1143                    let response = {
1144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1145                        let encoded = common::to_string(&bytes);
1146                        match serde_json::from_str(&encoded) {
1147                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1148                            Err(error) => {
1149                                dlg.response_json_decode_error(&encoded, &error);
1150                                return Err(common::Error::JsonDecodeError(
1151                                    encoded.to_string(),
1152                                    error,
1153                                ));
1154                            }
1155                        }
1156                    };
1157
1158                    dlg.finished(true);
1159                    return Ok(response);
1160                }
1161            }
1162        }
1163    }
1164
1165    /// Return only the preferred version of an API.
1166    ///
1167    /// Sets the *preferred* query property to the given value.
1168    pub fn preferred(mut self, new_value: bool) -> ApiListCall<'a, C> {
1169        self._preferred = Some(new_value);
1170        self
1171    }
1172    /// Only include APIs with the given name.
1173    ///
1174    /// Sets the *name* query property to the given value.
1175    pub fn name(mut self, new_value: &str) -> ApiListCall<'a, C> {
1176        self._name = Some(new_value.to_string());
1177        self
1178    }
1179    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1180    /// while executing the actual API request.
1181    ///
1182    /// ````text
1183    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1184    /// ````
1185    ///
1186    /// Sets the *delegate* property to the given value.
1187    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ApiListCall<'a, C> {
1188        self._delegate = Some(new_value);
1189        self
1190    }
1191
1192    /// Set any additional parameter of the query string used in the request.
1193    /// It should be used to set parameters which are not yet available through their own
1194    /// setters.
1195    ///
1196    /// Please note that this method must not be used to set any of the known parameters
1197    /// which have their own setter method. If done anyway, the request will fail.
1198    ///
1199    /// # Additional Parameters
1200    ///
1201    /// * *alt* (query-string) - Data format for the response.
1202    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1203    /// * *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.
1204    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1205    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1206    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1207    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1208    pub fn param<T>(mut self, name: T, value: T) -> ApiListCall<'a, C>
1209    where
1210        T: AsRef<str>,
1211    {
1212        self._additional_params
1213            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1214        self
1215    }
1216}