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