|
| 1 | +<!--- |
| 2 | +DO NOT EDIT ! |
| 3 | +This file was generated automatically from 'src/mako/README.md.mako' |
| 4 | +DO NOT EDIT ! |
| 5 | +--> |
| 6 | +The `groupsmigration1` library allows access to all features of *Groups Migration*. |
| 7 | + |
| 8 | +# Features |
| 9 | + |
| 10 | +It seems there is nothing you can do here ... . |
| 11 | + |
| 12 | +* archive |
| 13 | + * [*insert*](http://byron.github.io/google-apis-rs/google-groupsmigration1/struct.ArchiveInsertCall.html) |
| 14 | + |
| 15 | + |
| 16 | +Upload supported by ... |
| 17 | + |
| 18 | +* [*insert archive*](http://byron.github.io/google-apis-rs/google-groupsmigration1/struct.ArchiveInsertCall.html) |
| 19 | + |
| 20 | + |
| 21 | +Everything else about the *Groups Migration* *v1* API can be found at the |
| 22 | +[official documentation site](https://developers.google.com/google-apps/groups-migration/). |
| 23 | + |
| 24 | +# Structure of this Library |
| 25 | + |
| 26 | +The API is structured into the following primary items: |
| 27 | + |
| 28 | +* **[Hub](http://byron.github.io/google-apis-rs/google-groupsmigration1/struct.GroupsMigration.html)** |
| 29 | + * a central object to maintain state and allow accessing all *Activities* |
| 30 | +* **[Resources](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Resource.html)** |
| 31 | + * primary types that you can apply *Activities* to |
| 32 | + * a collection of properties and *Parts* |
| 33 | + * **[Parts](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Part.html)** |
| 34 | + * a collection of properties |
| 35 | + * never directly used in *Activities* |
| 36 | +* **[Activities](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.CallBuilder.html)** |
| 37 | + * operations to apply to *Resources* |
| 38 | + |
| 39 | +Generally speaking, you can invoke *Activities* like this: |
| 40 | + |
| 41 | +```Rust,ignore |
| 42 | +let r = hub.resource().activity(...).doit() |
| 43 | +``` |
| 44 | + |
| 45 | +Or specifically ... |
| 46 | + |
| 47 | +```ignore |
| 48 | +let r = hub.archive().insert(...).doit() |
| 49 | +``` |
| 50 | + |
| 51 | +The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` |
| 52 | +supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be |
| 53 | +specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. |
| 54 | +The `doit()` method performs the actual communication with the server and returns the respective result. |
| 55 | + |
| 56 | +# Usage |
| 57 | + |
| 58 | +## Setting up your Project |
| 59 | + |
| 60 | +To use this library, you would put the following lines into your `Cargo.toml` file: |
| 61 | + |
| 62 | +```toml |
| 63 | +[dependencies] |
| 64 | +google-groupsmigration1 = "*" |
| 65 | +``` |
| 66 | + |
| 67 | +## A complete example |
| 68 | + |
| 69 | +```Rust |
| 70 | +extern crate hyper; |
| 71 | +extern crate "yup-oauth2" as oauth2; |
| 72 | +extern crate "google-groupsmigration1" as groupsmigration1; |
| 73 | +use groupsmigration1::Result; |
| 74 | +use std::fs; |
| 75 | +use std::default::Default; |
| 76 | +use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; |
| 77 | +use groupsmigration1::GroupsMigration; |
| 78 | + |
| 79 | +// Get an ApplicationSecret instance by some means. It contains the `client_id` and |
| 80 | +// `client_secret`, among other things. |
| 81 | +let secret: ApplicationSecret = Default::default(); |
| 82 | +// Instantiate the authenticator. It will choose a suitable authentication flow for you, |
| 83 | +// unless you replace `None` with the desired Flow. |
| 84 | +// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about |
| 85 | +// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and |
| 86 | +// retrieve them from storage. |
| 87 | +let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, |
| 88 | + hyper::Client::new(), |
| 89 | + <MemoryStorage as Default>::default(), None); |
| 90 | +let mut hub = GroupsMigration::new(hyper::Client::new(), auth); |
| 91 | +// You can configure optional parameters by calling the respective setters at will, and |
| 92 | +// execute the final call using `upload(...)`. |
| 93 | +// Values shown here are possibly random and not representative ! |
| 94 | +let result = hub.archive().insert("groupId") |
| 95 | + .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); |
| 96 | + |
| 97 | +match result { |
| 98 | + Result::HttpError(err) => println!("HTTPERROR: {:?}", err), |
| 99 | + Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"), |
| 100 | + Result::MissingToken => println!("OAuth2: Missing Token"), |
| 101 | + Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size), |
| 102 | + Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"), |
| 103 | + Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field), |
| 104 | + Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err), |
| 105 | + Result::Success(_) => println!("Success (value doesn't print)"), |
| 106 | +} |
| 107 | + |
| 108 | +``` |
| 109 | +## Handling Errors |
| 110 | + |
| 111 | +All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google-groupsmigration1/enum.Result.html) enumeration as return value of |
| 112 | +the doit() methods, or handed as possibly intermediate results to either the |
| 113 | +[Hub Delegate](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google-groupsmigration1/../yup-oauth2/trait.AuthenticatorDelegate.html). |
| 114 | + |
| 115 | +When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This |
| 116 | +makes the system potentially resilient to all kinds of errors. |
| 117 | + |
| 118 | +## Uploads and Downlods |
| 119 | +If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google-groupsmigration1/enum.Result.html), should be |
| 120 | +read by you to obtain the media. |
| 121 | +If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.ResponseResult.html), it will return that by default. |
| 122 | +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 |
| 123 | +this call: `.param("alt", "media")`. |
| 124 | + |
| 125 | +Methods supporting uploads can do so using up to 2 different protocols: |
| 126 | +*simple* and *resumable*. The distinctiveness of each is represented by customized |
| 127 | +`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. |
| 128 | + |
| 129 | +## Customization and Callbacks |
| 130 | + |
| 131 | +You may alter the way an `doit()` method is called by providing a [delegate](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Delegate.html) to the |
| 132 | +[Method Builder](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.CallBuilder.html) before making the final `doit()` call. |
| 133 | +Respective methods will be called to provide progress information, as well as determine whether the system should |
| 134 | +retry on failure. |
| 135 | + |
| 136 | +The [delegate trait](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. |
| 137 | + |
| 138 | +## Optional Parts in Server-Requests |
| 139 | + |
| 140 | +All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.RequestValue.html) and |
| 141 | +[decodable](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.ResponseResult.html) via json. Optionals are used to indicate that partial requests are responses are valid. |
| 142 | +Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.Part.html) which are identifyable by name, which will be sent to |
| 143 | +the server to indicate either the set parts of the request or the desired parts in the response. |
| 144 | + |
| 145 | +## Builder Arguments |
| 146 | + |
| 147 | +Using [method builders](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. |
| 148 | +These will always take a single argument, for which the following statements are true. |
| 149 | + |
| 150 | +* [PODs][wiki-pod] are handed by copy |
| 151 | +* strings are passed as `&str` |
| 152 | +* [request values](http://byron.github.io/google-apis-rs/google-groupsmigration1/trait.RequestValue.html) are borrowed |
| 153 | + |
| 154 | +Arguments will always be copied or cloned into the builder, to make them independent of their original life times. |
| 155 | + |
| 156 | +[wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure |
| 157 | +[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern |
| 158 | +[google-go-api]: https://github.com/google/google-api-go-client |
| 159 | + |
| 160 | +# License |
| 161 | +The **groupsmigration1** library was generated by Sebastian Thiel, and is placed |
| 162 | +under the *MIT* license. |
| 163 | +You can read the full text at the repository's [license file][repo-license]. |
| 164 | + |
| 165 | +[repo-license]: https://github.com/Byron/google-apis-rs/LICENSE.md |
0 commit comments