generate api client

This commit is contained in:
shinichi kogai
2022-09-29 12:40:34 +09:00
parent c3f8e1ffbf
commit 9fe9e424ef
6 changed files with 33946 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# DO NOT EDIT !
# This file was generated automatically from 'src/generator/templates/Cargo.toml.mako'
# DO NOT EDIT !
[package]
name = "google-walletobjects1"
version = "4.0.2+20220928"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
description = "A complete library to interact with Walletobjects (protocol v1)"
repository = "https://github.com/Byron/google-apis-rs/tree/main/gen/walletobjects1"
homepage = "https://developers.google.com/pay/passes"
documentation = "https://docs.rs/google-walletobjects1/4.0.2+20220928"
license = "MIT"
keywords = ["walletobjects", "google", "protocol", "web", "api"]
autobins = false
edition = "2018"
[dependencies]
anyhow = "^ 1.0"
hyper-rustls = "0.23.0"
mime = "^ 0.2.0"
serde = { version = "^ 1.0", features = ["derive"] }
serde_json = "^ 1.0"
itertools = "^ 0.10"
google-apis-common = { path = "../../google-apis-common", version = "4.0" }
hyper = "^ 0.14"
http = "^0.2"
tokio = "^1.0"
tower-service = "^0.3.1"
url = "= 1.7"
# [features]
# default = ["yup-oauth2"]

View File

@@ -0,0 +1,30 @@
<!---
DO NOT EDIT !
This file was generated automatically from 'src/generator/templates/LICENSE.md.mako'
DO NOT EDIT !
-->
The MIT License (MIT)
=====================
Copyright © `2015-2020` `Sebastian Thiel`
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,228 @@
<!---
DO NOT EDIT !
This file was generated automatically from 'src/generator/templates/api/README.md.mako'
DO NOT EDIT !
-->
The `google-walletobjects1` library allows access to all features of the *Google Walletobjects* service.
This documentation was generated from *Walletobjects* crate version *4.0.2+20220928*, where *20220928* is the exact revision of the *walletobjects:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v4.0.2*.
Everything else about the *Walletobjects* *v1* API can be found at the
[official documentation site](https://developers.google.com/pay/passes).
# Features
Handle the following *Resources* with ease from the central [hub](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/Walletobjects) ...
* eventticketclass
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketclasAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketclasUpdateCall)
* eventticketobject
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectListCall), [*modifylinkedofferobjects*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectModifylinkedofferobjectCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::EventticketobjectUpdateCall)
* flightclass
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightclasAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightclasUpdateCall)
* flightobject
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightobjectAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightobjectListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::FlightobjectUpdateCall)
* genericclass
* [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericclasUpdateCall)
* genericobject
* [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericobjectListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GenericobjectUpdateCall)
* giftcardclass
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardclasAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardclasUpdateCall)
* giftcardobject
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardobjectAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardobjectListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::GiftcardobjectUpdateCall)
* [issuer](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::Issuer)
* [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::IssuerGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::IssuerInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::IssuerListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::IssuerPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::IssuerUpdateCall)
* jwt
* [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::JwtInsertCall)
* loyaltyclass
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyclasAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyclasUpdateCall)
* loyaltyobject
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectListCall), [*modifylinkedofferobjects*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectModifylinkedofferobjectCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::LoyaltyobjectUpdateCall)
* offerclass
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferclasAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferclasUpdateCall)
* offerobject
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferobjectAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferobjectListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::OfferobjectUpdateCall)
* [permissions](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::Permission)
* [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::PermissionGetCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::PermissionUpdateCall)
* smarttap
* [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::SmarttapInsertCall)
* transitclass
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitclasAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitclasGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitclasInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitclasListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitclasPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitclasUpdateCall)
* transitobject
* [*addmessage*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitobjectAddmessageCall), [*get*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitobjectGetCall), [*insert*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitobjectInsertCall), [*list*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitobjectListCall), [*patch*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitobjectPatchCall) and [*update*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/api::TransitobjectUpdateCall)
# Structure of this Library
The API is structured into the following primary items:
* **[Hub](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/Walletobjects)**
* a central object to maintain state and allow accessing all *Activities*
* creates [*Method Builders*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::MethodsBuilder) which in turn
allow access to individual [*Call Builders*](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::CallBuilder)
* **[Resources](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Resource)**
* primary types that you can apply *Activities* to
* a collection of properties and *Parts*
* **[Parts](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Part)**
* a collection of properties
* never directly used in *Activities*
* **[Activities](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::CallBuilder)**
* operations to apply to *Resources*
All *structures* are marked with applicable traits to further categorize them and ease browsing.
Generally speaking, you can invoke *Activities* like this:
```Rust,ignore
let r = hub.resource().activity(...).doit().await
```
Or specifically ...
```ignore
let r = hub.eventticketclass().addmessage(...).doit().await
let r = hub.eventticketobject().addmessage(...).doit().await
let r = hub.flightclass().addmessage(...).doit().await
let r = hub.flightobject().addmessage(...).doit().await
let r = hub.giftcardclass().addmessage(...).doit().await
let r = hub.giftcardobject().addmessage(...).doit().await
let r = hub.loyaltyclass().addmessage(...).doit().await
let r = hub.loyaltyobject().addmessage(...).doit().await
let r = hub.offerclass().addmessage(...).doit().await
let r = hub.offerobject().addmessage(...).doit().await
let r = hub.transitclass().addmessage(...).doit().await
let r = hub.transitobject().addmessage(...).doit().await
```
The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
The `doit()` method performs the actual communication with the server and returns the respective result.
# Usage
## Setting up your Project
To use this library, you would put the following lines into your `Cargo.toml` file:
```toml
[dependencies]
google-walletobjects1 = "*"
serde = "^1.0"
serde_json = "^1.0"
```
## A complete example
```Rust
extern crate hyper;
extern crate hyper_rustls;
extern crate google_walletobjects1 as walletobjects1;
use walletobjects1::api::AddMessageRequest;
use walletobjects1::{Result, Error};
use std::default::Default;
use walletobjects1::{Walletobjects, oauth2, hyper, hyper_rustls};
// Get an ApplicationSecret instance by some means. It contains the `client_id` and
// `client_secret`, among other things.
let secret: oauth2::ApplicationSecret = Default::default();
// Instantiate the authenticator. It will choose a suitable authentication flow for you,
// unless you replace `None` with the desired Flow.
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
// retrieve them from storage.
let auth = oauth2::InstalledFlowAuthenticator::builder(
secret,
oauth2::InstalledFlowReturnMethod::HTTPRedirect,
).build().await.unwrap();
let mut hub = Walletobjects::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
// As the method needs a request, you would usually fill it with the desired information
// into the respective structure. Some of the parts shown here might not be applicable !
// Values shown here are possibly random and not representative !
let mut req = AddMessageRequest::default();
// You can configure optional parameters by calling the respective setters at will, and
// execute the final call using `doit()`.
// Values shown here are possibly random and not representative !
let result = hub.eventticketclass().addmessage(req, "resourceId")
.doit().await;
match result {
Err(e) => match e {
// The Error enum provides details about what exactly happened.
// You can also just use its `Debug`, `Display` or `Error` traits
Error::HttpError(_)
|Error::Io(_)
|Error::MissingAPIKey
|Error::MissingToken(_)
|Error::Cancelled
|Error::UploadSizeLimitExceeded(_, _)
|Error::Failure(_)
|Error::BadRequest(_)
|Error::FieldClash(_)
|Error::JsonDecodeError(_, _) => println!("{}", e),
},
Ok(res) => println!("Success: {:?}", res),
}
```
## Handling Errors
All errors produced by the system are provided either as [Result](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Result) enumeration as return value of
the doit() methods, or handed as possibly intermediate results to either the
[Hub Delegate](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Delegate), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
makes the system potentially resilient to all kinds of errors.
## Uploads and Downloads
If a method supports downloads, the response body, which is part of the [Result](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Result), should be
read by you to obtain the media.
If such a method also supports a [Response Result](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::ResponseResult), it will return that by default.
You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
this call: `.param("alt", "media")`.
Methods supporting uploads can do so using up to 2 different protocols:
*simple* and *resumable*. The distinctiveness of each is represented by customized
`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
## Customization and Callbacks
You may alter the way an `doit()` method is called by providing a [delegate](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Delegate) to the
[Method Builder](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::CallBuilder) before making the final `doit()` call.
Respective methods will be called to provide progress information, as well as determine whether the system should
retry on failure.
The [delegate trait](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Delegate) is default-implemented, allowing you to customize it with minimal effort.
## Optional Parts in Server-Requests
All structures provided by this library are made to be [encodable](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::RequestValue) and
[decodable](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses
are valid.
Most optionals are are considered [Parts](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::Part) which are identifiable by name, which will be sent to
the server to indicate either the set parts of the request or the desired parts in the response.
## Builder Arguments
Using [method builders](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::CallBuilder), you are able to prepare an action call by repeatedly calling it's methods.
These will always take a single argument, for which the following statements are true.
* [PODs][wiki-pod] are handed by copy
* strings are passed as `&str`
* [request values](https://docs.rs/google-walletobjects1/4.0.2+20220928/google_walletobjects1/client::RequestValue) are moved
Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
[wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
[google-go-api]: https://github.com/google/google-api-go-client
# License
The **walletobjects1** library was generated by Sebastian Thiel, and is placed
under the *MIT* license.
You can read the full text at the repository's [license file][repo-license].
[repo-license]: https://github.com/Byron/google-apis-rsblob/main/LICENSE.md

32618
gen/walletobjects1/src/api.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,789 @@
// COPY OF 'src/rust/api/client.rs'
// DO NOT EDIT
use std::error;
use std::error::Error as StdError;
use std::fmt::{self, Display};
use std::io::{self, Cursor, Read, Seek, SeekFrom, Write};
use std::str::FromStr;
use std::thread::sleep;
use std::time::Duration;
use itertools::Itertools;
use hyper::http::Uri;
use hyper::body::Buf;
use hyper::client::connect;
use hyper::header::{HeaderMap, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT};
use hyper::Method;
use hyper::StatusCode;
use mime::{Attr, Mime, SubLevel, TopLevel, Value};
use serde_json as json;
use tokio::io::{AsyncRead, AsyncWrite};
use tower_service;
const LINE_ENDING: &str = "\r\n";
pub enum Retry {
/// Signal you don't want to retry
Abort,
/// Signals you want to retry after the given duration
After(Duration),
}
/// Identifies the Hub. There is only one per library, this trait is supposed
/// to make intended use more explicit.
/// The hub allows to access all resource methods more easily.
pub trait Hub {}
/// Identifies types for building methods of a particular resource type
pub trait MethodsBuilder {}
/// Identifies types which represent builders for a particular resource method
pub trait CallBuilder {}
/// Identifies types which can be inserted and deleted.
/// Types with this trait are most commonly used by clients of this API.
pub trait Resource {}
/// Identifies types which are used in API responses.
pub trait ResponseResult {}
/// Identifies types which are used in API requests.
pub trait RequestValue {}
/// Identifies types which are not actually used by the API
/// This might be a bug within the google API schema.
pub trait UnusedType {}
/// Identifies types which are only used as part of other types, which
/// usually are carrying the `Resource` trait.
pub trait Part {}
/// Identifies types which are only used by other types internally.
/// They have no special meaning, this trait just marks them for completeness.
pub trait NestedType {}
/// A utility to specify reader types which provide seeking capabilities too
pub trait ReadSeek: Seek + Read + Send {}
impl<T: Seek + Read + Send> ReadSeek for T {}
/// A trait for all types that can convert themselves into a *parts* string
pub trait ToParts {
fn to_parts(&self) -> String;
}
/// A trait specifying functionality to help controlling any request performed by the API.
/// The trait has a conservative default implementation.
///
/// It contains methods to deal with all common issues, as well with the ones related to
/// uploading media
pub trait Delegate: Send {
/// Called at the beginning of any API request. The delegate should store the method
/// information if he is interesting in knowing more context when further calls to it
/// are made.
/// The matching `finished()` call will always be made, no matter whether or not the API
/// request was successful. That way, the delegate may easily maintain a clean state
/// between various API calls.
fn begin(&mut self, _info: MethodInfo) {}
/// Called whenever there is an [HttpError](hyper::Error), usually if there are network problems.
///
/// If you choose to retry after a duration, the duration should be chosen using the
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
///
/// Return retry information.
fn http_error(&mut self, _err: &hyper::Error) -> Retry {
Retry::Abort
}
/// Called whenever there is the need for your applications API key after
/// the official authenticator implementation didn't provide one, for some reason.
/// If this method returns None as well, the underlying operation will fail
fn api_key(&mut self) -> Option<String> {
None
}
/// Called whenever the Authenticator didn't yield a token. The delegate
/// may attempt to provide one, or just take it as a general information about the
/// impending failure.
/// The given Error provides information about why the token couldn't be acquired in the
/// first place
fn token(&mut self, err: &oauth2::Error) -> Option<oauth2::AccessToken> {
let _ = err;
None
}
/// Called during resumable uploads to provide a URL for the impending upload.
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
/// will be used instead of asking the server for a new upload URL.
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
/// be resumed.
/// The returned URL will be used exactly once - if it fails again and the delegate allows
/// to retry, we will ask the server for a new upload URL.
fn upload_url(&mut self) -> Option<String> {
None
}
/// Called after we have retrieved a new upload URL for a resumable upload to store it
/// in case we fail or cancel. That way, we can attempt to resume the upload later,
/// see `upload_url()`.
/// It will also be called with None after a successful upload, which allows the delegate
/// to forget the URL. That way, we will not attempt to resume an upload that has already
/// finished.
fn store_upload_url(&mut self, url: Option<&str>) {
let _ = url;
}
/// Called whenever a server response could not be decoded from json.
/// It's for informational purposes only, the caller will return with an error
/// accordingly.
///
/// # Arguments
///
/// * `json_encoded_value` - The json-encoded value which failed to decode.
/// * `json_decode_error` - The decoder error
fn response_json_decode_error(
&mut self,
json_encoded_value: &str,
json_decode_error: &json::Error,
) {
let _ = json_encoded_value;
let _ = json_decode_error;
}
/// Called whenever the http request returns with a non-success status code.
/// This can involve authentication issues, or anything else that very much
/// depends on the used API method.
/// The delegate should check the status, header and decoded json error to decide
/// whether to retry or not. In the latter case, the underlying call will fail.
///
/// If you choose to retry after a duration, the duration should be chosen using the
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
fn http_failure(
&mut self,
_: &hyper::Response<hyper::body::Body>,
_err: Option<serde_json::Value>,
) -> Retry {
Retry::Abort
}
/// Called prior to sending the main request of the given method. It can be used to time
/// the call or to print progress information.
/// It's also useful as you can be sure that a request will definitely be made.
fn pre_request(&mut self) {}
/// Return the size of each chunk of a resumable upload.
/// Must be a power of two, with 1<<18 being the smallest allowed chunk size.
/// Will be called once before starting any resumable upload.
fn chunk_size(&mut self) -> u64 {
1 << 23
}
/// Called before the given chunk is uploaded to the server.
/// If true is returned, the upload will be interrupted.
/// However, it may be resumable if you stored the upload URL in a previous call
/// to `store_upload_url()`
fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool {
let _ = chunk;
false
}
/// Called before the API request method returns, in every case. It can be used to clean up
/// internal state between calls to the API.
/// This call always has a matching call to `begin(...)`.
///
/// # Arguments
///
/// * `is_success` - a true value indicates the operation was successful. If false, you should
/// discard all values stored during `store_upload_url`.
fn finished(&mut self, is_success: bool) {
let _ = is_success;
}
}
/// A delegate with a conservative default implementation, which is used if no other delegate is
/// set.
#[derive(Default)]
pub struct DefaultDelegate;
impl Delegate for DefaultDelegate {}
#[derive(Debug)]
pub enum Error {
/// The http connection failed
HttpError(hyper::Error),
/// An attempt was made to upload a resource with size stored in field `.0`
/// even though the maximum upload size is what is stored in field `.1`.
UploadSizeLimitExceeded(u64, u64),
/// Represents information about a request that was not understood by the server.
/// Details are included.
BadRequest(serde_json::Value),
/// We needed an API key for authentication, but didn't obtain one.
/// Neither through the authenticator, nor through the Delegate.
MissingAPIKey,
/// We required a Token, but didn't get one from the Authenticator
MissingToken(oauth2::Error),
/// The delgate instructed to cancel the operation
Cancelled,
/// An additional, free form field clashed with one of the built-in optional ones
FieldClash(&'static str),
/// Shows that we failed to decode the server response.
/// This can happen if the protocol changes in conjunction with strict json decoding.
JsonDecodeError(String, json::Error),
/// Indicates an HTTP repsonse with a non-success status code
Failure(hyper::Response<hyper::body::Body>),
/// An IO error occurred while reading a stream into memory
Io(std::io::Error),
}
impl Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Io(ref err) => err.fmt(f),
Error::HttpError(ref err) => err.fmt(f),
Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) => writeln!(
f,
"The media size {} exceeds the maximum allowed upload size of {}",
resource_size, max_size
),
Error::MissingAPIKey => {
(writeln!(
f,
"The application's API key was not found in the configuration"
))
.ok();
writeln!(
f,
"It is used as there are no Scopes defined for this method."
)
}
Error::BadRequest(ref message) => {
writeln!(f, "Bad Request: {}", message)?;
Ok(())
}
Error::MissingToken(ref err) => {
writeln!(f, "Token retrieval failed with error: {}", err)
}
Error::Cancelled => writeln!(f, "Operation cancelled by delegate"),
Error::FieldClash(field) => writeln!(
f,
"The custom parameter '{}' is already provided natively by the CallBuilder.",
field
),
Error::JsonDecodeError(ref json_str, ref err) => writeln!(f, "{}: {}", err, json_str),
Error::Failure(ref response) => {
writeln!(f, "Http status indicates failure: {:?}", response)
}
}
}
}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match *self {
Error::HttpError(ref err) => err.source(),
Error::JsonDecodeError(_, ref err) => err.source(),
_ => None,
}
}
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Error::Io(err)
}
}
/// A universal result type used as return for all calls.
pub type Result<T> = std::result::Result<T, Error>;
/// Contains information about an API request.
pub struct MethodInfo {
pub id: &'static str,
pub http_method: Method,
}
const BOUNDARY: &str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d";
/// Provides a `Read` interface that converts multiple parts into the protocol
/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387).
/// **Note**: This implementation is just as rich as it needs to be to perform uploads
/// to google APIs, and might not be a fully-featured implementation.
#[derive(Default)]
pub struct MultiPartReader<'a> {
raw_parts: Vec<(HeaderMap, &'a mut (dyn Read + Send))>,
current_part: Option<(Cursor<Vec<u8>>, &'a mut (dyn Read + Send))>,
last_part_boundary: Option<Cursor<Vec<u8>>>,
}
impl<'a> MultiPartReader<'a> {
/// Reserve memory for exactly the given amount of parts
pub fn reserve_exact(&mut self, cap: usize) {
self.raw_parts.reserve_exact(cap);
}
/// Add a new part to the queue of parts to be read on the first `read` call.
///
/// # Arguments
///
/// `headers` - identifying the body of the part. It's similar to the header
/// in an ordinary single-part call, and should thus contain the
/// same information.
/// `reader` - a reader providing the part's body
/// `size` - the amount of bytes provided by the reader. It will be put onto the header as
/// content-size.
/// `mime` - It will be put onto the content type
pub fn add_part(
&mut self,
reader: &'a mut (dyn Read + Send),
size: u64,
mime_type: Mime,
) -> &mut MultiPartReader<'a> {
let mut headers = HeaderMap::new();
headers.insert(
CONTENT_TYPE,
hyper::header::HeaderValue::from_str(&format!("{}", mime_type)).unwrap(),
);
headers.insert(CONTENT_LENGTH, size.into());
self.raw_parts.push((headers, reader));
self
}
/// Returns the mime-type representing our multi-part message.
/// Use it with the ContentType header.
pub fn mime_type(&self) -> Mime {
Mime(
TopLevel::Multipart,
SubLevel::Ext("related".to_string()),
vec![(
Attr::Ext("boundary".to_string()),
Value::Ext(BOUNDARY.to_string()),
)],
)
}
/// Returns true if we are totally used
fn is_depleted(&self) -> bool {
self.raw_parts.is_empty()
&& self.current_part.is_none()
&& self.last_part_boundary.is_none()
}
/// Returns true if we are handling our last part
fn is_last_part(&self) -> bool {
self.raw_parts.is_empty() && self.current_part.is_some()
}
}
impl<'a> Read for MultiPartReader<'a> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match (
self.raw_parts.len(),
self.current_part.is_none(),
self.last_part_boundary.is_none(),
) {
(_, _, false) => {
let br = self
.last_part_boundary
.as_mut()
.unwrap()
.read(buf)
.unwrap_or(0);
if br < buf.len() {
self.last_part_boundary = None;
}
return Ok(br);
}
(0, true, true) => return Ok(0),
(n, true, _) if n > 0 => {
let (headers, reader) = self.raw_parts.remove(0);
let mut c = Cursor::new(Vec::<u8>::new());
// TODO: The first line ending should be omitted for the first part,
// fortunately Google's API serves don't seem to mind.
(write!(
&mut c,
"{}--{}{}{}{}{}",
LINE_ENDING,
BOUNDARY,
LINE_ENDING,
headers
.iter()
.map(|(k, v)| format!("{}: {}", k, v.to_str().unwrap()))
.join(LINE_ENDING),
LINE_ENDING,
LINE_ENDING,
))
.unwrap();
c.seek(SeekFrom::Start(0)).unwrap();
self.current_part = Some((c, reader));
}
_ => {}
}
// read headers as long as possible
let (hb, rr) = {
let &mut (ref mut c, ref mut reader) = self.current_part.as_mut().unwrap();
let b = c.read(buf).unwrap_or(0);
(b, reader.read(&mut buf[b..]))
};
match rr {
Ok(bytes_read) => {
if hb < buf.len() && bytes_read == 0 {
if self.is_last_part() {
// before clearing the last part, we will add the boundary that
// will be written last
self.last_part_boundary = Some(Cursor::new(
format!("{}--{}--{}", LINE_ENDING, BOUNDARY, LINE_ENDING).into_bytes(),
))
}
// We are depleted - this can trigger the next part to come in
self.current_part = None;
}
let mut total_bytes_read = hb + bytes_read;
while total_bytes_read < buf.len() && !self.is_depleted() {
match self.read(&mut buf[total_bytes_read..]) {
Ok(br) => total_bytes_read += br,
Err(err) => return Err(err),
}
}
Ok(total_bytes_read)
}
Err(err) => {
// fail permanently
self.current_part = None;
self.last_part_boundary = None;
self.raw_parts.clear();
Err(err)
}
}
}
}
/// The `X-Upload-Content-Type` header.
///
/// Generated via rustc --pretty expanded -Z unstable-options, and manually
/// processed to be more readable.
#[derive(PartialEq, Debug, Clone)]
pub struct XUploadContentType(pub Mime);
impl ::std::ops::Deref for XUploadContentType {
type Target = Mime;
fn deref(&self) -> &Mime {
&self.0
}
}
impl ::std::ops::DerefMut for XUploadContentType {
fn deref_mut(&mut self) -> &mut Mime {
&mut self.0
}
}
impl Display for XUploadContentType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct Chunk {
pub first: u64,
pub last: u64,
}
impl fmt::Display for Chunk {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
(write!(fmt, "{}-{}", self.first, self.last)).ok();
Ok(())
}
}
impl FromStr for Chunk {
type Err = &'static str;
/// NOTE: only implements `%i-%i`, not `*`
fn from_str(s: &str) -> std::result::Result<Chunk, &'static str> {
let parts: Vec<&str> = s.split('-').collect();
if parts.len() != 2 {
return Err("Expected two parts: %i-%i");
}
Ok(Chunk {
first: match FromStr::from_str(parts[0]) {
Ok(d) => d,
_ => return Err("Couldn't parse 'first' as digit"),
},
last: match FromStr::from_str(parts[1]) {
Ok(d) => d,
_ => return Err("Couldn't parse 'last' as digit"),
},
})
}
}
/// Implements the Content-Range header, for serialization only
#[derive(Clone, PartialEq, Debug)]
pub struct ContentRange {
pub range: Option<Chunk>,
pub total_length: u64,
}
impl ContentRange {
pub fn header_value(&self) -> String {
format!(
"bytes {}/{}",
match self.range {
Some(ref c) => format!("{}", c),
None => "*".to_string(),
},
self.total_length
)
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct RangeResponseHeader(pub Chunk);
impl RangeResponseHeader {
fn from_bytes(raw: &[u8]) -> Self {
if !raw.is_empty() {
if let Ok(s) = std::str::from_utf8(raw) {
const PREFIX: &str = "bytes ";
if let Some(stripped) = s.strip_prefix(PREFIX) {
if let Ok(c) = <Chunk as FromStr>::from_str(&stripped) {
return RangeResponseHeader(c);
}
}
}
}
panic!("Unable to parse Range header {:?}", raw)
}
}
/// A utility type to perform a resumable upload from start to end.
pub struct ResumableUploadHelper<'a, A: 'a, S>
where
S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub client: &'a hyper::client::Client<
S,
hyper::body::Body,
>,
pub delegate: &'a mut dyn Delegate,
pub start_at: Option<u64>,
pub auth: &'a A,
pub user_agent: &'a str,
pub auth_header: String,
pub url: &'a str,
pub reader: &'a mut dyn ReadSeek,
pub media_type: Mime,
pub content_length: u64,
}
impl<'a, A, S> ResumableUploadHelper<'a, A, S>
where
S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
async fn query_transfer_status(
&mut self,
) -> std::result::Result<u64, hyper::Result<hyper::Response<hyper::body::Body>>> {
loop {
match self
.client
.request(
hyper::Request::builder()
.method(hyper::Method::POST)
.uri(self.url)
.header(USER_AGENT, self.user_agent.to_string())
.header(
"Content-Range",
ContentRange {
range: None,
total_length: self.content_length,
}
.header_value(),
)
.header(AUTHORIZATION, self.auth_header.clone())
.body(hyper::body::Body::empty())
.unwrap(),
)
.await
{
Ok(r) => {
// 308 = resume-incomplete == PermanentRedirect
let headers = r.headers().clone();
let h: RangeResponseHeader = match headers.get("Range") {
Some(hh) if r.status() == StatusCode::PERMANENT_REDIRECT => {
RangeResponseHeader::from_bytes(hh.as_bytes())
}
None | Some(_) => {
if let Retry::After(d) = self.delegate.http_failure(&r, None) {
sleep(d);
continue;
}
return Err(Ok(r));
}
};
return Ok(h.0.last);
}
Err(err) => {
if let Retry::After(d) = self.delegate.http_error(&err) {
sleep(d);
continue;
}
return Err(Err(err));
}
}
}
}
/// returns None if operation was cancelled by delegate, or the HttpResult.
/// It can be that we return the result just because we didn't understand the status code -
/// caller should check for status himself before assuming it's OK to use
pub async fn upload(&mut self) -> Option<hyper::Result<hyper::Response<hyper::body::Body>>> {
let mut start = match self.start_at {
Some(s) => s,
None => match self.query_transfer_status().await {
Ok(s) => s,
Err(result) => return Some(result),
},
};
const MIN_CHUNK_SIZE: u64 = 1 << 18;
let chunk_size = match self.delegate.chunk_size() {
cs if cs > MIN_CHUNK_SIZE => cs,
_ => MIN_CHUNK_SIZE,
};
loop {
self.reader.seek(SeekFrom::Start(start)).unwrap();
let request_size = match self.content_length - start {
rs if rs > chunk_size => chunk_size,
rs => rs,
};
let mut section_reader = self.reader.take(request_size);
let mut req_bytes = vec![];
section_reader.read_to_end(&mut req_bytes).unwrap();
let range_header = ContentRange {
range: Some(Chunk {
first: start,
last: start + request_size - 1,
}),
total_length: self.content_length,
};
if self.delegate.cancel_chunk_upload(&range_header) {
return None;
}
let res = self
.client
.request(
hyper::Request::builder()
.uri(self.url)
.method(hyper::Method::POST)
.header("Content-Range", range_header.header_value())
.header(CONTENT_TYPE, format!("{}", self.media_type))
.header(USER_AGENT, self.user_agent.to_string())
.body(hyper::body::Body::from(req_bytes))
.unwrap(),
)
.await;
match res {
Ok(res) => {
start += request_size;
if res.status() == StatusCode::PERMANENT_REDIRECT {
continue;
}
let (res_parts, res_body) = res.into_parts();
let res_body = match hyper::body::to_bytes(res_body).await {
Ok(res_body) => res_body.into_iter().collect(),
Err(err) => return Some(Err(err)),
};
let res_body_string: String = String::from_utf8(res_body).unwrap();
let reconstructed_result =
hyper::Response::from_parts(res_parts, res_body_string.clone().into());
if !reconstructed_result.status().is_success() {
if let Retry::After(d) = self.delegate.http_failure(
&reconstructed_result,
json::from_str(&res_body_string).ok(),
) {
sleep(d);
continue;
}
}
return Some(Ok(reconstructed_result));
}
Err(err) => {
if let Retry::After(d) = self.delegate.http_error(&err) {
sleep(d);
continue;
}
return Some(Err(err));
}
}
}
}
}
// Copy of src/rust/cli/client.rs
// TODO(ST): Allow sharing common code between program types
pub fn remove_json_null_values(value: &mut json::value::Value) {
match *value {
json::value::Value::Object(ref mut map) => {
let mut for_removal = Vec::new();
for (key, mut value) in map.iter_mut() {
if value.is_null() {
for_removal.push(key.clone());
} else {
remove_json_null_values(&mut value);
}
}
for key in &for_removal {
map.remove(key);
}
}
json::value::Value::Array(ref mut arr) => {
let mut i = 0;
while i < arr.len() {
if arr[i].is_null() {
arr.remove(i);
} else {
remove_json_null_values(&mut arr[i]);
i += 1;
}
}
}
_ => {}
}
}
// Borrowing the body object as mutable and converts it to a string
pub async fn get_body_as_string(res_body: &mut hyper::Body) -> String {
let res_body_buf = hyper::body::to_bytes(res_body).await.unwrap();
let res_body_string = String::from_utf8_lossy(&res_body_buf);
res_body_string.to_string()
}

View File

@@ -0,0 +1,245 @@
// DO NOT EDIT !
// This file was generated automatically from 'src/generator/templates/api/lib.rs.mako'
// DO NOT EDIT !
//! This documentation was generated from *Walletobjects* crate version *4.0.2+20220928*, where *20220928* is the exact revision of the *walletobjects:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v4.0.2*.
//!
//! Everything else about the *Walletobjects* *v1* API can be found at the
//! [official documentation site](https://developers.google.com/pay/passes).
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/main/gen/walletobjects1).
//! # Features
//!
//! Handle the following *Resources* with ease from the central [hub](Walletobjects) ...
//!
//! * eventticketclass
//! * [*addmessage*](api::EventticketclasAddmessageCall), [*get*](api::EventticketclasGetCall), [*insert*](api::EventticketclasInsertCall), [*list*](api::EventticketclasListCall), [*patch*](api::EventticketclasPatchCall) and [*update*](api::EventticketclasUpdateCall)
//! * eventticketobject
//! * [*addmessage*](api::EventticketobjectAddmessageCall), [*get*](api::EventticketobjectGetCall), [*insert*](api::EventticketobjectInsertCall), [*list*](api::EventticketobjectListCall), [*modifylinkedofferobjects*](api::EventticketobjectModifylinkedofferobjectCall), [*patch*](api::EventticketobjectPatchCall) and [*update*](api::EventticketobjectUpdateCall)
//! * flightclass
//! * [*addmessage*](api::FlightclasAddmessageCall), [*get*](api::FlightclasGetCall), [*insert*](api::FlightclasInsertCall), [*list*](api::FlightclasListCall), [*patch*](api::FlightclasPatchCall) and [*update*](api::FlightclasUpdateCall)
//! * flightobject
//! * [*addmessage*](api::FlightobjectAddmessageCall), [*get*](api::FlightobjectGetCall), [*insert*](api::FlightobjectInsertCall), [*list*](api::FlightobjectListCall), [*patch*](api::FlightobjectPatchCall) and [*update*](api::FlightobjectUpdateCall)
//! * genericclass
//! * [*get*](api::GenericclasGetCall), [*insert*](api::GenericclasInsertCall), [*list*](api::GenericclasListCall), [*patch*](api::GenericclasPatchCall) and [*update*](api::GenericclasUpdateCall)
//! * genericobject
//! * [*get*](api::GenericobjectGetCall), [*insert*](api::GenericobjectInsertCall), [*list*](api::GenericobjectListCall), [*patch*](api::GenericobjectPatchCall) and [*update*](api::GenericobjectUpdateCall)
//! * giftcardclass
//! * [*addmessage*](api::GiftcardclasAddmessageCall), [*get*](api::GiftcardclasGetCall), [*insert*](api::GiftcardclasInsertCall), [*list*](api::GiftcardclasListCall), [*patch*](api::GiftcardclasPatchCall) and [*update*](api::GiftcardclasUpdateCall)
//! * giftcardobject
//! * [*addmessage*](api::GiftcardobjectAddmessageCall), [*get*](api::GiftcardobjectGetCall), [*insert*](api::GiftcardobjectInsertCall), [*list*](api::GiftcardobjectListCall), [*patch*](api::GiftcardobjectPatchCall) and [*update*](api::GiftcardobjectUpdateCall)
//! * [issuer](api::Issuer)
//! * [*get*](api::IssuerGetCall), [*insert*](api::IssuerInsertCall), [*list*](api::IssuerListCall), [*patch*](api::IssuerPatchCall) and [*update*](api::IssuerUpdateCall)
//! * jwt
//! * [*insert*](api::JwtInsertCall)
//! * loyaltyclass
//! * [*addmessage*](api::LoyaltyclasAddmessageCall), [*get*](api::LoyaltyclasGetCall), [*insert*](api::LoyaltyclasInsertCall), [*list*](api::LoyaltyclasListCall), [*patch*](api::LoyaltyclasPatchCall) and [*update*](api::LoyaltyclasUpdateCall)
//! * loyaltyobject
//! * [*addmessage*](api::LoyaltyobjectAddmessageCall), [*get*](api::LoyaltyobjectGetCall), [*insert*](api::LoyaltyobjectInsertCall), [*list*](api::LoyaltyobjectListCall), [*modifylinkedofferobjects*](api::LoyaltyobjectModifylinkedofferobjectCall), [*patch*](api::LoyaltyobjectPatchCall) and [*update*](api::LoyaltyobjectUpdateCall)
//! * offerclass
//! * [*addmessage*](api::OfferclasAddmessageCall), [*get*](api::OfferclasGetCall), [*insert*](api::OfferclasInsertCall), [*list*](api::OfferclasListCall), [*patch*](api::OfferclasPatchCall) and [*update*](api::OfferclasUpdateCall)
//! * offerobject
//! * [*addmessage*](api::OfferobjectAddmessageCall), [*get*](api::OfferobjectGetCall), [*insert*](api::OfferobjectInsertCall), [*list*](api::OfferobjectListCall), [*patch*](api::OfferobjectPatchCall) and [*update*](api::OfferobjectUpdateCall)
//! * [permissions](api::Permission)
//! * [*get*](api::PermissionGetCall) and [*update*](api::PermissionUpdateCall)
//! * smarttap
//! * [*insert*](api::SmarttapInsertCall)
//! * transitclass
//! * [*addmessage*](api::TransitclasAddmessageCall), [*get*](api::TransitclasGetCall), [*insert*](api::TransitclasInsertCall), [*list*](api::TransitclasListCall), [*patch*](api::TransitclasPatchCall) and [*update*](api::TransitclasUpdateCall)
//! * transitobject
//! * [*addmessage*](api::TransitobjectAddmessageCall), [*get*](api::TransitobjectGetCall), [*insert*](api::TransitobjectInsertCall), [*list*](api::TransitobjectListCall), [*patch*](api::TransitobjectPatchCall) and [*update*](api::TransitobjectUpdateCall)
//!
//!
//!
//!
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
//!
//! # Structure of this Library
//!
//! The API is structured into the following primary items:
//!
//! * **[Hub](Walletobjects)**
//! * a central object to maintain state and allow accessing all *Activities*
//! * creates [*Method Builders*](client::MethodsBuilder) which in turn
//! allow access to individual [*Call Builders*](client::CallBuilder)
//! * **[Resources](client::Resource)**
//! * primary types that you can apply *Activities* to
//! * a collection of properties and *Parts*
//! * **[Parts](client::Part)**
//! * a collection of properties
//! * never directly used in *Activities*
//! * **[Activities](client::CallBuilder)**
//! * operations to apply to *Resources*
//!
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
//!
//! Generally speaking, you can invoke *Activities* like this:
//!
//! ```Rust,ignore
//! let r = hub.resource().activity(...).doit().await
//! ```
//!
//! Or specifically ...
//!
//! ```ignore
//! let r = hub.eventticketclass().addmessage(...).doit().await
//! let r = hub.eventticketobject().addmessage(...).doit().await
//! let r = hub.flightclass().addmessage(...).doit().await
//! let r = hub.flightobject().addmessage(...).doit().await
//! let r = hub.giftcardclass().addmessage(...).doit().await
//! let r = hub.giftcardobject().addmessage(...).doit().await
//! let r = hub.loyaltyclass().addmessage(...).doit().await
//! let r = hub.loyaltyobject().addmessage(...).doit().await
//! let r = hub.offerclass().addmessage(...).doit().await
//! let r = hub.offerobject().addmessage(...).doit().await
//! let r = hub.transitclass().addmessage(...).doit().await
//! let r = hub.transitobject().addmessage(...).doit().await
//! ```
//!
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
//! The `doit()` method performs the actual communication with the server and returns the respective result.
//!
//! # Usage
//!
//! ## Setting up your Project
//!
//! To use this library, you would put the following lines into your `Cargo.toml` file:
//!
//! ```toml
//! [dependencies]
//! google-walletobjects1 = "*"
//! serde = "^1.0"
//! serde_json = "^1.0"
//! ```
//!
//! ## A complete example
//!
//! ```test_harness,no_run
//! extern crate hyper;
//! extern crate hyper_rustls;
//! extern crate google_walletobjects1 as walletobjects1;
//! use walletobjects1::api::AddMessageRequest;
//! use walletobjects1::{Result, Error};
//! # async fn dox() {
//! use std::default::Default;
//! use walletobjects1::{Walletobjects, oauth2, hyper, hyper_rustls};
//!
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
//! // `client_secret`, among other things.
//! let secret: oauth2::ApplicationSecret = Default::default();
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
//! // unless you replace `None` with the desired Flow.
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
//! // retrieve them from storage.
//! let auth = oauth2::InstalledFlowAuthenticator::builder(
//! secret,
//! oauth2::InstalledFlowReturnMethod::HTTPRedirect,
//! ).build().await.unwrap();
//! let mut hub = Walletobjects::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
//! // As the method needs a request, you would usually fill it with the desired information
//! // into the respective structure. Some of the parts shown here might not be applicable !
//! // Values shown here are possibly random and not representative !
//! let mut req = AddMessageRequest::default();
//!
//! // You can configure optional parameters by calling the respective setters at will, and
//! // execute the final call using `doit()`.
//! // Values shown here are possibly random and not representative !
//! let result = hub.eventticketclass().addmessage(req, "resourceId")
//! .doit().await;
//!
//! match result {
//! Err(e) => match e {
//! // The Error enum provides details about what exactly happened.
//! // You can also just use its `Debug`, `Display` or `Error` traits
//! Error::HttpError(_)
//! |Error::Io(_)
//! |Error::MissingAPIKey
//! |Error::MissingToken(_)
//! |Error::Cancelled
//! |Error::UploadSizeLimitExceeded(_, _)
//! |Error::Failure(_)
//! |Error::BadRequest(_)
//! |Error::FieldClash(_)
//! |Error::JsonDecodeError(_, _) => println!("{}", e),
//! },
//! Ok(res) => println!("Success: {:?}", res),
//! }
//! # }
//! ```
//! ## Handling Errors
//!
//! All errors produced by the system are provided either as [Result](client::Result) enumeration as return value of
//! the doit() methods, or handed as possibly intermediate results to either the
//! [Hub Delegate](client::Delegate), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
//!
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
//! makes the system potentially resilient to all kinds of errors.
//!
//! ## Uploads and Downloads
//! If a method supports downloads, the response body, which is part of the [Result](client::Result), should be
//! read by you to obtain the media.
//! If such a method also supports a [Response Result](client::ResponseResult), it will return that by default.
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
//! this call: `.param("alt", "media")`.
//!
//! Methods supporting uploads can do so using up to 2 different protocols:
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
//!
//! ## Customization and Callbacks
//!
//! You may alter the way an `doit()` method is called by providing a [delegate](client::Delegate) to the
//! [Method Builder](client::CallBuilder) before making the final `doit()` call.
//! Respective methods will be called to provide progress information, as well as determine whether the system should
//! retry on failure.
//!
//! The [delegate trait](client::Delegate) is default-implemented, allowing you to customize it with minimal effort.
//!
//! ## Optional Parts in Server-Requests
//!
//! All structures provided by this library are made to be [encodable](client::RequestValue) and
//! [decodable](client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses
//! are valid.
//! Most optionals are are considered [Parts](client::Part) which are identifiable by name, which will be sent to
//! the server to indicate either the set parts of the request or the desired parts in the response.
//!
//! ## Builder Arguments
//!
//! Using [method builders](client::CallBuilder), you are able to prepare an action call by repeatedly calling it's methods.
//! These will always take a single argument, for which the following statements are true.
//!
//! * [PODs][wiki-pod] are handed by copy
//! * strings are passed as `&str`
//! * [request values](client::RequestValue) are moved
//!
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
//!
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
//! [google-go-api]: https://github.com/google/google-api-go-client
//!
//!
// Unused attributes happen thanks to defined, but unused structures
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
// unused imports in fully featured APIs. Same with unused_mut ... .
#![allow(unused_imports, unused_mut, dead_code)]
// DO NOT EDIT !
// This file was generated automatically from 'src/generator/templates/api/lib.rs.mako'
// DO NOT EDIT !
// Re-export the hyper and hyper_rustls crate, they are required to build the hub
pub use hyper;
pub use hyper_rustls;
pub extern crate google_apis_common as client;
pub mod api;
// Re-export the hub type and some basic client structs
pub use api::Walletobjects;
// Re-export the yup_oauth2 crate, that is required to call some methods of the hub and the client
pub use client::{Result, Error, Delegate, oauth2};